มอบหมาย
This commit is contained in:
parent
c43eeb9066
commit
7b5e6e5fb0
8 changed files with 279 additions and 2 deletions
22
src/migration/1728290588277-add_table_assign.ts
Normal file
22
src/migration/1728290588277-add_table_assign.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTableAssign1728290588277 implements MigrationInterface {
|
||||
name = 'AddTableAssign1728290588277'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`posMasterAssign\` (\`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', \`posMasterId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง posMaster', \`assignId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง assign', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`CREATE TABLE \`assign\` (\`id\` varchar(255) NOT NULL COMMENT 'ไอดีหลักของตาราง', \`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', \`name\` varchar(255) NULL COMMENT 'ชื่อระบบ', \`description\` varchar(255) NULL COMMENT 'รายละเอียด', \`commandSysId\` varchar(255) NULL COMMENT 'คีย์นอก(FK)ของตาราง CommandSys', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterAssign\` ADD CONSTRAINT \`FK_f5ae6d6c7bc95f304d8652577c4\` FOREIGN KEY (\`posMasterId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterAssign\` ADD CONSTRAINT \`FK_6eab8fe0c6745fce4e584d612a1\` FOREIGN KEY (\`assignId\`) REFERENCES \`assign\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`assign\` ADD CONSTRAINT \`FK_e5f8c525f66832567d1c82361df\` FOREIGN KEY (\`commandSysId\`) REFERENCES \`commandSys\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`assign\` DROP FOREIGN KEY \`FK_e5f8c525f66832567d1c82361df\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterAssign\` DROP FOREIGN KEY \`FK_6eab8fe0c6745fce4e584d612a1\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterAssign\` DROP FOREIGN KEY \`FK_f5ae6d6c7bc95f304d8652577c4\``);
|
||||
await queryRunner.query(`DROP TABLE \`assign\``);
|
||||
await queryRunner.query(`DROP TABLE \`posMasterAssign\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue