|
| 1 | +import type { MigrationBuilder } from "node-pg-migrate"; |
| 2 | + |
| 3 | +export async function up(pgm: MigrationBuilder): Promise<void> { |
| 4 | + pgm.dropConstraint("convention_drafts", "convention_drafts_agency_id_fk"); |
| 5 | + pgm.addConstraint("convention_drafts", "convention_drafts_agency_id_fk", { |
| 6 | + foreignKeys: { |
| 7 | + columns: "agency_id", |
| 8 | + references: "agencies(id)", |
| 9 | + onDelete: "CASCADE", |
| 10 | + }, |
| 11 | + }); |
| 12 | + |
| 13 | + pgm.dropConstraint( |
| 14 | + "convention_templates", |
| 15 | + "convention_templates_agency_id_fk", |
| 16 | + ); |
| 17 | + pgm.addConstraint( |
| 18 | + "convention_templates", |
| 19 | + "convention_templates_agency_id_fk", |
| 20 | + { |
| 21 | + foreignKeys: { |
| 22 | + columns: "agency_id", |
| 23 | + references: "agencies(id)", |
| 24 | + onDelete: "CASCADE", |
| 25 | + }, |
| 26 | + }, |
| 27 | + ); |
| 28 | + |
| 29 | + pgm.dropConstraint( |
| 30 | + "agency_groups__agencies", |
| 31 | + "agency_groups__agencies_agency_id_fkey", |
| 32 | + ); |
| 33 | + pgm.addConstraint( |
| 34 | + "agency_groups__agencies", |
| 35 | + "agency_groups__agencies_agency_id_fkey", |
| 36 | + { |
| 37 | + foreignKeys: { |
| 38 | + columns: "agency_id", |
| 39 | + references: "agencies(id)", |
| 40 | + onDelete: "CASCADE", |
| 41 | + }, |
| 42 | + }, |
| 43 | + ); |
| 44 | +} |
| 45 | + |
| 46 | +export async function down(pgm: MigrationBuilder): Promise<void> { |
| 47 | + pgm.dropConstraint( |
| 48 | + "agency_groups__agencies", |
| 49 | + "agency_groups__agencies_agency_id_fkey", |
| 50 | + ); |
| 51 | + pgm.addConstraint( |
| 52 | + "agency_groups__agencies", |
| 53 | + "agency_groups__agencies_agency_id_fkey", |
| 54 | + { |
| 55 | + foreignKeys: { |
| 56 | + columns: "agency_id", |
| 57 | + references: "agencies(id)", |
| 58 | + }, |
| 59 | + }, |
| 60 | + ); |
| 61 | + |
| 62 | + pgm.dropConstraint( |
| 63 | + "convention_templates", |
| 64 | + "convention_templates_agency_id_fk", |
| 65 | + ); |
| 66 | + pgm.addConstraint( |
| 67 | + "convention_templates", |
| 68 | + "convention_templates_agency_id_fk", |
| 69 | + { |
| 70 | + foreignKeys: { |
| 71 | + columns: "agency_id", |
| 72 | + references: "agencies(id)", |
| 73 | + }, |
| 74 | + }, |
| 75 | + ); |
| 76 | + |
| 77 | + pgm.dropConstraint("convention_drafts", "convention_drafts_agency_id_fk"); |
| 78 | + pgm.addConstraint("convention_drafts", "convention_drafts_agency_id_fk", { |
| 79 | + foreignKeys: { |
| 80 | + columns: "agency_id", |
| 81 | + references: "agencies(id)", |
| 82 | + }, |
| 83 | + }); |
| 84 | +} |
0 commit comments