我正在嘗試從 Heroku 的備份中恢復資料庫,但它失敗了。
我正在使用他們的說明:
heroku pg:backups:restore b101 DATABASE_URL --app example-app
但是得到以下錯誤:
Restoring... !
An error occurred and the backup did not finish.
pg_restore: creating FK CONSTRAINT "public.user_disciplines_usertoken_tokens usertoken_id_refs_id_a11f5e9d"
pg_restore: warning: errors ignored on restore: 16
pg_restore finished with errors
waiting for download to complete
download finished successfully
Run heroku pg:backups:info r2192 for more details.
當我運行建議的命令時,我得到以下資訊:
2022-08-31 15:09:55 0000 pg_restore: connecting to database for restore
2022-08-31 15:09:55 0000 pg_restore: creating EXTENSION "hstore"
2022-08-31 15:09:55 0000 pg_restore: while PROCESSING TOC:
2022-08-31 15:09:55 0000 pg_restore: from TOC entry 2; 3079 95267 EXTENSION hstore (no owner)
2022-08-31 15:09:55 0000 pg_restore: error: could not execute query: ERROR: Extensions can only be created on heroku_ext schema
2022-08-31 15:09:55 0000 CONTEXT: PL/pgSQL function inline_code_block line 7 at RAISE
2022-08-31 15:09:55 0000 Command was: CREATE EXTENSION IF NOT EXISTS "hstore" WITH SCHEMA "public";
2022-08-31 15:09:55 0000
2022-08-31 15:09:55 0000
2022-08-31 15:09:55 0000 pg_restore: creating COMMENT "EXTENSION "hstore""
2022-08-31 15:09:55 0000 pg_restore: from TOC entry 5891; 0 0 COMMENT EXTENSION "hstore"
2022-08-31 15:09:55 0000 pg_restore: error: could not execute query: ERROR: extension "hstore" does not exist
2022-08-31 15:09:55 0000 Command was: COMMENT ON EXTENSION "hstore" IS 'data type for storing sets of (key, value) pairs';
2022-08-31 15:09:55 0000
2022-08-31 15:09:55 0000
2022-08-31 15:09:55 0000 pg_restore: creating EXTENSION "pg_stat_statements"
2022-08-31 15:09:55 0000 pg_restore: from TOC entry 3; 3079 95394 EXTENSION pg_stat_statements (no owner)
2022-08-31 15:09:55 0000 pg_restore: error: could not execute query: ERROR: Extensions can only be created on heroku_ext schema
2022-08-31 15:09:55 0000 CONTEXT: PL/pgSQL function inline_code_block line 6 at RAISE
2022-08-31 15:09:55 0000 Command was: CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "public";
2022-08-31 15:09:55 0000
2022-08-31 15:09:55 0000
2022-08-31 15:09:55 0000 pg_restore: creating COMMENT "EXTENSION "pg_stat_statements""
2022-08-31 15:09:55 0000 pg_restore: from TOC entry 5892; 0 0 COMMENT EXTENSION "pg_stat_statements"
2022-08-31 15:09:55 0000 pg_restore: error: could not execute query: ERROR: extension "pg_stat_statements" does not exist
2022-08-31 15:09:55 0000 Command was: COMMENT ON EXTENSION "pg_stat_statements" IS 'track planning and execution statistics of all SQL statements executed';
因此,問題似乎出在 hstore 擴展上,最近 Heroku 進行了一些更改:https ://devcenter.heroku.com/changelog-items/2446
我聯系了 Heroku 支持,但還沒有得到回復。也許有人知道如何處理這個問題?
uj5u.com熱心網友回復:
以下解決方案有效:
恢復包含公開安裝的擴展的備份
heroku pg:backups:restore <BACKUP_ID> <DATABASE_NAME> --extensions '<LIST_OF_EXTENSIONS>' -a <APP_NAME>
例如:
heroku pg:backups:restore b010 STAGING_DATABASE_URL --extensions 'pg_stat_statements,hstore,pgcrypto' -a example_app
更多詳細資訊: https ://help.heroku.com/ZOFBHJCJ/heroku-postgres-extension-changes-faq
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/503972.html
