import { MigrationInterface, QueryRunner } from "typeorm";

export class UpdateTableOrgDeleteIsNormal11706270464847 implements MigrationInterface {
    name = 'UpdateTableOrgDeleteIsNormal11706270464847'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP FOREIGN KEY \`FK_b9d787230c285dcd0ba4c63d33b\``);
        await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`orgRevisionId\``);
        await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'`);
        await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD CONSTRAINT \`FK_b9d787230c285dcd0ba4c63d33b\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP FOREIGN KEY \`FK_b9d787230c285dcd0ba4c63d33b\``);
        await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`orgRevisionId\``);
        await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`orgRevisionId\` varchar(36) NULL`);
        await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD CONSTRAINT \`FK_b9d787230c285dcd0ba4c63d33b\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

}
