25 lines
785 B
TypeScript
25 lines
785 B
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
export class AddBookingGroupId1789046200000 implements MigrationInterface {
|
|
name = 'AddBookingGroupId1789046200000';
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`
|
|
ALTER TABLE "bookings"
|
|
ADD COLUMN IF NOT EXISTS "bookingGroupId" uuid
|
|
`);
|
|
await queryRunner.query(`
|
|
CREATE INDEX IF NOT EXISTS "IDX_booking_group"
|
|
ON "bookings" ("bookingGroupId")
|
|
WHERE "bookingGroupId" IS NOT NULL
|
|
`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`DROP INDEX IF EXISTS "IDX_booking_group"`);
|
|
await queryRunner.query(`
|
|
ALTER TABLE "bookings" DROP COLUMN IF EXISTS "bookingGroupId"
|
|
`);
|
|
}
|
|
}
|