add dtos and fix entities including migrations

This commit is contained in:
Anika Raemer 2025-09-27 18:21:10 +02:00
parent ad6ee64565
commit d94251dea4
9 changed files with 125 additions and 3 deletions

View file

@ -0,0 +1,49 @@
import { MigrationInterface, QueryRunner, Table, TableColumn } from "typeorm";
export class UpdateIngredientTable1758988727469 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// rename title column to name
await queryRunner.renameColumn(
"recipe_ingredient",
"title",
"name"
)
// add missing columns
await queryRunner.addColumns(
"recipe_ingredient",
[
new TableColumn({
name: "amount",
type: "numeric",
isNullable: true,
}),
new TableColumn({
name: "unit",
type: "varchar",
isNullable: true,
}),
new TableColumn({
name: "subtext",
type: "varchar",
isNullable: true,
})
]
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
// rename name column to title
await queryRunner.renameColumn(
"recipe_ingredient",
"name",
"title"
)
// remove columns
await queryRunner.dropColumns(
"recipe_ingredient",
["amount", "unit", "subtext"]
)
}
}

View file

@ -0,0 +1,12 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class DropNotNullForIngredientGroupTitle1758988748273 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query("ALTER TABLE recipe_ingredient_group ALTER COLUMN title DROP NOT NULL")
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}