mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 21:20:57 +00:00
fix
This commit is contained in:
@@ -2,15 +2,14 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FixOrphanedRouteMilestones1718549400000 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// Clean up orphaned route_milestones records
|
||||
// Delete orphaned route_milestones records (yard_id is NOT NULL, cannot be set to null)
|
||||
await queryRunner.query(`
|
||||
UPDATE "freight"."route_milestones"
|
||||
SET "yard_id" = NULL
|
||||
DELETE FROM "freight"."route_milestones"
|
||||
WHERE "yard_id" IS NOT NULL
|
||||
AND "yard_id" NOT IN (SELECT "id" FROM "freight"."yards")
|
||||
`);
|
||||
|
||||
console.log('✅ Cleaned up orphaned route_milestones records');
|
||||
console.log('✅ Deleted orphaned route_milestones records');
|
||||
}
|
||||
|
||||
public async down(_queryRunner: QueryRunner): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user