fix transportation image

This commit is contained in:
ItsMalma
2025-12-10 11:20:17 +07:00
parent 678ca3c192
commit 2198c9ef04

View File

@@ -0,0 +1,53 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251210041847 extends Migration {
override async up(): Promise<void> {
const knex = this.getKnex();
await knex.schema.dropTable("transportation_image");
await knex.schema.createTable("transportation_image", (table) => {
// Columns
table.string("id", 30).notNullable();
table.string("transportation_id", 30).notNullable();
table.string("src", 100).notNullable();
table.timestamp("created_at", { useTz: true }).notNullable();
table.timestamp("updated_at", { useTz: true }).notNullable();
// Constraints
table.primary(["id"], { constraintName: "transportation_image_pkey" });
table
.foreign(
"transportation_id",
"transportation_image_transportation_id_foreign",
)
.references("transportation_class.id")
.onUpdate("NO ACTION")
.onDelete("CASCADE");
});
}
override async down(): Promise<void> {
const knex = this.getKnex();
await knex.schema.dropTable("transportation_image");
await knex.schema.createTable("transportation_image", (table) => {
// Columns
table.string("id", 30).notNullable();
table.string("transportation_id", 30).notNullable();
table.string("src", 100).notNullable();
table.timestamp("created_at", { useTz: true }).notNullable();
table.timestamp("updated_at", { useTz: true }).notNullable();
// Constraints
table.primary(["id"], { constraintName: "transportation_image_pkey" });
table
.foreign(
"transportation_id",
"transportation_image_transportation_id_foreign",
)
.references("transportation.id")
.onUpdate("NO ACTION")
.onDelete("CASCADE");
});
}
}