import { MigrationInterface, QueryRunner } from "typeorm";

export class UpdateTableProfileAddType11707279774838 implements MigrationInterface {
    name = 'UpdateTableProfileAddType11707279774838'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`profile\` ADD \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง'`);
        await queryRunner.query(`ALTER TABLE \`profile\` ADD \`posLevelId\` varchar(40) NULL COMMENT 'ไอดีระดับตำแหน่ง'`);
        await queryRunner.query(`ALTER TABLE \`profile\` ADD \`posTypeId\` varchar(40) NULL COMMENT 'ไอดีประเภทตำแหน่'`);
        await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_9098aae6d26e1d5a274f90240ff\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        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\` DROP FOREIGN KEY \`FK_9098aae6d26e1d5a274f90240ff\``);
        await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`posTypeId\``);
        await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`posLevelId\``);
        await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`position\``);
    }

}
