enhance: add updateAt column to query
This commit is contained in:
parent
9fefd93f09
commit
f1ed6d095a
3 changed files with 28 additions and 1 deletions
22
src/migrations/1744795756230-QueryUpdatedAt.ts
Normal file
22
src/migrations/1744795756230-QueryUpdatedAt.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { getTypeByORM, getDefaultByORM } from "./ormHelper";
|
||||
|
||||
export class QueryUpdatedAt1744795756230 implements MigrationInterface {
|
||||
name = "QueryUpdatedAt1744795756230";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.addColumn(
|
||||
"query",
|
||||
new TableColumn({
|
||||
name: "updatedAt",
|
||||
...getTypeByORM("datetime", false, 6),
|
||||
default: getDefaultByORM("currentTimestamp", 6),
|
||||
onUpdate: getDefaultByORM<string>("currentTimestamp", 6),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropColumn("query", "updatedAt");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue