将数据库名称从SQlite3更改为Postgres

时间:2017-08-25 19:35:55

标签: ruby-on-rails postgresql heroku sqlite

我目前正在尝试从SQlite3切换到Postgres,并想知道如何更改我的数据库名称?根据Heroku的说法,他们说this

  

请注意,适配器名称为postgresql而非postgrespg。你也会   需要更改数据库:自定义名称。最终版本可能会   看起来像这样:

development:
  adapter: postgresql
  database: my_database_development
  pool: 5
  timeout: 5000
test:
  adapter: postgresql
  database: my_database_test
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: my_database_production
  pool: 5
  timeout: 5000

我现在看到我的测试环境的数据库名称有以下内容:

test:
  <<: *default
  database: db/test.sqlite3

对于这个(以及开发和生产环境),我只需要更改数据库的名称,还是需要做更多的事情。因为对于SQLite3文件,它具有.sqlite3扩展名。 postgres有类似的情况吗?

1 个答案:

答案 0 :(得分:1)

是的,您只需更改每个其他环境的数据库名称即可。

  

&lt;&lt;:*默认

表示这是将在其他环境中使用的配置的一部分,因此您不必复制代码(DRY)。

对于postgres,你不必提供扩展(我记得)。 只需为数据库提供明确的名称,这应该可行。

相关问题