无法将Heroku PostgreSQL转储导入本地数据库

时间:2013-04-25 21:38:40

标签: postgresql heroku

我正在尝试将heroku的PostgreSQL转储导入本地数据库(以模仿本地环境中的生产数据)。我在OSX本地使用postgres 9.2。以下是我在控制台中采取的步骤:

dropdb db_dev

createdb db_dev

heroku pgbackups:capture HEROKU_POSTGRESQL_MAROON_URL

curl -o latest.dump `heroku pgbackups:url`

pg_restore --verbose --clean --no-acl --no-owner -h localhost -U connorwarnock -d db-dev latest.dump

以及随后的错误:

pg_restore: connecting to database for restore
pg_restore: dropping COMMENT EXTENSION plpgsql
pg_restore: dropping EXTENSION plpgsql
pg_restore: dropping COMMENT SCHEMA public
pg_restore: dropping SCHEMA public
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 6; 2615 2200 SCHEMA public whgnwlkesexkyo
pg_restore: [archiver (db)] could not execute query: ERROR:  cannot drop schema public because other objects depend on it
DETAIL:  extension hstore depends on schema public
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
Command was: DROP SCHEMA public;

pg_restore: creating SCHEMA public
pg_restore: [archiver (db)] could not execute query: ERROR:  schema "public" already exists
Command was: CREATE SCHEMA public;



pg_restore: creating COMMENT SCHEMA public
pg_restore: creating EXTENSION plpgsql
pg_restore: creating COMMENT EXTENSION plpgsql
pg_restore: setting owner and privileges for SCHEMA public
pg_restore: setting owner and privileges for COMMENT SCHEMA public
pg_restore: setting owner and privileges for EXTENSION plpgsql
pg_restore: setting owner and privileges for COMMENT EXTENSION plpgsql
WARNING: errors ignored on restore: 2

未导入任何数据。似乎公共架构导致了问题(我已经手动删除了架构并再次尝试,但无济于事)。也许hstore扩展会造成麻烦?关于如何避免这些错误的任何其他想法?

1 个答案:

答案 0 :(得分:4)

您的template1似乎包含hstore扩展名以及可能的其他更改。

我建议删除db_dev并从template0重新创建它,这是包含基本默认数据库的只读模板。

createdb -T template0 dev_db

如果不能解决问题,请在此处发布更新的错误并发表评论。