squash: combine template and protocol migrations
This commit is contained in:
parent
6e618e7531
commit
2aa7ea99ac
5 changed files with 57 additions and 84 deletions
|
@ -47,9 +47,7 @@ import { salutation } from "./entity/configuration/salutation";
|
|||
|
||||
import { BackupAndResetDatabase1738166124200 } from "./migrations/1738166124200-BackupAndResetDatabase";
|
||||
import { CreateSchema1738166167472 } from "./migrations/1738166167472-CreateSchema";
|
||||
import { MemberPrintoutTemplates1742207245862 } from "./migrations/1742207245862-memberPrintoutTemplates";
|
||||
import { Listprinting1742311486232 } from "./migrations/1742311486232-listprinting";
|
||||
import { ProtocolSort1742544887410 } from "./migrations/1742544887410-protocolSort";
|
||||
import { TemplatesAndProtocolSort1742549956787 } from "./migrations/1742549956787-templatesAndProtocolSort";
|
||||
|
||||
const dataSource = new DataSource({
|
||||
type: DB_TYPE as any,
|
||||
|
@ -103,13 +101,7 @@ const dataSource = new DataSource({
|
|||
webapi,
|
||||
webapiPermission,
|
||||
],
|
||||
migrations: [
|
||||
BackupAndResetDatabase1738166124200,
|
||||
CreateSchema1738166167472,
|
||||
MemberPrintoutTemplates1742207245862,
|
||||
Listprinting1742311486232,
|
||||
ProtocolSort1742544887410,
|
||||
],
|
||||
migrations: [BackupAndResetDatabase1738166124200, CreateSchema1738166167472, TemplatesAndProtocolSort1742549956787],
|
||||
migrationsRun: true,
|
||||
migrationsTransactionMode: "each",
|
||||
subscribers: [],
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { templateUsage } from "../entity/configuration/templateUsage";
|
||||
|
||||
export class MemberPrintoutTemplates1742207245862 implements MigrationInterface {
|
||||
name = "MemberPrintoutTemplates1742207245862";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(templateUsage)
|
||||
.values([{ scope: "member" }])
|
||||
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"])
|
||||
.execute();
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.manager.createQueryBuilder().delete().from(templateUsage).where({ scope: "member" }).execute();
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { templateUsage } from "../entity/configuration/templateUsage";
|
||||
|
||||
export class Listprinting1742311486232 implements MigrationInterface {
|
||||
name = "Listprinting1742311486232";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(templateUsage)
|
||||
.where({ scope: "member.list" })
|
||||
.execute();
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(templateUsage)
|
||||
.values([{ scope: "member.list" }])
|
||||
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"])
|
||||
.execute();
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { getDefaultByORM, getTypeByORM } from "./ormHelper";
|
||||
|
||||
export class ProtocolSort1742544887410 implements MigrationInterface {
|
||||
name = "ProtocolSort1742544887410";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.addColumn(
|
||||
"protocol_agenda",
|
||||
new TableColumn({ name: "sort", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) })
|
||||
);
|
||||
|
||||
await queryRunner.addColumn(
|
||||
"protocol_decision",
|
||||
new TableColumn({ name: "sort", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) })
|
||||
);
|
||||
|
||||
await queryRunner.addColumn(
|
||||
"protocol_voting",
|
||||
new TableColumn({ name: "sort", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) })
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropColumn("protocol_agenda", "sort");
|
||||
await queryRunner.dropColumn("protocol_decision", "sort");
|
||||
await queryRunner.dropColumn("protocol_voting", "sort");
|
||||
}
|
||||
}
|
55
src/migrations/1742549956787-templatesAndProtocolSort.ts
Normal file
55
src/migrations/1742549956787-templatesAndProtocolSort.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { templateUsage } from "../entity/configuration/templateUsage";
|
||||
import { getTypeByORM, getDefaultByORM } from "./ormHelper";
|
||||
|
||||
export class TemplatesAndProtocolSort1742549956787 implements MigrationInterface {
|
||||
name = "TemplatesAndProtocolSort1742549956787";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(templateUsage)
|
||||
.values([{ scope: "member" }])
|
||||
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"])
|
||||
.execute();
|
||||
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
.from(templateUsage)
|
||||
.where({ scope: "member.list" })
|
||||
.execute();
|
||||
|
||||
await queryRunner.addColumn(
|
||||
"protocol_agenda",
|
||||
new TableColumn({ name: "sort", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) })
|
||||
);
|
||||
|
||||
await queryRunner.addColumn(
|
||||
"protocol_decision",
|
||||
new TableColumn({ name: "sort", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) })
|
||||
);
|
||||
|
||||
await queryRunner.addColumn(
|
||||
"protocol_voting",
|
||||
new TableColumn({ name: "sort", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) })
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropColumn("protocol_agenda", "sort");
|
||||
await queryRunner.dropColumn("protocol_decision", "sort");
|
||||
await queryRunner.dropColumn("protocol_voting", "sort");
|
||||
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(templateUsage)
|
||||
.values([{ scope: "member.list" }])
|
||||
.orUpdate(["headerId", "bodyId", "footerId", "headerHeight", "footerHeight"], ["scope"])
|
||||
.execute();
|
||||
|
||||
await queryRunner.manager.createQueryBuilder().delete().from(templateUsage).where({ scope: "member" }).execute();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue