トラブルシューティング

pem.alertテーブルの復元に失敗する

バックアップからpemバッキングデータベースを復元する場合、 pem.alertテーブルの復元中にエラーが発生する場合があります。これは、テーブルの欠落表の前提条件によって引き起こされる- pg_restoreユーティリティが復元可能pem.alertそれが復元しようとした後、前提条件をpem.alert 。

これが発生した場合、 pg_restoreの出力には、 alertテーブルを参照するエラーメッセージが含まれます。

 pg_restore : [ archiver ( db )] could not execute query : ERROR : insert or
 update on table "alert_history" violates foreign key constraint
 "alert_history_alert_id_fkey"
DETAIL : Key ( alert_id ) = ( 3 ) is not present in table "alert" .
Command was : ALTER TABLE ONLY alert_history
ADD CONSTRAINT alert_history_alert_id_fkey FOREIGN KEY ( alert_id )
 REFERENCES alert ( id ) ON ...
pg_restore : creating FK CONSTRAINT alert_status_alert_id_fkey
pg_restore : [ archiver ( db )] Error from TOC entry 3265 ; 2606 18355 FK
 CONSTRAINT alert_status_alert_id_fkey postgres
pg_restore : [ archiver ( db )] could not execute query : ERROR : insert or
 update on table "alert_status" violates foreign key constraint
 "alert_status_alert_id_fkey"
DETAIL : Key ( alert_id ) = ( 1 ) is not present in table "alert" .
Command was : ALTER TABLE ONLY alert_status
ADD CONSTRAINT alert_status_alert_id_fkey FOREIGN KEY ( alert_id )
 REFERENCES alert ( id ) ON U ...

この問題が発生した場合は、 pem.alertテーブルを復元する前に、 pemデータベースを復元してください。 pemデータベースを復元すると、 pem.alert前提条件がインストールされ、テーブルの復元が期待どおりに完了するはずです。