Disable PostgreSQL foreign key checks for migrations

前端 未结 2 1414
攒了一身酷
攒了一身酷 2020-11-29 18:25

I\'m creating a lot of migrations that have foreign keys in PostgreSQL 9.4.

This is creating a headache because the tables must all be in the exact order expected by

2条回答
  •  攒了一身酷
    2020-11-29 18:56

    For migration, it is easier to disable all triggers with:

    SET session_replication_role = 'replica';
    

    And after migration reenable all with

    SET session_replication_role = 'origin';
    

提交回复
热议问题