Workspace commands writes inupgradeMigration (#19379)
# Introduction As for the instance commands we want to keep a track of what has been run for the workspace commands Note that the history will be updated only when the workspace command has been run through the upgrade directly and not when run atomically ## What's next Later we will use this history in order to determine the current workspace's version and instance's version getting rid of the version in database, that will be the last stone
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddWorkspaceIdToUpgradeMigration1775553825848
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddWorkspaceIdToUpgradeMigration1775553825848';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "core"."upgradeMigration" DROP CONSTRAINT "UQ_upgrade_migration_name_attempt"',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "core"."upgradeMigration" ADD "workspaceId" uuid',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'CREATE UNIQUE INDEX "UQ_upgrade_migration_workspace" ON "core"."upgradeMigration" ("name", "attempt", "workspaceId") WHERE "workspaceId" IS NOT NULL',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'CREATE UNIQUE INDEX "UQ_upgrade_migration_instance" ON "core"."upgradeMigration" ("name", "attempt") WHERE "workspaceId" IS NULL',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "core"."upgradeMigration" ADD CONSTRAINT "FK_77f64a697c55f8802592bd7eeba" FOREIGN KEY ("workspaceId") REFERENCES "core"."workspace"("id") ON DELETE CASCADE ON UPDATE NO ACTION',
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "core"."upgradeMigration" DROP CONSTRAINT "FK_77f64a697c55f8802592bd7eeba"',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'DROP INDEX "core"."UQ_upgrade_migration_instance"',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'DROP INDEX "core"."UQ_upgrade_migration_workspace"',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "core"."upgradeMigration" DROP COLUMN "workspaceId"',
|
||||
);
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "core"."upgradeMigration" ADD CONSTRAINT "UQ_upgrade_migration_name_attempt" UNIQUE ("name", "attempt")',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user