在一个新鲜的Rails项目中从SQLite更改为PostgreSQL [英] Change from SQLite to PostgreSQL in a fresh Rails project

查看:128
本文介绍了在一个新鲜的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?

PS我不知道这个过程是什么,但我已经知道将数据库从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:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆