import { MigrationInterface, QueryRunner } from "typeorm";

export class UpdateTableProfileAddKeycloak1708054669956 implements MigrationInterface {
    name = 'UpdateTableProfileAddKeycloak1708054669956'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`profile\` ADD \`keycloak\` varchar(40) NULL COMMENT 'id keycloak'`);
        await queryRunner.query(`ALTER TABLE \`profile\` DROP FOREIGN KEY \`FK_de774e32853add3313ff44bd793\``);
        await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่ง'`);
        await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_de774e32853add3313ff44bd793\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`profile\` DROP FOREIGN KEY \`FK_de774e32853add3313ff44bd793\``);
        await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`posTypeId\` \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่'`);
        await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_de774e32853add3313ff44bd793\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`keycloak\``);
    }

}
