mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 20:10:56 +00:00
fix
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FixOrphanedRouteMilestones1718549400000 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// Clean up orphaned route_milestones records
|
||||
await queryRunner.query(`
|
||||
UPDATE "freight"."route_milestones"
|
||||
SET "yard_id" = NULL
|
||||
WHERE "yard_id" IS NOT NULL
|
||||
AND "yard_id" NOT IN (SELECT "id" FROM "freight"."yards")
|
||||
`);
|
||||
|
||||
console.log('✅ Cleaned up orphaned route_milestones records');
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
// No rollback needed for data cleanup
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user