Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.2 KB
Raw Blame
import { MigrationInterface, QueryRunner } from 'typeorm'
import { system } from '../../../helper/system/system'

const log = system.globalLogger()

export class ChangeProjectUniqueConstraintToPartialIndex1729098769827 implements MigrationInterface {
    name = 'ChangeProjectUniqueConstraintToPartialIndex1729098769827'

    public async up(queryRunner: QueryRunner): Promise<void> {
        log.info('[changeProjectUniqueConstraintToPartialIndex1729098769827#up]')
        await queryRunner.query(`
          DROP INDEX "idx_project_platform_id_external_id";
        `)

        await queryRunner.query(`
            CREATE UNIQUE INDEX "idx_project_platform_id_external_id"
            ON "project" ("platformId", "externalId")
            WHERE "deleted" IS NULL;
        `)
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        log.info('[changeProjectUniqueConstraintToPartialIndex1729098769827#down]')
        await queryRunner.query(`
            DROP INDEX "idx_project_platform_id_external_id";
        `)

        await queryRunner.query(`
            CREATE UNIQUE INDEX "idx_project_platform_id_external_id"
            ON "project" ("platformId", "externalId");
        `)

    }
}