swagger
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class FixReservesStatusEnum1720500000000 implements MigrationInterface {
|
||||
name = 'FixReservesStatusEnum1720500000000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const oldType = await queryRunner.query(`
|
||||
SELECT 1 FROM pg_type WHERE typname = 'reserves_status_enum_old'
|
||||
`);
|
||||
|
||||
if (oldType.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "reserve_status_history"
|
||||
ALTER COLUMN "fromStatus" TYPE "reserves_status_enum"
|
||||
USING "fromStatus"::text::"reserves_status_enum",
|
||||
ALTER COLUMN "toStatus" TYPE "reserves_status_enum"
|
||||
USING "toStatus"::text::"reserves_status_enum"
|
||||
`);
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "reserves"
|
||||
ALTER COLUMN "status" TYPE "reserves_status_enum"
|
||||
USING "status"::text::"reserves_status_enum"
|
||||
`);
|
||||
|
||||
await queryRunner.query(`DROP TYPE "reserves_status_enum_old"`);
|
||||
}
|
||||
|
||||
public async down(): Promise<void> {
|
||||
// Irreversible cleanup migration.
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ export function getTypeOrmOptions(): TypeOrmModuleOptions {
|
||||
autoLoadEntities: true,
|
||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||
migrations: [__dirname + '/migrations/*.{js,ts}'],
|
||||
synchronize: !isProduction,
|
||||
// synchronize breaks shared PostgreSQL enums (reserves_status_enum is used
|
||||
// by both reserves and reserve_status_history). Use migrations instead.
|
||||
synchronize: false,
|
||||
migrationsRun: isProduction,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user