diff --git a/packages/db/src/migrations/20250924044343_fix_removal.ts b/packages/db/src/migrations/20250924044343_fix_removal.ts new file mode 100644 index 000000000..c66945658 --- /dev/null +++ b/packages/db/src/migrations/20250924044343_fix_removal.ts @@ -0,0 +1,41 @@ +import { type Kysely } from 'kysely'; + +export async function up(db: Kysely) { + // applications + + await db.schema + .alterTable('applications') + .dropConstraint('applications_referral_id_fkey') + .execute(); + + await db.schema + .alterTable('applications') + .addForeignKeyConstraint( + 'applications_referral_id_fkey', + ['referral_id'], + 'referrals', + ['id'] + ) + .onDelete('cascade') + .execute(); + + // opportunity_reports + + await db.schema + .alterTable('opportunity_reports') + .dropConstraint('opportunity_reports_reporter_id_fkey') + .execute(); + + await db.schema + .alterTable('opportunity_reports') + .addForeignKeyConstraint( + 'opportunity_reports_reporter_id_fkey', + ['reporter_id'], + 'students', + ['id'] + ) + .onDelete('cascade') + .execute(); +} + +export async function down(_: Kysely) {}