I'm trying to import ruby on rails project to my computer but am running into all sorts of problems with the database.
我正在尝试将rails项目中的ruby导入我的计算机,但是我遇到了数据库的各种问题。
Here's the situation:
这是情况:
I have an appname.tar.gz that I got from another developer. I extract it and relocated it to my user directory to work with it.
我有一个appname.tar.gz,我是从另一个开发者那里得到的。我将其解压缩并重新定位到我的用户目录以使用它。
- Next I run
bundle install
in the directory to install gem dependencies. - Then I run
rake db:create
to create the database and load the schema and structure from the DB folder in the same directory. This is where I'm running into all sorts of issues. When I launch the app I get an error saying DB migration pending.- structure.sql is a MySQL dump 10.13
- while the database.yml file had the adapter set to postgres:
adapter: postgres
. Is this normal?
structure.sql是一个MySQL转储10.13
而database.yml文件的适配器设置为postgres:adapter:postgres。这是正常的吗?
接下来,我在目录中运行bundle install来安装gem依赖项。
然后我运行rake db:create来创建数据库,并从同一目录中的DB文件夹加载模式和结构。这是我遇到各种各样问题的地方。当我启动应用程序时,我收到一条错误,指出数据库迁移待处理structure.sql是一个MySQL转储10.13,而database.yml文件的适配器设置为postgres:adapter:postgres。这是正常的吗?
Is this the best way to import an existing app into your environment?
这是将现有应用导入您的环境的最佳方式吗?
Any help will be appreciated.
任何帮助将不胜感激。
2 个解决方案
#1
0
To me this sounds like you got a MySQL dump and the application is configured to use postgres. I am wonderning why this is but you can try using the mysql adapter in your config/database.yml
file by setting something like
对我来说,这听起来像你有一个MySQL转储,应用程序配置为使用postgres。我很奇怪为什么会这样,但你可以通过设置类似的方法尝试在config / database.yml文件中使用mysql适配器
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
host: localhost
development:
<<: *default
database: foobar_development
The interesting bit is adapter: mysql2
.
有趣的是适配器:mysql2。
I have taken this from a brand new rails application. You need mysql running for sure.
我从一个全新的rails应用程序中获取了这个。你肯定需要运行mysql。
Hope this helps. If not you have to reach out to the other person to get some postgresql compatible dump.
希望这可以帮助。如果不是,你必须联系其他人获得一些postgresql兼容转储。
#2
0
I got it to work! Thank you all for your help! Really appreciated it. Below are the steps that worked for me:
我得到了它的工作!感谢大家的帮助!真的很感激。以下是对我有用的步骤:
- Copy the project to the new computer
- Open terminal and change directory to the project
- Run
bundle install
to install all the gem dependencies - Run
bundle update
to update installed gems - Start the Postgres server by running
pg_ctl -D /usr/local/var/postgres start
- Run
createdb databasename
to create the database on the new computer. The database name has to match the database mentioned in the database.yml file in the config folder. - Run
rake db:schema:load
and that's it!
将项目复制到新计算机
打开终端并将目录更改为项目
运行bundle install以安装所有gem依赖项
运行捆绑包更新以更新已安装的gem
通过运行pg_ctl -D / usr / local / var / postgres start启动Postgres服务器
运行createdb databasename在新计算机上创建数据库。数据库名称必须与config文件夹中database.yml文件中提到的数据库匹配。
运行rake db:schema:load就是这样!
After following the above steps I was able to run rails s
to check out the website.
按照上面的步骤后,我可以运行rails s来查看网站。
#1
0
To me this sounds like you got a MySQL dump and the application is configured to use postgres. I am wonderning why this is but you can try using the mysql adapter in your config/database.yml
file by setting something like
对我来说,这听起来像你有一个MySQL转储,应用程序配置为使用postgres。我很奇怪为什么会这样,但你可以通过设置类似的方法尝试在config / database.yml文件中使用mysql适配器
default: &default
adapter: mysql2
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root
password:
host: localhost
development:
<<: *default
database: foobar_development
The interesting bit is adapter: mysql2
.
有趣的是适配器:mysql2。
I have taken this from a brand new rails application. You need mysql running for sure.
我从一个全新的rails应用程序中获取了这个。你肯定需要运行mysql。
Hope this helps. If not you have to reach out to the other person to get some postgresql compatible dump.
希望这可以帮助。如果不是,你必须联系其他人获得一些postgresql兼容转储。
#2
0
I got it to work! Thank you all for your help! Really appreciated it. Below are the steps that worked for me:
我得到了它的工作!感谢大家的帮助!真的很感激。以下是对我有用的步骤:
- Copy the project to the new computer
- Open terminal and change directory to the project
- Run
bundle install
to install all the gem dependencies - Run
bundle update
to update installed gems - Start the Postgres server by running
pg_ctl -D /usr/local/var/postgres start
- Run
createdb databasename
to create the database on the new computer. The database name has to match the database mentioned in the database.yml file in the config folder. - Run
rake db:schema:load
and that's it!
将项目复制到新计算机
打开终端并将目录更改为项目
运行bundle install以安装所有gem依赖项
运行捆绑包更新以更新已安装的gem
通过运行pg_ctl -D / usr / local / var / postgres start启动Postgres服务器
运行createdb databasename在新计算机上创建数据库。数据库名称必须与config文件夹中database.yml文件中提到的数据库匹配。
运行rake db:schema:load就是这样!
After following the above steps I was able to run rails s
to check out the website.
按照上面的步骤后,我可以运行rails s来查看网站。