restart migration

This commit is contained in:
ItsMalma
2025-11-30 10:28:36 +07:00
parent 66c8d9681a
commit f8f130e2f8
13 changed files with 6469 additions and 6857 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,367 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251104110158 extends Migration {
override async up(): Promise<void> {
this.addSql(
`create table "airline" ("id" varchar(30) not null, "code" varchar(10) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "logo" varchar(100) not null, "skytrax_rating" int null, "skytrax_type" text check ("skytrax_type" in ('full_service', 'low_cost')) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "airline_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "airline" add constraint "airline_code_unique" unique ("code");`,
);
this.addSql(
`alter table "airline" add constraint "airline_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "airline" add constraint "airline_logo_unique" unique ("logo");`,
);
this.addSql(
`create table "country" ("id" varchar(30) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "country_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "country" add constraint "country_slug_unique" unique ("slug");`,
);
this.addSql(
`create table "city" ("id" varchar(30) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "country_id" varchar(30) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "city_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "city" add constraint "city_slug_unique" unique ("slug");`,
);
this.addSql(
`create table "airport" ("id" varchar(30) not null, "code" varchar(10) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "city_id" varchar(30) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "airport_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "airport" add constraint "airport_code_unique" unique ("code");`,
);
this.addSql(
`alter table "airport" add constraint "airport_slug_unique" unique ("slug");`,
);
this.addSql(
`create table "flight" ("id" varchar(30) not null, "slug" varchar(220) not null, "airline_id" varchar(30) not null, "number" int not null, "departure_airport_id" varchar(30) not null, "departure_terminal" varchar(100) null, "departure_gate" varchar(100) null, "departure_time" time(0) not null, "arrival_airport_id" varchar(30) not null, "arrival_terminal" varchar(100) null, "arrival_gate" varchar(100) null, "duration" int not null, "aircraft" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "flight" add constraint "flight_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "flight" add constraint "flight_airline_id_number_unique" unique ("airline_id", "number");`,
);
this.addSql(
`create table "flight_class" ("id" varchar(30) not null, "slug" varchar(420) not null, "flight_id" varchar(30) not null, "class" varchar(100) not null, "seat_layout" varchar(10) not null, "baggage" int not null, "cabin_baggage" int not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_class_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "flight_class" add constraint "flight_class_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "flight_class" add constraint "flight_class_flight_id_class_unique" unique ("flight_id", "class");`,
);
this.addSql(
`create table "hotel" ("id" varchar(30) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "city_id" varchar(30) not null, "star" int not null, "google_maps_link" varchar(500) not null, "google_maps_embed" varchar(500) not null, "google_reviews_link" varchar(500) not null, "description" varchar(1000) not null, "address" varchar(100) not null, "landmark" varchar(100) not null, "distance_to_landmark" numeric(10,0) not null, "food_type" varchar(100) not null, "food_amount" int not null, "food_menu" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "hotel_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "hotel" add constraint "hotel_slug_unique" unique ("slug");`,
);
this.addSql(
`create table "hotel_facility" ("id" varchar(30) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "icon" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "hotel_facility_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "hotel_facility" add constraint "hotel_facility_slug_unique" unique ("slug");`,
);
this.addSql(
`create table "hotel_facilities" ("hotel_id" varchar(30) not null, "hotel_facility_id" varchar(30) not null, constraint "hotel_facilities_pkey" primary key ("hotel_id", "hotel_facility_id"));`,
);
this.addSql(
`create table "hotel_image" ("id" varchar(30) not null, "hotel_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "hotel_image_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package" ("id" varchar(30) not null, "slug" varchar(200) not null, "name" varchar(100) not null, "type" text check ("type" in ('reguler', 'plus')) not null, "class" text check ("class" in ('silver', 'gold', 'platinum')) not null, "thumbnail" varchar(100) not null, "use_fast_train" boolean not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "package" add constraint "package_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "package" add constraint "package_thumbnail_unique" unique ("thumbnail");`,
);
this.addSql(
`create table "transportation" ("id" varchar(30) not null, "slug" varchar(100) not null, "name" varchar(100) not null, "type" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "transportation_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "transportation" add constraint "transportation_slug_unique" unique ("slug");`,
);
this.addSql(
`create table "transportation_class" ("id" varchar(30) not null, "slug" varchar(400) not null, "transportation_id" varchar(30) not null, "class" varchar(100) not null, "total_seats" int not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "transportation_class_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "transportation_class" add constraint "transportation_class_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "transportation_class" add constraint "transportation_class_transportation_id_class_unique" unique ("transportation_id", "class");`,
);
this.addSql(
`create table "package_detail" ("id" varchar(30) not null, "slug" varchar(200) not null, "package_id" varchar(30) not null, "departure_date" date not null, "makkah_hotel_id" varchar(30) not null, "madinah_hotel_id" varchar(30) not null, "transportation_id" varchar(30) not null, "quad_price" numeric(10,0) not null, "triple_price" numeric(10,0) not null, "double_price" numeric(10,0) not null, "infant_price" numeric(10,0) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_detail_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_package_id_departure_date_unique" unique ("package_id", "departure_date");`,
);
this.addSql(
`create table "package_detail_tour_hotels" ("id" serial primary key, "package_detail_id" varchar(30) not null, "hotel_id" varchar(30) not null);`,
);
this.addSql(
`create table "package_detail_tour_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
);
this.addSql(
`create table "package_detail_outbound_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
);
this.addSql(
`create table "package_detail_inbound_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
);
this.addSql(
`create table "transportation_class_image" ("id" varchar(30) not null, "transportation_class_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "transportation_class_image_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "city" add constraint "city_country_id_foreign" foreign key ("country_id") references "country" ("id") on update cascade;`,
);
this.addSql(
`alter table "airport" add constraint "airport_city_id_foreign" foreign key ("city_id") references "city" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight" add constraint "flight_airline_id_foreign" foreign key ("airline_id") references "airline" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight" add constraint "flight_departure_airport_id_foreign" foreign key ("departure_airport_id") references "airport" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight" add constraint "flight_arrival_airport_id_foreign" foreign key ("arrival_airport_id") references "airport" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight_class" add constraint "flight_class_flight_id_foreign" foreign key ("flight_id") references "flight" ("id") on update cascade;`,
);
this.addSql(
`alter table "hotel" add constraint "hotel_city_id_foreign" foreign key ("city_id") references "city" ("id") on update cascade;`,
);
this.addSql(
`alter table "hotel_facilities" add constraint "hotel_facilities_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "hotel_facilities" add constraint "hotel_facilities_hotel_facility_id_foreign" foreign key ("hotel_facility_id") references "hotel_facility" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "transportation_class" add constraint "transportation_class_transportation_id_foreign" foreign key ("transportation_id") references "transportation" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_package_id_foreign" foreign key ("package_id") references "package" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_tour_flight_classes" add constraint "package_detail_tour_flight_classes_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_tour_flight_classes" add constraint "package_detail_tour_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_outbound_flight_classes" add constraint "package_detail_outbound_flight_classes_package_d_8b70d_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_outbound_flight_classes" add constraint "package_detail_outbound_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_inbound_flight_classes" add constraint "package_detail_inbound_flight_classes_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_inbound_flight_classes" add constraint "package_detail_inbound_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "transportation_class_image" add constraint "transportation_class_image_transportation_class_id_foreign" foreign key ("transportation_class_id") references "transportation_class" ("id") on update cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "flight" drop constraint "flight_airline_id_foreign";`,
);
this.addSql(
`alter table "city" drop constraint "city_country_id_foreign";`,
);
this.addSql(
`alter table "airport" drop constraint "airport_city_id_foreign";`,
);
this.addSql(`alter table "hotel" drop constraint "hotel_city_id_foreign";`);
this.addSql(
`alter table "flight" drop constraint "flight_departure_airport_id_foreign";`,
);
this.addSql(
`alter table "flight" drop constraint "flight_arrival_airport_id_foreign";`,
);
this.addSql(
`alter table "flight_class" drop constraint "flight_class_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_flight_classes" drop constraint "package_detail_tour_flight_classes_flight_class_id_foreign";`,
);
this.addSql(
`alter table "package_detail_outbound_flight_classes" drop constraint "package_detail_outbound_flight_classes_flight_class_id_foreign";`,
);
this.addSql(
`alter table "package_detail_inbound_flight_classes" drop constraint "package_detail_inbound_flight_classes_flight_class_id_foreign";`,
);
this.addSql(
`alter table "hotel_facilities" drop constraint "hotel_facilities_hotel_id_foreign";`,
);
this.addSql(
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_hotel_id_foreign";`,
);
this.addSql(
`alter table "hotel_facilities" drop constraint "hotel_facilities_hotel_facility_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_package_id_foreign";`,
);
this.addSql(
`alter table "transportation_class" drop constraint "transportation_class_transportation_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_transportation_id_foreign";`,
);
this.addSql(
`alter table "transportation_class_image" drop constraint "transportation_class_image_transportation_class_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_package_detail_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_flight_classes" drop constraint "package_detail_tour_flight_classes_package_detail_id_foreign";`,
);
this.addSql(
`alter table "package_detail_outbound_flight_classes" drop constraint "package_detail_outbound_flight_classes_package_d_8b70d_foreign";`,
);
this.addSql(
`alter table "package_detail_inbound_flight_classes" drop constraint "package_detail_inbound_flight_classes_package_detail_id_foreign";`,
);
this.addSql(`drop table if exists "airline" cascade;`);
this.addSql(`drop table if exists "country" cascade;`);
this.addSql(`drop table if exists "city" cascade;`);
this.addSql(`drop table if exists "airport" cascade;`);
this.addSql(`drop table if exists "flight" cascade;`);
this.addSql(`drop table if exists "flight_class" cascade;`);
this.addSql(`drop table if exists "hotel" cascade;`);
this.addSql(`drop table if exists "hotel_facility" cascade;`);
this.addSql(`drop table if exists "hotel_facilities" cascade;`);
this.addSql(`drop table if exists "hotel_image" cascade;`);
this.addSql(`drop table if exists "package" cascade;`);
this.addSql(`drop table if exists "transportation" cascade;`);
this.addSql(`drop table if exists "transportation_class" cascade;`);
this.addSql(`drop table if exists "package_detail" cascade;`);
this.addSql(`drop table if exists "package_detail_tour_hotels" cascade;`);
this.addSql(
`drop table if exists "package_detail_tour_flight_classes" cascade;`,
);
this.addSql(
`drop table if exists "package_detail_outbound_flight_classes" cascade;`,
);
this.addSql(
`drop table if exists "package_detail_inbound_flight_classes" cascade;`,
);
this.addSql(`drop table if exists "transportation_class_image" cascade;`);
}
}

View File

@@ -1,91 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251108053920 extends Migration {
override async up(): Promise<void> {
this.addSql(
`create table "hotel_schedule" ("id" varchar(30) not null, "hotel_id" varchar(30) not null, "check_in" time(0) not null, "check_out" time(0) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "hotel_schedule_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "hotel_schedule" add constraint "hotel_schedule_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_hotel_id_foreign";`,
);
this.addSql(
`alter table "flight_class" alter column "slug" type varchar(200) using ("slug"::varchar(200));`,
);
this.addSql(
`alter table "transportation_class" alter column "slug" type varchar(200) using ("slug"::varchar(200));`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" rename column "hotel_id" to "hotel_schedule_id";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_hotel_schedule_id_foreign" foreign key ("hotel_schedule_id") references "hotel_schedule" ("id") on update cascade on delete cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_hotel_schedule_id_foreign";`,
);
this.addSql(`drop table if exists "hotel_schedule" cascade;`);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "flight_class" alter column "slug" type varchar(420) using ("slug"::varchar(420));`,
);
this.addSql(
`alter table "transportation_class" alter column "slug" type varchar(400) using ("slug"::varchar(400));`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" rename column "hotel_schedule_id" to "hotel_id";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete cascade;`,
);
}
}

View File

@@ -1,226 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251110080126 extends Migration {
override async up(): Promise<void> {
this.addSql(
`create table "flight_schedule" ("id" varchar(30) not null, "flight_id" varchar(30) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_schedule_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary_day" ("id" varchar(30) not null, "title" varchar(100) not null, "description" varchar(1000) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_itinerary_day_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary" ("id" varchar(30) not null, "location" varchar(100) not null, "day_id" varchar(30) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_itinerary_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary_image" ("id" varchar(30) not null, "package_itinerary_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "package_itinerary_image_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary_widget" ("id" varchar(30) not null, "package_itinerary_day_id" varchar(30) not null, "type" text check ("type" in ('transport', 'hotel', 'information')) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, "hotel_id" varchar(30) null, "description" varchar(1000) null, "transportation" varchar(100) null, "from" varchar(100) null, "to" varchar(100) null, constraint "package_itinerary_widget_pkey" primary key ("id"));`,
);
this.addSql(
`create index "package_itinerary_widget_type_index" on "package_itinerary_widget" ("type");`,
);
this.addSql(
`create table "transportation_image" ("id" varchar(30) not null, "transportation_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "transportation_image_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "flight_schedule" add constraint "flight_schedule_flight_id_foreign" foreign key ("flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "package_itinerary_image" add constraint "package_itinerary_image_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_package_itinerary_day_id_foreign" foreign key ("package_itinerary_day_id") references "package_itinerary_day" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
);
this.addSql(
`drop table if exists "package_detail_tour_flight_classes" cascade;`,
);
this.addSql(
`drop table if exists "package_detail_outbound_flight_classes" cascade;`,
);
this.addSql(
`drop table if exists "package_detail_inbound_flight_classes" cascade;`,
);
this.addSql(`drop table if exists "transportation_class_image" cascade;`);
this.addSql(
`alter table "airline" alter column "skytrax_rating" type int using ("skytrax_rating"::int);`,
);
this.addSql(
`alter table "airline" alter column "skytrax_rating" set not null;`,
);
this.addSql(
`alter table "package_detail" add column "tour_flight_id" varchar(30) not null, add column "outbound_flight_id" varchar(30) not null, add column "inbound_flight_id" varchar(30) not null, add column "package_itinerary_id" varchar(30) not null;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_pkey";`,
);
this.addSql(`alter table "package_detail_tour_hotels" drop column "id";`);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_pkey" primary key ("package_detail_id", "hotel_schedule_id");`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_widget" drop constraint "package_itinerary_widget_package_itinerary_day_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_image" drop constraint "package_itinerary_image_package_itinerary_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_package_itinerary_id_foreign";`,
);
this.addSql(
`create table "package_detail_tour_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
);
this.addSql(
`create table "package_detail_outbound_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
);
this.addSql(
`create table "package_detail_inbound_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
);
this.addSql(
`create table "transportation_class_image" ("id" varchar(30) not null, "transportation_class_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "transportation_class_image_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "package_detail_tour_flight_classes" add constraint "package_detail_tour_flight_classes_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_tour_flight_classes" add constraint "package_detail_tour_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_outbound_flight_classes" add constraint "package_detail_outbound_flight_classes_package_d_8b70d_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_outbound_flight_classes" add constraint "package_detail_outbound_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_inbound_flight_classes" add constraint "package_detail_inbound_flight_classes_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_inbound_flight_classes" add constraint "package_detail_inbound_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "transportation_class_image" add constraint "transportation_class_image_transportation_class_id_foreign" foreign key ("transportation_class_id") references "transportation_class" ("id") on update cascade;`,
);
this.addSql(`drop table if exists "flight_schedule" cascade;`);
this.addSql(`drop table if exists "package_itinerary_day" cascade;`);
this.addSql(`drop table if exists "package_itinerary" cascade;`);
this.addSql(`drop table if exists "package_itinerary_image" cascade;`);
this.addSql(`drop table if exists "package_itinerary_widget" cascade;`);
this.addSql(`drop table if exists "transportation_image" cascade;`);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
);
this.addSql(
`alter table "airline" alter column "skytrax_rating" type int using ("skytrax_rating"::int);`,
);
this.addSql(
`alter table "airline" alter column "skytrax_rating" drop not null;`,
);
this.addSql(
`alter table "package_detail" drop column "tour_flight_id", drop column "outbound_flight_id", drop column "inbound_flight_id", drop column "package_itinerary_id";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_pkey";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add column "id" serial not null;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_pkey" primary key ("id");`,
);
}
}

View File

@@ -1,133 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251111010042 extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table "airline" drop constraint "airline_slug_unique";`);
this.addSql(`alter table "airline" drop column "slug";`);
this.addSql(`alter table "country" drop constraint "country_slug_unique";`);
this.addSql(`alter table "country" drop column "slug";`);
this.addSql(`alter table "city" drop constraint "city_slug_unique";`);
this.addSql(`alter table "city" drop column "slug";`);
this.addSql(`alter table "airport" drop constraint "airport_slug_unique";`);
this.addSql(`alter table "airport" drop column "slug";`);
this.addSql(`alter table "flight" drop constraint "flight_slug_unique";`);
this.addSql(`alter table "flight" drop column "slug";`);
this.addSql(
`alter table "flight_class" drop constraint "flight_class_slug_unique";`,
);
this.addSql(`alter table "flight_class" drop column "slug";`);
this.addSql(`alter table "hotel" drop constraint "hotel_slug_unique";`);
this.addSql(`alter table "hotel" drop column "slug";`);
this.addSql(
`alter table "hotel_facility" drop constraint "hotel_facility_slug_unique";`,
);
this.addSql(`alter table "hotel_facility" drop column "slug";`);
this.addSql(`alter table "package" drop constraint "package_slug_unique";`);
this.addSql(`alter table "package" drop column "slug";`);
this.addSql(
`alter table "transportation" drop constraint "transportation_slug_unique";`,
);
this.addSql(`alter table "transportation" drop column "slug";`);
this.addSql(
`alter table "transportation_class" drop constraint "transportation_class_slug_unique";`,
);
this.addSql(`alter table "transportation_class" drop column "slug";`);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_slug_unique";`,
);
this.addSql(`alter table "package_detail" drop column "slug";`);
}
override async down(): Promise<void> {
this.addSql(
`alter table "airline" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "airline" add constraint "airline_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "country" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "country" add constraint "country_slug_unique" unique ("slug");`,
);
this.addSql(`alter table "city" add column "slug" varchar(200) not null;`);
this.addSql(
`alter table "city" add constraint "city_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "airport" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "airport" add constraint "airport_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "flight" add column "slug" varchar(220) not null;`,
);
this.addSql(
`alter table "flight" add constraint "flight_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "flight_class" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "flight_class" add constraint "flight_class_slug_unique" unique ("slug");`,
);
this.addSql(`alter table "hotel" add column "slug" varchar(200) not null;`);
this.addSql(
`alter table "hotel" add constraint "hotel_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "hotel_facility" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "hotel_facility" add constraint "hotel_facility_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "package" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "package" add constraint "package_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "transportation" add column "slug" varchar(100) not null;`,
);
this.addSql(
`alter table "transportation" add constraint "transportation_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "transportation_class" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "transportation_class" add constraint "transportation_class_slug_unique" unique ("slug");`,
);
this.addSql(
`alter table "package_detail" add column "slug" varchar(200) not null;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_slug_unique" unique ("slug");`,
);
}
}

View File

@@ -1,27 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251112104244 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table "hotel" alter column "google_maps_link" type varchar(1000) using ("google_maps_link"::varchar(1000));`,
);
this.addSql(
`alter table "hotel" alter column "google_maps_embed" type varchar(1000) using ("google_maps_embed"::varchar(1000));`,
);
this.addSql(
`alter table "hotel" alter column "google_reviews_link" type varchar(1000) using ("google_reviews_link"::varchar(1000));`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "hotel" alter column "google_maps_link" type varchar(500) using ("google_maps_link"::varchar(500));`,
);
this.addSql(
`alter table "hotel" alter column "google_maps_embed" type varchar(500) using ("google_maps_embed"::varchar(500));`,
);
this.addSql(
`alter table "hotel" alter column "google_reviews_link" type varchar(500) using ("google_reviews_link"::varchar(500));`,
);
}
}

View File

@@ -1,35 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251112105017 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" drop not null;`,
);
this.addSql(
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on delete cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" set not null;`,
);
this.addSql(
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
);
}
}

View File

@@ -1,35 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251112105413 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" drop not null;`,
);
this.addSql(
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on delete cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" set not null;`,
);
this.addSql(
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
);
}
}

View File

@@ -1,47 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251112134446 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_class" ("id") on update cascade;`,
);
}
}

View File

@@ -1,29 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251112140208 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table "package_detail" drop constraint "package_detail_package_itinerary_id_foreign";`,
);
this.addSql(
`alter table "package_detail" rename column "package_itinerary_id" to "itinerary_id";`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on update cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
);
this.addSql(
`alter table "package_detail" rename column "itinerary_id" to "package_itinerary_id";`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
);
}
}

View File

@@ -1,283 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251113230544 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
);
this.addSql(
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
);
this.addSql(
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
);
this.addSql(
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" set not null;`,
);
this.addSql(
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_itinerary" alter column "day_id" type varchar(30) using ("day_id"::varchar(30));`,
);
this.addSql(
`alter table "package_itinerary" alter column "day_id" drop not null;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" alter column "tour_flight_id" type varchar(30) using ("tour_flight_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "tour_flight_id" drop not null;`,
);
this.addSql(
`alter table "package_detail" alter column "outbound_flight_id" type varchar(30) using ("outbound_flight_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "outbound_flight_id" drop not null;`,
);
this.addSql(
`alter table "package_detail" alter column "inbound_flight_id" type varchar(30) using ("inbound_flight_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "inbound_flight_id" drop not null;`,
);
this.addSql(
`alter table "package_detail" alter column "makkah_hotel_id" type varchar(30) using ("makkah_hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "makkah_hotel_id" drop not null;`,
);
this.addSql(
`alter table "package_detail" alter column "madinah_hotel_id" type varchar(30) using ("madinah_hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "madinah_hotel_id" drop not null;`,
);
this.addSql(
`alter table "package_detail" alter column "itinerary_id" type varchar(30) using ("itinerary_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "itinerary_id" drop not null;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on delete cascade;`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" set not null;`,
);
this.addSql(
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
);
this.addSql(
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
);
this.addSql(
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
);
this.addSql(
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "hotel_image" alter column "hotel_id" drop not null;`,
);
this.addSql(
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "package_itinerary" alter column "day_id" type varchar(30) using ("day_id"::varchar(30));`,
);
this.addSql(
`alter table "package_itinerary" alter column "day_id" set not null;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "package_detail" alter column "tour_flight_id" type varchar(30) using ("tour_flight_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "tour_flight_id" set not null;`,
);
this.addSql(
`alter table "package_detail" alter column "outbound_flight_id" type varchar(30) using ("outbound_flight_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "outbound_flight_id" set not null;`,
);
this.addSql(
`alter table "package_detail" alter column "inbound_flight_id" type varchar(30) using ("inbound_flight_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "inbound_flight_id" set not null;`,
);
this.addSql(
`alter table "package_detail" alter column "makkah_hotel_id" type varchar(30) using ("makkah_hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "makkah_hotel_id" set not null;`,
);
this.addSql(
`alter table "package_detail" alter column "madinah_hotel_id" type varchar(30) using ("madinah_hotel_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "madinah_hotel_id" set not null;`,
);
this.addSql(
`alter table "package_detail" alter column "itinerary_id" type varchar(30) using ("itinerary_id"::varchar(30));`,
);
this.addSql(
`alter table "package_detail" alter column "itinerary_id" set not null;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel_schedule" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on update cascade;`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`,
);
this.addSql(
`alter table "transportation_image" alter column "transportation_id" drop not null;`,
);
this.addSql(
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on delete cascade;`,
);
}
}

View File

@@ -1,184 +0,0 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251119103455 extends Migration {
override async up(): Promise<void> {
this.addSql(
`create type "skytrax_type" as enum ('full_service', 'low_cost');`,
);
this.addSql(`create type "package_type" as enum ('reguler', 'plus');`);
this.addSql(
`create type "package_class" as enum ('silver', 'gold', 'platinum');`,
);
this.addSql(
`create type "package_itinerary_widget_type" as enum ('hotel', 'information', 'transport');`,
);
this.addSql(
`create type "verification_type" as enum ('admin:create', 'admin:changeEmail', 'admin:changePassword', 'admin:update', 'partner:create', 'partner:changeEmail', 'partner:changePassword', 'partner:update', 'order:create');`,
);
this.addSql(
`create type "room_type" as enum ('double', 'triple', 'quad', 'infant');`,
);
this.addSql(
`create type "admin_permission" as enum ('country:create', 'country:update', 'country:delete', 'city:create', 'city:update', 'city:delete', 'airline:create', 'airline:update', 'airline:delete', 'airport:create', 'airport:update', 'airport:delete', 'flight:create', 'flight:update', 'flight:delete', 'flight-class:create', 'flight-class:update', 'flight-class:delete', 'hotel-facility:create', 'hotel-facility:update', 'hotel-facility:delete', 'hotel:create', 'hotel:update', 'hotel:delete', 'transportation:create', 'transportation:update', 'transportation:delete', 'transportation-class:create', 'transportation-class:update', 'transportation-class:delete', 'package:create', 'package:update', 'package:delete', 'package-detail:create', 'package-detail:update', 'package-detail:delete', 'admin:create', 'admin:update', 'admin:delete', 'partner:create', 'partner:update', 'partner:delete');`,
);
this.addSql(
`create table "verification" ("id" varchar(30) not null, "code" char(6) not null, "type" "verification_type" not null, "expired_at" timestamptz not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "verification_pkey" primary key ("id"));`,
);
this.addSql(
`create table "partner" ("id" varchar(30) not null, "name" varchar(100) not null, "email" varchar(254) not null, "whatsapp" varchar(20) not null, "password" text not null, "avatar" varchar(100) null, "verification_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "partner_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "partner" add constraint "partner_email_unique" unique ("email");`,
);
this.addSql(
`alter table "partner" add constraint "partner_whatsapp_unique" unique ("whatsapp");`,
);
this.addSql(
`create table "order" ("id" varchar(30) not null, "package_id" varchar(30) not null, "name" varchar(100) not null, "whatsapp" varchar(20) not null, "verification_id" varchar(30) null, "partner_id" varchar(30) null, "expired_at" timestamptz null, "purchased_at" timestamptz null, "finished_at" timestamptz null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "order_pkey" primary key ("id"));`,
);
this.addSql(
`create table "order_detail" ("id" varchar(30) not null, "order_id" varchar(30) not null, "room_type" "room_type" not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "order_detail_pkey" primary key ("id"));`,
);
this.addSql(
`create table "admin" ("id" varchar(30) not null, "name" varchar(100) not null, "email" varchar(254) not null, "password" text not null, "avatar" varchar(100) null, "permissions" "admin_permission"[] not null, "verification_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "admin_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "admin" add constraint "admin_email_unique" unique ("email");`,
);
this.addSql(
`alter table "partner" add constraint "partner_verification_id_foreign" foreign key ("verification_id") references "verification" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "order" add constraint "order_package_id_foreign" foreign key ("package_id") references "package_detail" ("id") on update cascade;`,
);
this.addSql(
`alter table "order" add constraint "order_verification_id_foreign" foreign key ("verification_id") references "verification" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "order" add constraint "order_partner_id_foreign" foreign key ("partner_id") references "partner" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "order_detail" add constraint "order_detail_order_id_foreign" foreign key ("order_id") references "order" ("id") on update cascade;`,
);
this.addSql(
`alter table "admin" add constraint "admin_verification_id_foreign" foreign key ("verification_id") references "verification" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "airline" drop constraint if exists "airline_skytrax_type_check";`,
);
this.addSql(
`alter table "package" drop constraint if exists "package_type_check";`,
);
this.addSql(
`alter table "package" drop constraint if exists "package_class_check";`,
);
this.addSql(
`alter table "package_itinerary_widget" drop constraint if exists "package_itinerary_widget_type_check";`,
);
this.addSql(`alter table "airline" drop constraint "airline_logo_unique";`);
this.addSql(
`alter table "airline" alter column "skytrax_type" type "skytrax_type" using ("skytrax_type"::"skytrax_type");`,
);
this.addSql(
`alter table "package" drop constraint "package_thumbnail_unique";`,
);
this.addSql(
`alter table "package" alter column "type" type "package_type" using ("type"::"package_type");`,
);
this.addSql(
`alter table "package" alter column "class" type "package_class" using ("class"::"package_class");`,
);
this.addSql(
`alter table "package_itinerary_widget" alter column "type" type "package_itinerary_widget_type" using ("type"::"package_itinerary_widget_type");`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "partner" drop constraint "partner_verification_id_foreign";`,
);
this.addSql(
`alter table "order" drop constraint "order_verification_id_foreign";`,
);
this.addSql(
`alter table "admin" drop constraint "admin_verification_id_foreign";`,
);
this.addSql(
`alter table "order" drop constraint "order_partner_id_foreign";`,
);
this.addSql(
`alter table "order_detail" drop constraint "order_detail_order_id_foreign";`,
);
this.addSql(`drop table if exists "verification" cascade;`);
this.addSql(`drop table if exists "partner" cascade;`);
this.addSql(`drop table if exists "order" cascade;`);
this.addSql(`drop table if exists "order_detail" cascade;`);
this.addSql(`drop table if exists "admin" cascade;`);
this.addSql(
`alter table "airline" alter column "skytrax_type" type text using ("skytrax_type"::text);`,
);
this.addSql(
`alter table "airline" add constraint "airline_skytrax_type_check" check("skytrax_type" in ('full_service', 'low_cost'));`,
);
this.addSql(
`alter table "airline" add constraint "airline_logo_unique" unique ("logo");`,
);
this.addSql(
`alter table "package" alter column "type" type text using ("type"::text);`,
);
this.addSql(
`alter table "package" alter column "class" type text using ("class"::text);`,
);
this.addSql(
`alter table "package" add constraint "package_type_check" check("type" in ('reguler', 'plus'));`,
);
this.addSql(
`alter table "package" add constraint "package_class_check" check("class" in ('silver', 'gold', 'platinum'));`,
);
this.addSql(
`alter table "package" add constraint "package_thumbnail_unique" unique ("thumbnail");`,
);
this.addSql(
`alter table "package_itinerary_widget" alter column "type" type text using ("type"::text);`,
);
this.addSql(
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_type_check" check("type" in ('transport', 'hotel', 'information'));`,
);
this.addSql(`drop type "skytrax_type";`);
this.addSql(`drop type "package_type";`);
this.addSql(`drop type "package_class";`);
this.addSql(`drop type "package_itinerary_widget_type";`);
this.addSql(`drop type "verification_type";`);
this.addSql(`drop type "room_type";`);
this.addSql(`drop type "admin_permission";`);
}
}

View File

@@ -0,0 +1,490 @@
import { Migration } from "@mikro-orm/migrations";
export class Migration20251130032813 extends Migration {
override async up(): Promise<void> {
this.addSql(
`create type "skytrax_type" as enum ('full_service', 'low_cost');`,
);
this.addSql(`create type "package_type" as enum ('reguler', 'plus');`);
this.addSql(
`create type "package_class" as enum ('silver', 'gold', 'platinum');`,
);
this.addSql(
`create type "package_itinerary_widget_type" as enum ('hotel', 'information', 'transport');`,
);
this.addSql(
`create type "verification_type" as enum ('admin:create', 'admin:changeEmail', 'admin:changePassword', 'admin:update', 'partner:create', 'partner:changeEmail', 'partner:changePassword', 'partner:update', 'order:create');`,
);
this.addSql(
`create type "room_type" as enum ('double', 'triple', 'quad', 'infant');`,
);
this.addSql(
`create type "admin_permission" as enum ('country:create', 'country:update', 'country:delete', 'city:create', 'city:update', 'city:delete', 'airline:create', 'airline:update', 'airline:delete', 'airport:create', 'airport:update', 'airport:delete', 'flight:create', 'flight:update', 'flight:delete', 'flight-class:create', 'flight-class:update', 'flight-class:delete', 'hotel-facility:create', 'hotel-facility:update', 'hotel-facility:delete', 'hotel:create', 'hotel:update', 'hotel:delete', 'transportation:create', 'transportation:update', 'transportation:delete', 'transportation-class:create', 'transportation-class:update', 'transportation-class:delete', 'package:create', 'package:update', 'package:delete', 'package-detail:create', 'package-detail:update', 'package-detail:delete', 'admin:create', 'admin:update', 'admin:delete', 'partner:create', 'partner:update', 'partner:delete');`,
);
this.addSql(
`create table "airline" ("id" varchar(30) not null, "name" varchar(100) not null, "code" varchar(10) not null, "logo" varchar(100) not null, "skytrax_rating" int not null, "skytrax_type" "skytrax_type" not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "airline_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "airline" add constraint "airline_code_unique" unique ("code");`,
);
this.addSql(
`create table "country" ("id" varchar(30) not null, "name" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "country_pkey" primary key ("id"));`,
);
this.addSql(
`create table "city" ("id" varchar(30) not null, "name" varchar(100) not null, "country_id" varchar(30) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "city_pkey" primary key ("id"));`,
);
this.addSql(
`create table "airport" ("id" varchar(30) not null, "name" varchar(100) not null, "code" varchar(10) not null, "city_id" varchar(30) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "airport_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "airport" add constraint "airport_code_unique" unique ("code");`,
);
this.addSql(
`create table "flight" ("id" varchar(30) not null, "airline_id" varchar(30) not null, "number" int not null, "departure_airport_id" varchar(30) not null, "departure_terminal" varchar(100) null, "departure_gate" varchar(100) null, "departure_time" time(0) not null, "arrival_airport_id" varchar(30) not null, "arrival_terminal" varchar(100) null, "arrival_gate" varchar(100) null, "duration" int not null, "aircraft" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "flight" add constraint "flight_airline_id_number_unique" unique ("airline_id", "number");`,
);
this.addSql(
`create table "flight_class" ("id" varchar(30) not null, "flight_id" varchar(30) not null, "class" varchar(100) not null, "seat_layout" varchar(10) not null, "baggage" int not null, "cabin_baggage" int not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_class_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "flight_class" add constraint "flight_class_flight_id_class_unique" unique ("flight_id", "class");`,
);
this.addSql(
`create table "flight_schedule" ("id" varchar(30) not null, "flight_id" varchar(30) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_schedule_pkey" primary key ("id"));`,
);
this.addSql(
`create table "hotel" ("id" varchar(30) not null, "name" varchar(100) not null, "city_id" varchar(30) not null, "star" int not null, "google_maps_link" varchar(1000) not null, "google_maps_embed" varchar(1000) not null, "google_reviews_link" varchar(1000) not null, "description" varchar(1000) not null, "address" varchar(100) not null, "landmark" varchar(100) not null, "distance_to_landmark" numeric(10,0) not null, "food_type" varchar(100) not null, "food_amount" int not null, "food_menu" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "hotel_pkey" primary key ("id"));`,
);
this.addSql(
`create table "hotel_facility" ("id" varchar(30) not null, "name" varchar(100) not null, "icon" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "hotel_facility_pkey" primary key ("id"));`,
);
this.addSql(
`create table "hotel_facilities" ("hotel_id" varchar(30) not null, "hotel_facility_id" varchar(30) not null, constraint "hotel_facilities_pkey" primary key ("hotel_id", "hotel_facility_id"));`,
);
this.addSql(
`create table "hotel_image" ("id" varchar(30) not null, "hotel_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "hotel_image_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package" ("id" varchar(30) not null, "name" varchar(100) not null, "type" "package_type" not null, "class" "package_class" not null, "thumbnail" varchar(100) not null, "use_fast_train" boolean not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary_day" ("id" varchar(30) not null, "title" varchar(100) not null, "description" varchar(1000) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_itinerary_day_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary" ("id" varchar(30) not null, "location" varchar(100) not null, "day_id" varchar(30) null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_itinerary_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary_image" ("id" varchar(30) not null, "package_itinerary_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "package_itinerary_image_pkey" primary key ("id"));`,
);
this.addSql(
`create table "package_itinerary_widget" ("id" varchar(30) not null, "package_itinerary_day_id" varchar(30) not null, "type" "package_itinerary_widget_type" not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, "hotel_id" varchar(30) null, "description" varchar(1000) null, "transportation" varchar(100) null, "from" varchar(100) null, "to" varchar(100) null, constraint "package_itinerary_widget_pkey" primary key ("id"));`,
);
this.addSql(
`create index "package_itinerary_widget_type_index" on "package_itinerary_widget" ("type");`,
);
this.addSql(
`create table "transportation" ("id" varchar(30) not null, "name" varchar(100) not null, "type" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "transportation_pkey" primary key ("id"));`,
);
this.addSql(
`create table "transportation_class" ("id" varchar(30) not null, "transportation_id" varchar(30) not null, "class" varchar(100) not null, "total_seats" int not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "transportation_class_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "transportation_class" add constraint "transportation_class_transportation_id_class_unique" unique ("transportation_id", "class");`,
);
this.addSql(
`create table "package_detail" ("id" varchar(30) not null, "package_id" varchar(30) not null, "departure_date" date not null, "tour_flight_id" varchar(30) null, "outbound_flight_id" varchar(30) null, "inbound_flight_id" varchar(30) null, "makkah_hotel_id" varchar(30) null, "madinah_hotel_id" varchar(30) null, "transportation_id" varchar(30) not null, "quad_price" numeric(10,0) not null, "triple_price" numeric(10,0) not null, "double_price" numeric(10,0) not null, "infant_price" numeric(10,0) null, "itinerary_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_detail_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_package_id_departure_date_unique" unique ("package_id", "departure_date");`,
);
this.addSql(
`create table "package_detail_tour_hotels" ("package_detail_id" varchar(30) not null, "hotel_id" varchar(30) not null, constraint "package_detail_tour_hotels_pkey" primary key ("package_detail_id", "hotel_id"));`,
);
this.addSql(
`create table "transportation_image" ("id" varchar(30) not null, "transportation_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "transportation_image_pkey" primary key ("id"));`,
);
this.addSql(
`create table "verification" ("id" varchar(30) not null, "code" char(6) not null, "type" "verification_type" not null, "expired_at" timestamptz not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "verification_pkey" primary key ("id"));`,
);
this.addSql(
`create table "partner" ("id" varchar(30) not null, "name" varchar(100) not null, "email" varchar(254) not null, "whatsapp" varchar(20) not null, "password" text not null, "avatar" varchar(100) null, "verification_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "partner_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "partner" add constraint "partner_email_unique" unique ("email");`,
);
this.addSql(
`alter table "partner" add constraint "partner_whatsapp_unique" unique ("whatsapp");`,
);
this.addSql(
`create table "order" ("id" varchar(30) not null, "package_id" varchar(30) not null, "name" varchar(100) not null, "whatsapp" varchar(20) not null, "verification_id" varchar(30) null, "partner_id" varchar(30) null, "expired_at" timestamptz null, "purchased_at" timestamptz null, "finished_at" timestamptz null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "order_pkey" primary key ("id"));`,
);
this.addSql(
`create table "order_detail" ("id" varchar(30) not null, "order_id" varchar(30) not null, "room_type" "room_type" not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "order_detail_pkey" primary key ("id"));`,
);
this.addSql(
`create table "admin" ("id" varchar(30) not null, "name" varchar(100) not null, "email" varchar(254) not null, "password" text not null, "avatar" varchar(100) null, "permissions" "admin_permission"[] not null, "verification_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "admin_pkey" primary key ("id"));`,
);
this.addSql(
`alter table "admin" add constraint "admin_email_unique" unique ("email");`,
);
this.addSql(
`alter table "city" add constraint "city_country_id_foreign" foreign key ("country_id") references "country" ("id") on update cascade;`,
);
this.addSql(
`alter table "airport" add constraint "airport_city_id_foreign" foreign key ("city_id") references "city" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight" add constraint "flight_airline_id_foreign" foreign key ("airline_id") references "airline" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight" add constraint "flight_departure_airport_id_foreign" foreign key ("departure_airport_id") references "airport" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight" add constraint "flight_arrival_airport_id_foreign" foreign key ("arrival_airport_id") references "airport" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight_class" add constraint "flight_class_flight_id_foreign" foreign key ("flight_id") references "flight" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight_schedule" add constraint "flight_schedule_flight_id_foreign" foreign key ("flight_id") references "flight_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "hotel" add constraint "hotel_city_id_foreign" foreign key ("city_id") references "city" ("id") on update cascade;`,
);
this.addSql(
`alter table "hotel_facilities" add constraint "hotel_facilities_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "hotel_facilities" add constraint "hotel_facilities_hotel_facility_id_foreign" foreign key ("hotel_facility_id") references "hotel_facility" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_itinerary_image" add constraint "package_itinerary_image_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_package_itinerary_day_id_foreign" foreign key ("package_itinerary_day_id") references "package_itinerary_day" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "transportation_class" add constraint "transportation_class_transportation_id_foreign" foreign key ("transportation_id") references "transportation" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_package_id_foreign" foreign key ("package_id") references "package" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on delete cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete cascade;`,
);
this.addSql(
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
);
this.addSql(
`alter table "partner" add constraint "partner_verification_id_foreign" foreign key ("verification_id") references "verification" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "order" add constraint "order_package_id_foreign" foreign key ("package_id") references "package_detail" ("id") on update cascade;`,
);
this.addSql(
`alter table "order" add constraint "order_verification_id_foreign" foreign key ("verification_id") references "verification" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "order" add constraint "order_partner_id_foreign" foreign key ("partner_id") references "partner" ("id") on update cascade on delete set null;`,
);
this.addSql(
`alter table "order_detail" add constraint "order_detail_order_id_foreign" foreign key ("order_id") references "order" ("id") on update cascade;`,
);
this.addSql(
`alter table "admin" add constraint "admin_verification_id_foreign" foreign key ("verification_id") references "verification" ("id") on update cascade on delete set null;`,
);
}
override async down(): Promise<void> {
this.addSql(
`alter table "flight" drop constraint "flight_airline_id_foreign";`,
);
this.addSql(
`alter table "city" drop constraint "city_country_id_foreign";`,
);
this.addSql(
`alter table "airport" drop constraint "airport_city_id_foreign";`,
);
this.addSql(`alter table "hotel" drop constraint "hotel_city_id_foreign";`);
this.addSql(
`alter table "flight" drop constraint "flight_departure_airport_id_foreign";`,
);
this.addSql(
`alter table "flight" drop constraint "flight_arrival_airport_id_foreign";`,
);
this.addSql(
`alter table "flight_class" drop constraint "flight_class_flight_id_foreign";`,
);
this.addSql(
`alter table "flight_schedule" drop constraint "flight_schedule_flight_id_foreign";`,
);
this.addSql(
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
);
this.addSql(
`alter table "hotel_facilities" drop constraint "hotel_facilities_hotel_id_foreign";`,
);
this.addSql(
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_widget" drop constraint "package_itinerary_widget_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_hotel_id_foreign";`,
);
this.addSql(
`alter table "hotel_facilities" drop constraint "hotel_facilities_hotel_facility_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_package_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_widget" drop constraint "package_itinerary_widget_package_itinerary_day_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
);
this.addSql(
`alter table "package_itinerary_image" drop constraint "package_itinerary_image_package_itinerary_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
);
this.addSql(
`alter table "transportation_class" drop constraint "transportation_class_transportation_id_foreign";`,
);
this.addSql(
`alter table "package_detail" drop constraint "package_detail_transportation_id_foreign";`,
);
this.addSql(
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
);
this.addSql(
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_package_detail_id_foreign";`,
);
this.addSql(
`alter table "order" drop constraint "order_package_id_foreign";`,
);
this.addSql(
`alter table "partner" drop constraint "partner_verification_id_foreign";`,
);
this.addSql(
`alter table "order" drop constraint "order_verification_id_foreign";`,
);
this.addSql(
`alter table "admin" drop constraint "admin_verification_id_foreign";`,
);
this.addSql(
`alter table "order" drop constraint "order_partner_id_foreign";`,
);
this.addSql(
`alter table "order_detail" drop constraint "order_detail_order_id_foreign";`,
);
this.addSql(`drop table if exists "airline" cascade;`);
this.addSql(`drop table if exists "country" cascade;`);
this.addSql(`drop table if exists "city" cascade;`);
this.addSql(`drop table if exists "airport" cascade;`);
this.addSql(`drop table if exists "flight" cascade;`);
this.addSql(`drop table if exists "flight_class" cascade;`);
this.addSql(`drop table if exists "flight_schedule" cascade;`);
this.addSql(`drop table if exists "hotel" cascade;`);
this.addSql(`drop table if exists "hotel_facility" cascade;`);
this.addSql(`drop table if exists "hotel_facilities" cascade;`);
this.addSql(`drop table if exists "hotel_image" cascade;`);
this.addSql(`drop table if exists "package" cascade;`);
this.addSql(`drop table if exists "package_itinerary_day" cascade;`);
this.addSql(`drop table if exists "package_itinerary" cascade;`);
this.addSql(`drop table if exists "package_itinerary_image" cascade;`);
this.addSql(`drop table if exists "package_itinerary_widget" cascade;`);
this.addSql(`drop table if exists "transportation" cascade;`);
this.addSql(`drop table if exists "transportation_class" cascade;`);
this.addSql(`drop table if exists "package_detail" cascade;`);
this.addSql(`drop table if exists "package_detail_tour_hotels" cascade;`);
this.addSql(`drop table if exists "transportation_image" cascade;`);
this.addSql(`drop table if exists "verification" cascade;`);
this.addSql(`drop table if exists "partner" cascade;`);
this.addSql(`drop table if exists "order" cascade;`);
this.addSql(`drop table if exists "order_detail" cascade;`);
this.addSql(`drop table if exists "admin" cascade;`);
this.addSql(`drop type "skytrax_type";`);
this.addSql(`drop type "package_type";`);
this.addSql(`drop type "package_class";`);
this.addSql(`drop type "package_itinerary_widget_type";`);
this.addSql(`drop type "verification_type";`);
this.addSql(`drop type "room_type";`);
this.addSql(`drop type "admin_permission";`);
}
}