简体   繁体   English

使用postgres.app使用现有的Rails应用程序迁移到postgresql

[英]migrating to postgresql with an existing rails app using postgres.app

I have been using the default sqlite3 to date, however as I would ultimately like to deploy using postgres I think it would be best to try it out in my development environment rather than launching myself into production untested. 到目前为止,我一直在使用默认的sqlite3,但是由于最终我希望使用postgres进行部署,我认为最好在开发环境中进行尝试,而不是未经测试就投入生产。

Several points a) once i have the pg.app running, how do test it? 要点a)一旦我运行了pg.app,该如何测试? b) in my config/database.yml file b)在我的config / database.yml文件中

development:
  adapter: postgresql
  encoding: unicode
  database: 
  pool: 5
  username:
  password:

how do i know what the default name of my database is, and how would I got about setting up a user, is this even necessary? 我怎么知道数据库的默认名称是什么,以及如何设置用户,这是否有必要?

Finally, when i check 最后,当我检查

which psql

I am told that 有人告诉我

/usr/bin/psql

I think that this PATH is incorrect that I will need to modify it, is this so and if so why? 我认为此PATH不正确,因此我需要对其进行修改,是这样,如果是,为什么呢?

Im sure this is relatively simple but thanks in advance for any help you can offer. 我确定这是相对简单的,但在此先感谢您提供的任何帮助。

EDIT 1: 编辑1:

During my error googling, and prior attempts, I shot up a similar error to this chap Repairing Postgresql after upgrading to OSX 10.7 Lion and thought that it may be a similar problem despite the fact that he is using homebrew? 在我的错误搜索和之前的尝试期间,我在升级到OSX 10.7 Lion后出现了与该小伙子“ 修复Postgresql”类似的错误,并认为尽管他正在使用自制软件,但可能是类似的问题?

EDIT 2: 编辑2:

My .bash_profile file 我的.bash_profile文件

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . [[-s“ $ HOME / .rvm / scripts / rvm”]] &&。 "$HOME/.rvm/scripts/rvm" # Load RVM function export PATH=/usr/local/bin:$PATH “ $ HOME / .rvm / scripts / rvm”#加载RVM函数导出PATH = / usr / local / bin:$ PATH

A few things you need to do to get postgres.app up and running. 您需要做一些事情来启动和运行postgres.app It looks like you are using the default postgres install with Mac OS X /usr/bin/psql which is good as it should be easy to get this fixed. 看来您正在Mac OS X /usr/bin/psql上使用默认的postgres安装,这很好,因为应该很容易就能解决此问题。

The main action is to make sure that the path to the postgres.app is set in your PATH . 主要操作是确保在您的PATH设置了postgres.appPATH Your .profile , .bashrc or .zshrc (whichever you use) should have the following appended to the start of your Path with the following. 您的.profile.bashrc.zshrc (无论使用哪种)都应在路径的开头附加以下内容。

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

This will ensure that postgres.app is used in preference to any other install by prepending it to your current path. 这样可以确保将postgres.app放在当前路径之前,优先于其他安装使用。 You shouldn't need any other config, 您不需要任何其他配置,

The second action is to set up your database.yml . 第二步是设置您的database.yml Postgres.app comes pre-configured with your local Mac username so you don't need to add or change it for everything to just work. Postgres.app预先配置了本地Mac用户名,因此您无需添加或更改它即可使一切正常工作。 You also don't need to specify it in database.yml . 您也不需要在database.yml指定它。 Development should work with the following: 开发应与以下各项一起工作:

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: appname_development

Postgres.app will auto create the database that has been specified when you migrate the database for the first time. Postgres.app将自动创建首次迁移数据库时指定的数据库。 The name of your database is up to you but the convention is application_name underscore environment . 数据库的名称由您决定,但是约定是application_name下划线environment

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM