2013-04-25 90 views
4

我試圖從heroku導入PostgreSQL轉儲到本地數據庫(模擬本地環境中的生產數據)。我正在OSX上本地使用postgres 9.2。以下是我已經邁出了我的控制檯的步驟:無法將Heroku PostgreSQL轉儲導入本地數據庫

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

當您嘗試手動刪除'public'然後恢復時,請顯示您收到的錯誤。 'DROP EXTENSION hstore; DROP SCHEMA public CASCADE;'。 – 2013-04-25 23:39:08

回答

4

它看起來像你的template1包含hstore擴展和可能的其他變化。

我建議刪除db_dev並從template0(包含基本默認數據庫的只讀模板)重新創建它。

createdb -T template0 dev_db 

如果這沒有辦法,請發佈更新的錯誤和評論在這裏。

+0

有一種感覺hstore正在惹麻煩,感謝修復。 – Connor 2013-05-02 08:58:38

相關問題