mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 22:18:12 +00:00
fix
This commit is contained in:
@@ -2,15 +2,14 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
|||||||
|
|
||||||
export class FixOrphanedRouteMilestones1718549400000 implements MigrationInterface {
|
export class FixOrphanedRouteMilestones1718549400000 implements MigrationInterface {
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
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(`
|
await queryRunner.query(`
|
||||||
UPDATE "freight"."route_milestones"
|
DELETE FROM "freight"."route_milestones"
|
||||||
SET "yard_id" = NULL
|
|
||||||
WHERE "yard_id" IS NOT NULL
|
WHERE "yard_id" IS NOT NULL
|
||||||
AND "yard_id" NOT IN (SELECT "id" FROM "freight"."yards")
|
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> {
|
public async down(_queryRunner: QueryRunner): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user