fix transportation image
This commit is contained in:
53
src/database/migrations/Migration20251210041847.ts
Normal file
53
src/database/migrations/Migration20251210041847.ts
Normal 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");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user