ff-admin-server/src/migrations/1734854680201-template.ts

31 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-12-22 09:29:42 +00:00
import { MigrationInterface, QueryRunner, Table } from "typeorm";
import { DB_TYPE } from "../env.defaults";
export class Template1734854680201 implements MigrationInterface {
name = "Template1734854680201";
public async up(queryRunner: QueryRunner): Promise<void> {
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
await queryRunner.createTable(
new Table({
name: "template",
columns: [
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
{ name: "template", type: "varchar", length: "255", isNullable: false },
{ name: "description", type: "varchar", length: "255", isNullable: true },
{ name: "design", type: "text", isNullable: false, default: "'{}'" },
{ name: "headerHTML", type: "text", isNullable: false, default: "''" },
{ name: "bodyHTML", type: "text", isNullable: false, default: "''" },
{ name: "footerHTML", type: "text", isNullable: false, default: "''" },
],
}),
true
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable("template");
}
}