Merge branch 'develop' of github.com:Frappet/bma-ehr-development into develop

This commit is contained in:
Kittapath 2024-04-11 11:41:36 +07:00
commit 37bf71aca5
6 changed files with 317 additions and 0 deletions

View file

@ -0,0 +1,42 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableStarty1712810427265 implements MigrationInterface {
name = 'AddTableStarty1712810427265'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`strategyChild4\` (\`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', \`strategyChild4Name\` varchar(255) NULL COMMENT 'ยุทธศาสตร์ย่อยที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', \`strategyChild3Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild3\` (\`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', \`strategyChild3Name\` varchar(255) NULL COMMENT 'ยุทธศาสตร์ที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild2\` (\`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', \`strategyChild2Name\` varchar(255) NULL COMMENT 'ชื่อยุทธศาสตร์/แผน', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild1\` (\`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', \`strategyChild1Name\` varchar(255) NULL COMMENT 'ชื่อยุทธศาสตร์', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`strategyChild5\` (\`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', \`strategyChild5Name\` varchar(255) NULL COMMENT 'กลยุทธ์ที่', \`strategyChild1Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild1', \`strategyChild2Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild2', \`strategyChild3Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild3', \`strategyChild4Id\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง strategyChild4', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_0066b72a1b1e1832ee4e19f1962\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_f22f3637349caf8ba4e96bef6a6\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` ADD CONSTRAINT \`FK_a02975074aac7445aced33ab99d\` FOREIGN KEY (\`strategyChild3Id\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD CONSTRAINT \`FK_678c2b72214a00ba380affeb574\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` ADD CONSTRAINT \`FK_441c2fc2b760d1d0dfb9faca4bc\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild2\` ADD CONSTRAINT \`FK_5dd11a1dac02f7368d6cd5bba34\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_2f396ec33e0f571a4e913ca30f3\` FOREIGN KEY (\`strategyChild1Id\`) REFERENCES \`strategyChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_2c2a8b73ea0fa93ebbd4d81229b\` FOREIGN KEY (\`strategyChild2Id\`) REFERENCES \`strategyChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_67d08068d52226bb028a0d25d36\` FOREIGN KEY (\`strategyChild3Id\`) REFERENCES \`strategyChild3\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` ADD CONSTRAINT \`FK_ad2b70c3a8955e67eec6ce85085\` FOREIGN KEY (\`strategyChild4Id\`) REFERENCES \`strategyChild4\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_ad2b70c3a8955e67eec6ce85085\``);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_67d08068d52226bb028a0d25d36\``);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_2c2a8b73ea0fa93ebbd4d81229b\``);
await queryRunner.query(`ALTER TABLE \`strategyChild5\` DROP FOREIGN KEY \`FK_2f396ec33e0f571a4e913ca30f3\``);
await queryRunner.query(`ALTER TABLE \`strategyChild2\` DROP FOREIGN KEY \`FK_5dd11a1dac02f7368d6cd5bba34\``);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP FOREIGN KEY \`FK_441c2fc2b760d1d0dfb9faca4bc\``);
await queryRunner.query(`ALTER TABLE \`strategyChild3\` DROP FOREIGN KEY \`FK_678c2b72214a00ba380affeb574\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_a02975074aac7445aced33ab99d\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_f22f3637349caf8ba4e96bef6a6\``);
await queryRunner.query(`ALTER TABLE \`strategyChild4\` DROP FOREIGN KEY \`FK_0066b72a1b1e1832ee4e19f1962\``);
await queryRunner.query(`DROP TABLE \`strategyChild5\``);
await queryRunner.query(`DROP TABLE \`strategyChild1\``);
await queryRunner.query(`DROP TABLE \`strategyChild2\``);
await queryRunner.query(`DROP TABLE \`strategyChild3\``);
await queryRunner.query(`DROP TABLE \`strategyChild4\``);
}
}