fix package detail transportation
This commit is contained in:
@@ -4,18 +4,18 @@ export class Migration20251203114705 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
const knex = this.getKnex();
|
||||
|
||||
await knex.schema.alterTable("package", (table) => {
|
||||
await knex.schema.alterTable("package_detail", (table) => {
|
||||
table.decimal("quad_discount", 10, 2).notNullable().defaultTo(0);
|
||||
table.decimal("triple_discount", 10, 2).notNullable().defaultTo(0);
|
||||
table.decimal("double_discount", 10, 2).notNullable().defaultTo(0);
|
||||
table.decimal("infant_discount", 10, 2).notNullable().defaultTo(0);
|
||||
table.decimal("infant_discount", 10, 2).nullable();
|
||||
});
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
const knex = this.getKnex();
|
||||
|
||||
await knex.schema.alterTable("package", (table) => {
|
||||
await knex.schema.alterTable("package_detail", (table) => {
|
||||
table.dropColumn("quad_discount");
|
||||
table.dropColumn("triple_discount");
|
||||
table.dropColumn("double_discount");
|
||||
|
||||
47
src/database/migrations/Migration20251210043520.ts
Normal file
47
src/database/migrations/Migration20251210043520.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251210043520 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
const knex = this.getKnex();
|
||||
|
||||
knex.schema.alterTable("package_detail", (table) => {
|
||||
table.dropColumn("transportation_id");
|
||||
});
|
||||
|
||||
knex.schema.alterTable("package_detail", (table) => {
|
||||
// Columns
|
||||
table.string("transportation_id", 30).notNullable();
|
||||
// Constraints
|
||||
table
|
||||
.foreign(
|
||||
"transportation_id",
|
||||
"package_detail_transportation_id_foreign",
|
||||
)
|
||||
.references("transportation_class.id")
|
||||
.onUpdate("NO ACTION")
|
||||
.onDelete("CASCADE");
|
||||
});
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
const knex = this.getKnex();
|
||||
|
||||
knex.schema.alterTable("package_detail", (table) => {
|
||||
table.dropColumn("transportation_id");
|
||||
});
|
||||
|
||||
knex.schema.alterTable("package_detail", (table) => {
|
||||
// Columns
|
||||
table.string("transportation_id", 30).notNullable();
|
||||
// Constraints
|
||||
table
|
||||
.foreign(
|
||||
"transportation_id",
|
||||
"package_detail_transportation_id_foreign",
|
||||
)
|
||||
.references("transportation.id")
|
||||
.onUpdate("NO ACTION")
|
||||
.onDelete("CASCADE");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user