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

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)
FastAPI + Tortoise ORM + FastAPI Users (Python) - Relationship - Many To Many(FastAPI+Tortoise ORM+FastAPI用户(Python)-关系-多对多)
How can I generate an entity–relationship (ER) diagram of a database using Microsoft SQL Server Management Studio?(如何使用Microsoft SQL Server Management Studio生成数据库的实体关系(ER)图?)
Inserting NaN value into MySQL Database(将NaN值插入MySQL数据库)