18 lines
2.6 KiB
TypeScript
18 lines
2.6 KiB
TypeScript
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
|
|
export class AddTableCommandSign1730456393834 implements MigrationInterface {
|
|
name = 'AddTableCommandSign1730456393834'
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`CREATE TABLE \`commandSign\` (\`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', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`comment\` varchar(255) NULL COMMENT 'ความเห็น', \`isActive\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT 0, \`commandId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง command', \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
|
await queryRunner.query(`ALTER TABLE \`commandSign\` ADD CONSTRAINT \`FK_143488a80d2317daa9333e1a726\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
await queryRunner.query(`ALTER TABLE \`commandSign\` ADD CONSTRAINT \`FK_748a443f8f9d4fa32dfddad0b2e\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.query(`ALTER TABLE \`commandSign\` DROP FOREIGN KEY \`FK_748a443f8f9d4fa32dfddad0b2e\``);
|
|
await queryRunner.query(`ALTER TABLE \`commandSign\` DROP FOREIGN KEY \`FK_143488a80d2317daa9333e1a726\``);
|
|
await queryRunner.query(`DROP TABLE \`commandSign\``);
|
|
}
|
|
|
|
}
|