cro*_*don 15 postgresql ruby-on-rails
I do the following on my server:
pg_dump -O -c register_production > register.sql
Run Code Online (Sandbox Code Playgroud)
Then, after copying register.sql to my local environment, I try:
psql register_development < register.sql
Run Code Online (Sandbox Code Playgroud)
This appears to work, but when I try to launch the Rails site locally, I get this:
PG::UndefinedTable: ERROR: relation "list_items" does not exist at character 28
Run Code Online (Sandbox Code Playgroud)
How can I restore everything (including relations) from the server db to my local dev db?
Ver*_*cus 49
我使用此命令来保存我的数据库:
pg_dump -F c -v -U postgres -h localhost <database_name> -f /tmp/<filename>.psql
Run Code Online (Sandbox Code Playgroud)
这要恢复它:
pg_restore -c -C -F c -v -U postgres /tmp/<filename>.psql
Run Code Online (Sandbox Code Playgroud)
这将以Postgres的自定义格式(-F c
)转储数据库,默认情况下压缩该格式并允许重新排序其内容.-C -c
将删除数据库(如果已存在)然后重新创建它,对您的情况有帮助.并-v
指定详细信息,以便您可以确切了解发生了什么.
归档时间: |
|
查看次数: |
16797 次 |
最近记录: |