在新的 Rails 项目中从 SQLite 更改为 PostgreSQL

我有一个 rails 应用程序,它的数据库位于 SQLite(开发和生产)中.由于我要转移到 heroku,我想将我的数据库转换为 PostgreSQL.

I have a rails app that's databases are in SQLite (The dev and production). Since I am moving to heroku, I want to convert my database to PostgreSQL.

总之,我听说本地、开发、数据库不需要从SQLite改变,所以我不需要改变,但是,我如何将生产环境从SQLite改变到PostgreSQL?

Anyways, I heard that the local, development, database does not need to be changed from SQLite, so I don't need to change that, however, how do I go about changing the production environment from SQLite to PostgreSQL?

有没有人以前做过这个并且可以提供帮助?

Has anyone ever done this before and can help?

附言我不确定这个过程到底叫什么,但我听说过将数据库从 SQLite 迁移到 PostgreSQL,这是需要做的吗?

P.S. I'm not sure what exactly this process is called, but I've heard about migrating the database from SQLite to PostgreSQL, is that what needs to be done?

推荐答案

你可以把你的 database.yml 改成这样,而不是使用开箱即用的 sqlite one:

You can change your database.yml to this instead of using the out of the box sqlite one:

development:
  adapter: postgresql
  encoding: utf8
  database: project_development
  pool: 5
  username: 
  password:

test: &TEST
  adapter: postgresql
  encoding: utf8
  database: project_test
  pool: 5
  username: 
  password:

production:
  adapter: postgresql
  encoding: utf8
  database: project_production
  pool: 5
  username: 
  password:

cucumber:
  <<: *TEST

相关文章