2016-05-06 3 views
0

Ich kann meine Backup-DB auf heroku DB nicht wiederherstellen, aber ich habe kein Problem, wenn ich auf meinem lokalen env wiederherstellen und ich bekomme keine Fehler.Fehler: Befehl war: SELECT pg_catalog.setval

Wenn ich versuche, auf Heroku wiederherzustellen verbindet Datenbank ich diese folgende Fehlermeldung erhalten:

C:\Program Files\PostgreSQL\9.4\bin\pg_restore.exe --host XXXXXX.compute-1.amazonaws.com --port 5432 --username "XXXXokwpyzewicl" --dbname "d9uto7paqXXX" --no-password --verbose

"C:\Users\XXXX\Desktop\loans.backup"

pg_restore: connecting to database for restore pg_restore: implied data-only restore

pg_restore: processing data for table "application_denial_reason_types"

pg_restore: [archiver (db)] Error while PROCESSING TOC:

pg_restore: [archiver (db)] Error from TOC entry 5202; 0 16622 TABLE DATA application_denial_reason_types postgres

pg_restore: [archiver (db)] could not execute query: ERROR: relation "application_denial_reason_types" does not exist Command was: COPY application_denial_reason_types (denial_reason_type_id, denial_reason_type_name, description, active, created_by, creat... pg_restore: executing SEQUENCE SET application_denial_reason_types_denial_reason_type_id_seq

pg_restore: [archiver (db)] Error from TOC entry 5672; 0 0 SEQUENCE SET application_denial_reason_types_denial_reason_type_id_seq postgres

pg_restore: [archiver (db)] could not execute query: ERROR: relation "application_denial_reason_types_denial_reason_type_id_seq" does not exist LINE 1: SELECT pg_catalog.setval('application_denial_reason_types_de... ^ Command was: SELECT pg_catalog.setval('application_denial_reason_types_denial_reason_type_id_seq', 1, false);

Wie behebe ich diesen Fehler?

Antwort

0

Es wird versucht Wert von nicht vorhandenen Sequenz einzustellen:

pg_restore: [archiver (db)] could not execute query: ERROR: relation "application_denial_reason_types_denial_reason_type_id_seq" does not exist

der Grund nehmen alook am verstehen:

pg_restore: connecting to database for restore pg_restore: implied data-only restore

Wenn Sie man pg_restore überprüfen Sie feststellen, dass:

-a 
    --data-only 
     Restore only the data, not the schema (data definitions). Table data, large objects, and sequence values are restored, if 

present in the archive.

Sie haben wahrscheinlich Datenstruktur auf Ihrem lokalen env, und deshalb setzen Sie v für vorhandene Sequenz. Und es gibt keine Struktur auf Heroku, so dass Sie Fehler bekommen.

Entfernen Sie -a von pg_restore Befehl, um DDL vor der Datenwiederherstellung auszuführen.