migrate (fix data type) #153

This commit is contained in:
Bright 2025-09-10 13:20:34 +07:00
parent 45922287ea
commit 8ef8207cc0
3 changed files with 47 additions and 11 deletions

View file

@ -256,10 +256,10 @@ export class Registry extends EntityBase {
birthdate: Date;
@Column({
type: "text",
nullable: true,
comment: "วุฒิการศึกษา",
length: 255,
default: null,
default: null
})
degrees: string;
@ -350,18 +350,18 @@ export class Registry extends EntityBase {
Educations: string;
@Column({
type: "text",
nullable: true,
comment: "ระดับศึกษา",
length: 255,
default: null,
default: null
})
educationLevels: string;
@Column({
type: "text",
nullable: true,
comment: "สาขาวิชา/ทาง",
length: 255,
default: null,
default: null
})
fields: string;
}

View file

@ -248,9 +248,9 @@ export class RegistryEmployee extends EntityBase {
birthdate: Date;
@Column({
type: "text",
nullable: true,
comment: "วุฒิการศึกษา",
length: 255,
default: null,
})
degrees: string;
@ -313,18 +313,18 @@ export class RegistryEmployee extends EntityBase {
Educations: string;
@Column({
type: "text",
nullable: true,
comment: "ระดับศึกษา",
length: 255,
default: null,
default: null
})
educationLevels: string;
@Column({
type: "text",
nullable: true,
comment: "สาขาวิชา/ทาง",
length: 255,
default: null,
default: null
})
fields: string;

View file

@ -0,0 +1,36 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateDataTypeFieldsRegistryAndRegistryEmpployee1757484721787 implements MigrationInterface {
name = 'UpdateDataTypeFieldsRegistryAndRegistryEmpployee1757484721787'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`degrees\``);
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`degrees\` text NULL COMMENT 'วุฒิการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`educationLevels\``);
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`educationLevels\` text NULL COMMENT 'ระดับศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`fields\``);
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`fields\` text NULL COMMENT 'สาขาวิชา/ทาง'`);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`degrees\``);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`degrees\` text NULL COMMENT 'วุฒิการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`educationLevels\``);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`educationLevels\` text NULL COMMENT 'ระดับศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`fields\``);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`fields\` text NULL COMMENT 'สาขาวิชา/ทาง'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`fields\``);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`fields\` varchar(255) NULL COMMENT 'สาขาวิชา/ทาง'`);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`educationLevels\``);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`educationLevels\` varchar(255) NULL COMMENT 'ระดับศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` DROP COLUMN \`degrees\``);
await queryRunner.query(`ALTER TABLE \`registryEmployee\` ADD \`degrees\` varchar(255) NULL COMMENT 'วุฒิการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`fields\``);
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`fields\` varchar(255) NULL COMMENT 'สาขาวิชา/ทาง'`);
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`educationLevels\``);
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`educationLevels\` varchar(255) NULL COMMENT 'ระดับศึกษา'`);
await queryRunner.query(`ALTER TABLE \`registry\` DROP COLUMN \`degrees\``);
await queryRunner.query(`ALTER TABLE \`registry\` ADD \`degrees\` varchar(255) NULL COMMENT 'วุฒิการศึกษา'`);
}
}