add dtos and fix entities including migrations
This commit is contained in:
parent
ad6ee64565
commit
d94251dea4
9 changed files with 125 additions and 3 deletions
49
src/migrations/1758988727469-UpdateIngredientTable.ts
Normal file
49
src/migrations/1758988727469-UpdateIngredientTable.ts
Normal 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"]
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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> {
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue