import { MigrationInterface, QueryRunner } from "typeorm";

export class AddProfiledevelopment11724754372183 implements MigrationInterface {
    name = 'AddProfiledevelopment11724754372183'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`developmentProject\` DROP FOREIGN KEY \`FK_4913ef1466f9f35c1429e213d4b\``);
        await queryRunner.query(`ALTER TABLE \`developmentProject\` DROP FOREIGN KEY \`FK_8e3f2e86427befeff4283ae80f0\``);
        // await queryRunner.query(`CREATE TABLE \`subDistrictImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`DISTRICT_CODE\` varchar(255) NULL, \`DISTRICT_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`provinceImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`PROVINCE_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_POSITION_OFFICER\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`MP_POS_DATE\` text NULL, \`SALARY\` text NULL, \`MP_COMMAND_NUM\` text NULL, \`POS_NUM_NAME\` text NULL, \`POS_NUM_CODE\` text NULL, \`FLAG_TO_NAME\` text NULL, \`WORK_LINE_NAME\` text NULL, \`SPECIALIST_NAME\` text NULL, \`ADMIN_NAME\` text NULL, \`REMARK\` text NULL, \`ORDER_MOVE_POSITION\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_EDUCATION_EMP\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`HR_EDUCATION\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`educationMis\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`EDUCATION_CODE\` varchar(255) NULL, \`EDUCATION_NAME\` varchar(255) NULL, \`EDUCATION_ABB_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        // await queryRunner.query(`CREATE TABLE \`amphurImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`AMPHUR_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` ADD \`kpiDevelopmentId\` varchar(40) NULL COMMENT 'id kpi development'`);
        await queryRunner.query(`ALTER TABLE \`profileDevelopment\` ADD \`kpiDevelopmentId\` varchar(40) NULL COMMENT 'id kpi development'`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`profileDevelopment\` DROP COLUMN \`kpiDevelopmentId\``);
        await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` DROP COLUMN \`kpiDevelopmentId\``);
        // await queryRunner.query(`DROP TABLE \`amphurImport\``);
        // await queryRunner.query(`DROP TABLE \`educationMis\``);
        // await queryRunner.query(`DROP TABLE \`HR_EDUCATION\``);
        // await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_ADDRESS\``);
        // await queryRunner.query(`DROP TABLE \`HR_EDUCATION_EMP\``);
        // await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_FAMILY\``);
        // await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_ADDRESS\``);
        // await queryRunner.query(`DROP TABLE \`HR_POSITION_OFFICER\``);
        // await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_FAMILY\``);
        // await queryRunner.query(`DROP TABLE \`provinceImport\``);
        // await queryRunner.query(`DROP TABLE \`subDistrictImport\``);
        await queryRunner.query(`ALTER TABLE \`developmentProject\` ADD CONSTRAINT \`FK_8e3f2e86427befeff4283ae80f0\` FOREIGN KEY (\`profileDevelopmentHistoryId\`) REFERENCES \`profileDevelopmentHistory\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE \`developmentProject\` ADD CONSTRAINT \`FK_4913ef1466f9f35c1429e213d4b\` FOREIGN KEY (\`profileDevelopmentId\`) REFERENCES \`profileDevelopment\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

}
