Change from SQLite to PostgreSQL in a fresh Rails project(在新的 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
这篇关于在新的 Rails 项目中从 SQLite 更改为 PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在新的 Rails 项目中从 SQLite 更改为 PostgreSQL


- 在SQL中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01