diff --git a/src/database/enums/room-type.enum.ts b/src/database/enums/room-type.enum.ts index ec72660..32258e2 100644 --- a/src/database/enums/room-type.enum.ts +++ b/src/database/enums/room-type.enum.ts @@ -1,6 +1,6 @@ export enum RoomType { - double = "double", - triple = "triple", quad = "quad", + triple = "triple", + double = "double", infant = "infant", } diff --git a/src/database/migrations/.snapshot-goumrah.json b/src/database/migrations/.snapshot-goumrah.json deleted file mode 100644 index f260953..0000000 --- a/src/database/migrations/.snapshot-goumrah.json +++ /dev/null @@ -1,3184 +0,0 @@ -{ - "namespaces": ["public"], - "name": "public", - "tables": [ - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "code": { - "name": "code", - "type": "varchar(10)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 10, - "mappedType": "string" - }, - "logo": { - "name": "logo", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "skytrax_rating": { - "name": "skytrax_rating", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "skytrax_type": { - "name": "skytrax_type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": ["full_service", "low_cost"], - "mappedType": "enum" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "airline", - "schema": "public", - "indexes": [ - { - "columnNames": ["code"], - "composite": false, - "keyName": "airline_code_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "airline_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "thumbnail": { - "name": "thumbnail", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "slug": { - "name": "slug", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "title": { - "name": "title", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "content": { - "name": "content", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "views": { - "name": "views", - "type": "int", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "article", - "schema": "public", - "indexes": [ - { - "columnNames": ["slug"], - "composite": false, - "keyName": "article_slug_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "article_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "country", - "schema": "public", - "indexes": [ - { - "keyName": "country_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "country_id": { - "name": "country_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "city", - "schema": "public", - "indexes": [ - { - "keyName": "city_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "city_country_id_foreign": { - "constraintName": "city_country_id_foreign", - "columnNames": ["country_id"], - "localTableName": "public.city", - "referencedColumnNames": ["id"], - "referencedTableName": "public.country", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "code": { - "name": "code", - "type": "varchar(10)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 10, - "mappedType": "string" - }, - "city_id": { - "name": "city_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "airport", - "schema": "public", - "indexes": [ - { - "columnNames": ["code"], - "composite": false, - "keyName": "airport_code_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "airport_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "airport_city_id_foreign": { - "constraintName": "airport_city_id_foreign", - "columnNames": ["city_id"], - "localTableName": "public.airport", - "referencedColumnNames": ["id"], - "referencedTableName": "public.city", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "airline_id": { - "name": "airline_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "number": { - "name": "number", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "departure_airport_id": { - "name": "departure_airport_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "departure_terminal": { - "name": "departure_terminal", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "departure_gate": { - "name": "departure_gate", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "departure_time": { - "name": "departure_time", - "type": "time(0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 0, - "mappedType": "time" - }, - "arrival_airport_id": { - "name": "arrival_airport_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "arrival_terminal": { - "name": "arrival_terminal", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "arrival_gate": { - "name": "arrival_gate", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "duration": { - "name": "duration", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "aircraft": { - "name": "aircraft", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "flight", - "schema": "public", - "indexes": [ - { - "keyName": "flight_airline_id_number_unique", - "columnNames": ["airline_id", "number"], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "flight_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "flight_airline_id_foreign": { - "constraintName": "flight_airline_id_foreign", - "columnNames": ["airline_id"], - "localTableName": "public.flight", - "referencedColumnNames": ["id"], - "referencedTableName": "public.airline", - "updateRule": "cascade" - }, - "flight_departure_airport_id_foreign": { - "constraintName": "flight_departure_airport_id_foreign", - "columnNames": ["departure_airport_id"], - "localTableName": "public.flight", - "referencedColumnNames": ["id"], - "referencedTableName": "public.airport", - "updateRule": "cascade" - }, - "flight_arrival_airport_id_foreign": { - "constraintName": "flight_arrival_airport_id_foreign", - "columnNames": ["arrival_airport_id"], - "localTableName": "public.flight", - "referencedColumnNames": ["id"], - "referencedTableName": "public.airport", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "flight_id": { - "name": "flight_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "class": { - "name": "class", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "seat_layout": { - "name": "seat_layout", - "type": "varchar(10)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 10, - "mappedType": "string" - }, - "baggage": { - "name": "baggage", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "cabin_baggage": { - "name": "cabin_baggage", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "flight_class", - "schema": "public", - "indexes": [ - { - "keyName": "flight_class_flight_id_class_unique", - "columnNames": ["flight_id", "class"], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "flight_class_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "flight_class_flight_id_foreign": { - "constraintName": "flight_class_flight_id_foreign", - "columnNames": ["flight_id"], - "localTableName": "public.flight_class", - "referencedColumnNames": ["id"], - "referencedTableName": "public.flight", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "flight_id": { - "name": "flight_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "next_id": { - "name": "next_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "flight_schedule", - "schema": "public", - "indexes": [ - { - "keyName": "flight_schedule_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "flight_schedule_flight_id_foreign": { - "constraintName": "flight_schedule_flight_id_foreign", - "columnNames": ["flight_id"], - "localTableName": "public.flight_schedule", - "referencedColumnNames": ["id"], - "referencedTableName": "public.flight_class", - "updateRule": "cascade" - }, - "flight_schedule_next_id_foreign": { - "constraintName": "flight_schedule_next_id_foreign", - "columnNames": ["next_id"], - "localTableName": "public.flight_schedule", - "referencedColumnNames": ["id"], - "referencedTableName": "public.flight_schedule", - "deleteRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "city_id": { - "name": "city_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "star": { - "name": "star", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "google_maps_link": { - "name": "google_maps_link", - "type": "varchar(1000)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 1000, - "mappedType": "string" - }, - "google_maps_embed": { - "name": "google_maps_embed", - "type": "varchar(1000)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 1000, - "mappedType": "string" - }, - "google_reviews_link": { - "name": "google_reviews_link", - "type": "varchar(1000)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 1000, - "mappedType": "string" - }, - "description": { - "name": "description", - "type": "varchar(1000)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 1000, - "mappedType": "string" - }, - "address": { - "name": "address", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "landmark": { - "name": "landmark", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "distance_to_landmark": { - "name": "distance_to_landmark", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "food_type": { - "name": "food_type", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "food_amount": { - "name": "food_amount", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "food_menu": { - "name": "food_menu", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "hotel", - "schema": "public", - "indexes": [ - { - "keyName": "hotel_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "hotel_city_id_foreign": { - "constraintName": "hotel_city_id_foreign", - "columnNames": ["city_id"], - "localTableName": "public.hotel", - "referencedColumnNames": ["id"], - "referencedTableName": "public.city", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "icon": { - "name": "icon", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "hotel_facility", - "schema": "public", - "indexes": [ - { - "keyName": "hotel_facility_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "hotel_id": { - "name": "hotel_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "hotel_facility_id": { - "name": "hotel_facility_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - } - }, - "name": "hotel_facilities", - "schema": "public", - "indexes": [ - { - "keyName": "hotel_facilities_pkey", - "columnNames": ["hotel_id", "hotel_facility_id"], - "composite": true, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "hotel_facilities_hotel_id_foreign": { - "constraintName": "hotel_facilities_hotel_id_foreign", - "columnNames": ["hotel_id"], - "localTableName": "public.hotel_facilities", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "hotel_facilities_hotel_facility_id_foreign": { - "constraintName": "hotel_facilities_hotel_facility_id_foreign", - "columnNames": ["hotel_facility_id"], - "localTableName": "public.hotel_facilities", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel_facility", - "deleteRule": "cascade", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "hotel_id": { - "name": "hotel_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "src": { - "name": "src", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "hotel_image", - "schema": "public", - "indexes": [ - { - "keyName": "hotel_image_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "hotel_image_hotel_id_foreign": { - "constraintName": "hotel_image_hotel_id_foreign", - "columnNames": ["hotel_id"], - "localTableName": "public.hotel_image", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "title": { - "name": "title", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "description": { - "name": "description", - "type": "varchar(1000)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 1000, - "mappedType": "string" - }, - "next_id": { - "name": "next_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "package_itinerary_day", - "schema": "public", - "indexes": [ - { - "keyName": "package_itinerary_day_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_itinerary_day_next_id_foreign": { - "constraintName": "package_itinerary_day_next_id_foreign", - "columnNames": ["next_id"], - "localTableName": "public.package_itinerary_day", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_itinerary_day", - "deleteRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "location": { - "name": "location", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "day_id": { - "name": "day_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "next_id": { - "name": "next_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "package_itinerary", - "schema": "public", - "indexes": [ - { - "keyName": "package_itinerary_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_itinerary_day_id_foreign": { - "constraintName": "package_itinerary_day_id_foreign", - "columnNames": ["day_id"], - "localTableName": "public.package_itinerary", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_itinerary_day", - "deleteRule": "cascade" - }, - "package_itinerary_next_id_foreign": { - "constraintName": "package_itinerary_next_id_foreign", - "columnNames": ["next_id"], - "localTableName": "public.package_itinerary", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_itinerary", - "deleteRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "package_itinerary_id": { - "name": "package_itinerary_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "src": { - "name": "src", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "package_itinerary_image", - "schema": "public", - "indexes": [ - { - "keyName": "package_itinerary_image_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_itinerary_image_package_itinerary_id_foreign": { - "constraintName": "package_itinerary_image_package_itinerary_id_foreign", - "columnNames": ["package_itinerary_id"], - "localTableName": "public.package_itinerary_image", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_itinerary", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "package_itinerary_day_id": { - "name": "package_itinerary_day_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": ["hotel", "information", "transport"], - "mappedType": "enum" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "hotel_id": { - "name": "hotel_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "description": { - "name": "description", - "type": "varchar(1000)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 1000, - "mappedType": "string" - }, - "transportation": { - "name": "transportation", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "from": { - "name": "from", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "to": { - "name": "to", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - } - }, - "name": "package_itinerary_widget", - "schema": "public", - "indexes": [ - { - "columnNames": ["type"], - "composite": false, - "keyName": "package_itinerary_widget_type_index", - "constraint": false, - "primary": false, - "unique": false - }, - { - "keyName": "package_itinerary_widget_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_itinerary_widget_package_itinerary_day_id_foreign": { - "constraintName": "package_itinerary_widget_package_itinerary_day_id_foreign", - "columnNames": ["package_itinerary_day_id"], - "localTableName": "public.package_itinerary_widget", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_itinerary_day", - "updateRule": "cascade" - }, - "package_itinerary_widget_hotel_id_foreign": { - "constraintName": "package_itinerary_widget_hotel_id_foreign", - "columnNames": ["hotel_id"], - "localTableName": "public.package_itinerary_widget", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "slug": { - "name": "slug", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "tag", - "schema": "public", - "indexes": [ - { - "columnNames": ["slug"], - "composite": false, - "keyName": "tag_slug_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "tag_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "article_id": { - "name": "article_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "tag_id": { - "name": "tag_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - } - }, - "name": "article_tags", - "schema": "public", - "indexes": [ - { - "keyName": "article_tags_pkey", - "columnNames": ["article_id", "tag_id"], - "composite": true, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "article_tags_article_id_foreign": { - "constraintName": "article_tags_article_id_foreign", - "columnNames": ["article_id"], - "localTableName": "public.article_tags", - "referencedColumnNames": ["id"], - "referencedTableName": "public.article", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "article_tags_tag_id_foreign": { - "constraintName": "article_tags_tag_id_foreign", - "columnNames": ["tag_id"], - "localTableName": "public.article_tags", - "referencedColumnNames": ["id"], - "referencedTableName": "public.tag", - "deleteRule": "cascade", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "type": { - "name": "type", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "transportation", - "schema": "public", - "indexes": [ - { - "keyName": "transportation_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "transportation_id": { - "name": "transportation_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "class": { - "name": "class", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "total_seats": { - "name": "total_seats", - "type": "int", - "unsigned": true, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "integer" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "transportation_class", - "schema": "public", - "indexes": [ - { - "keyName": "transportation_class_transportation_id_class_unique", - "columnNames": ["transportation_id", "class"], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "transportation_class_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "transportation_class_transportation_id_foreign": { - "constraintName": "transportation_class_transportation_id_foreign", - "columnNames": ["transportation_id"], - "localTableName": "public.transportation_class", - "referencedColumnNames": ["id"], - "referencedTableName": "public.transportation", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "transportation_id": { - "name": "transportation_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "src": { - "name": "src", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "transportation_image", - "schema": "public", - "indexes": [ - { - "keyName": "transportation_image_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "transportation_image_transportation_id_foreign": { - "constraintName": "transportation_image_transportation_id_foreign", - "columnNames": ["transportation_id"], - "localTableName": "public.transportation_image", - "referencedColumnNames": ["id"], - "referencedTableName": "public.transportation_class", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "code": { - "name": "code", - "type": "char(6)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "character" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "admin:create", - "admin:changeEmail", - "admin:changePassword", - "admin:update", - "partner:create", - "partner:changeEmail", - "partner:changePassword", - "partner:update", - "order:create" - ], - "mappedType": "enum" - }, - "expired_at": { - "name": "expired_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "verification", - "schema": "public", - "indexes": [ - { - "keyName": "verification_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": {}, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "email": { - "name": "email", - "type": "varchar(254)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 254, - "mappedType": "string" - }, - "whatsapp": { - "name": "whatsapp", - "type": "varchar(20)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 20, - "mappedType": "string" - }, - "password": { - "name": "password", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "avatar": { - "name": "avatar", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "verification_id": { - "name": "verification_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "partner", - "schema": "public", - "indexes": [ - { - "columnNames": ["email"], - "composite": false, - "keyName": "partner_email_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "columnNames": ["whatsapp"], - "composite": false, - "keyName": "partner_whatsapp_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "partner_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "partner_verification_id_foreign": { - "constraintName": "partner_verification_id_foreign", - "columnNames": ["verification_id"], - "localTableName": "public.partner", - "referencedColumnNames": ["id"], - "referencedTableName": "public.verification", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "slug": { - "name": "slug", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "type": { - "name": "type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": ["reguler", "plus"], - "mappedType": "enum" - }, - "class": { - "name": "class", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": ["silver", "gold", "platinum"], - "mappedType": "enum" - }, - "thumbnail": { - "name": "thumbnail", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "use_fast_train": { - "name": "use_fast_train", - "type": "boolean", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "boolean" - }, - "partner_id": { - "name": "partner_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "package", - "schema": "public", - "indexes": [ - { - "columnNames": ["slug"], - "composite": false, - "keyName": "package_slug_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "package_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_partner_id_foreign": { - "constraintName": "package_partner_id_foreign", - "columnNames": ["partner_id"], - "localTableName": "public.package", - "referencedColumnNames": ["id"], - "referencedTableName": "public.partner", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "package_id": { - "name": "package_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "departure_date": { - "name": "departure_date", - "type": "date", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 0, - "mappedType": "date" - }, - "tour_flight_id": { - "name": "tour_flight_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "outbound_flight_id": { - "name": "outbound_flight_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "inbound_flight_id": { - "name": "inbound_flight_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "makkah_hotel_id": { - "name": "makkah_hotel_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "madinah_hotel_id": { - "name": "madinah_hotel_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "transportation_id": { - "name": "transportation_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "quad_price": { - "name": "quad_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "triple_price": { - "name": "triple_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "double_price": { - "name": "double_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "infant_price": { - "name": "infant_price", - "type": "numeric(10,0)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "precision": 10, - "scale": 0, - "mappedType": "decimal" - }, - "itinerary_id": { - "name": "itinerary_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "package_detail", - "schema": "public", - "indexes": [ - { - "keyName": "package_detail_package_id_departure_date_unique", - "columnNames": ["package_id", "departure_date"], - "composite": true, - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "package_detail_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_detail_package_id_foreign": { - "constraintName": "package_detail_package_id_foreign", - "columnNames": ["package_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package", - "updateRule": "cascade" - }, - "package_detail_tour_flight_id_foreign": { - "constraintName": "package_detail_tour_flight_id_foreign", - "columnNames": ["tour_flight_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.flight_schedule", - "deleteRule": "cascade" - }, - "package_detail_outbound_flight_id_foreign": { - "constraintName": "package_detail_outbound_flight_id_foreign", - "columnNames": ["outbound_flight_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.flight_schedule", - "deleteRule": "cascade" - }, - "package_detail_inbound_flight_id_foreign": { - "constraintName": "package_detail_inbound_flight_id_foreign", - "columnNames": ["inbound_flight_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.flight_schedule", - "deleteRule": "cascade" - }, - "package_detail_makkah_hotel_id_foreign": { - "constraintName": "package_detail_makkah_hotel_id_foreign", - "columnNames": ["makkah_hotel_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel", - "deleteRule": "cascade" - }, - "package_detail_madinah_hotel_id_foreign": { - "constraintName": "package_detail_madinah_hotel_id_foreign", - "columnNames": ["madinah_hotel_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel", - "deleteRule": "cascade" - }, - "package_detail_transportation_id_foreign": { - "constraintName": "package_detail_transportation_id_foreign", - "columnNames": ["transportation_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.transportation_class", - "updateRule": "cascade" - }, - "package_detail_itinerary_id_foreign": { - "constraintName": "package_detail_itinerary_id_foreign", - "columnNames": ["itinerary_id"], - "localTableName": "public.package_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_itinerary", - "deleteRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "package_detail_id": { - "name": "package_detail_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "hotel_id": { - "name": "hotel_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - } - }, - "name": "package_detail_tour_hotels", - "schema": "public", - "indexes": [ - { - "keyName": "package_detail_tour_hotels_pkey", - "columnNames": ["package_detail_id", "hotel_id"], - "composite": true, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_detail_tour_hotels_package_detail_id_foreign": { - "constraintName": "package_detail_tour_hotels_package_detail_id_foreign", - "columnNames": ["package_detail_id"], - "localTableName": "public.package_detail_tour_hotels", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_detail", - "deleteRule": "cascade", - "updateRule": "cascade" - }, - "package_detail_tour_hotels_hotel_id_foreign": { - "constraintName": "package_detail_tour_hotels_hotel_id_foreign", - "columnNames": ["hotel_id"], - "localTableName": "public.package_detail_tour_hotels", - "referencedColumnNames": ["id"], - "referencedTableName": "public.hotel", - "deleteRule": "cascade", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "code": { - "name": "code", - "type": "varchar(6)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "string" - }, - "package_id": { - "name": "package_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "package_consult_session", - "schema": "public", - "indexes": [ - { - "columnNames": ["code"], - "composite": false, - "keyName": "package_consult_session_code_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "package_consult_session_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "package_consult_session_package_id_foreign": { - "constraintName": "package_consult_session_package_id_foreign", - "columnNames": ["package_id"], - "localTableName": "public.package_consult_session", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "package_id": { - "name": "package_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "whatsapp": { - "name": "whatsapp", - "type": "varchar(20)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 20, - "mappedType": "string" - }, - "verification_id": { - "name": "verification_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "partner_id": { - "name": "partner_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "expired_at": { - "name": "expired_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "purchased_at": { - "name": "purchased_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 6, - "mappedType": "datetime" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "order", - "schema": "public", - "indexes": [ - { - "keyName": "order_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_package_id_foreign": { - "constraintName": "order_package_id_foreign", - "columnNames": ["package_id"], - "localTableName": "public.order", - "referencedColumnNames": ["id"], - "referencedTableName": "public.package_detail", - "updateRule": "cascade" - }, - "order_verification_id_foreign": { - "constraintName": "order_verification_id_foreign", - "columnNames": ["verification_id"], - "localTableName": "public.order", - "referencedColumnNames": ["id"], - "referencedTableName": "public.verification", - "deleteRule": "set null", - "updateRule": "cascade" - }, - "order_partner_id_foreign": { - "constraintName": "order_partner_id_foreign", - "columnNames": ["partner_id"], - "localTableName": "public.order", - "referencedColumnNames": ["id"], - "referencedTableName": "public.partner", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "order_id": { - "name": "order_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "room_type": { - "name": "room_type", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": ["double", "triple", "quad", "infant"], - "mappedType": "enum" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "order_detail", - "schema": "public", - "indexes": [ - { - "keyName": "order_detail_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "order_detail_order_id_foreign": { - "constraintName": "order_detail_order_id_foreign", - "columnNames": ["order_id"], - "localTableName": "public.order_detail", - "referencedColumnNames": ["id"], - "referencedTableName": "public.order", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - }, - { - "columns": { - "id": { - "name": "id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 30, - "mappedType": "string" - }, - "name": { - "name": "name", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 100, - "mappedType": "string" - }, - "email": { - "name": "email", - "type": "varchar(254)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 254, - "mappedType": "string" - }, - "password": { - "name": "password", - "type": "text", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "mappedType": "text" - }, - "avatar": { - "name": "avatar", - "type": "varchar(100)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 100, - "mappedType": "string" - }, - "permissions": { - "name": "permissions", - "type": "text[]", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "enumItems": [ - "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", - "tag:create", - "tag:update", - "tag:delete", - "article:create", - "article:update", - "article:delete" - ], - "mappedType": "array" - }, - "verification_id": { - "name": "verification_id", - "type": "varchar(30)", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": true, - "length": 30, - "mappedType": "string" - }, - "created_at": { - "name": "created_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamptz", - "unsigned": false, - "autoincrement": false, - "primary": false, - "nullable": false, - "length": 6, - "mappedType": "datetime" - } - }, - "name": "admin", - "schema": "public", - "indexes": [ - { - "columnNames": ["email"], - "composite": false, - "keyName": "admin_email_unique", - "constraint": true, - "primary": false, - "unique": true - }, - { - "keyName": "admin_pkey", - "columnNames": ["id"], - "composite": false, - "constraint": true, - "primary": true, - "unique": true - } - ], - "checks": [], - "foreignKeys": { - "admin_verification_id_foreign": { - "constraintName": "admin_verification_id_foreign", - "columnNames": ["verification_id"], - "localTableName": "public.admin", - "referencedColumnNames": ["id"], - "referencedTableName": "public.verification", - "deleteRule": "set null", - "updateRule": "cascade" - } - }, - "nativeEnums": {} - } - ], - "nativeEnums": {} -} diff --git a/src/database/migrations/Migration20251201133512.ts b/src/database/migrations/Migration20251201133512.ts index 14aa832..c779062 100644 --- a/src/database/migrations/Migration20251201133512.ts +++ b/src/database/migrations/Migration20251201133512.ts @@ -2,529 +2,836 @@ import { Migration } from "@mikro-orm/migrations"; export class Migration20251201133512 extends Migration { override async up(): Promise { - 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" 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");`, - ); + const knex = this.getKnex(); - this.addSql( - `create table "article" ("id" varchar(30) not null, "thumbnail" varchar(100) not null, "slug" varchar(100) not null, "title" varchar(100) not null, "content" text not null, "views" int not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "article_pkey" primary key ("id"));`, - ); - this.addSql( - `alter table "article" add constraint "article_slug_unique" unique ("slug");`, - ); + // Enums + await knex.raw(` + create type "skytrax_type" as enum ( + 'full_service', + 'low_cost' + ); + `); - 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"));`, - ); + await knex.raw(` + create type "package_itinerary_widget_type" as enum ( + 'hotel', + 'information', + 'transport' + ); + `); - 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"));`, - ); + await knex.raw(` + 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 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");`, - ); + await knex.raw(` + create type "package_type" as enum ( + 'reguler', + 'plus' + ); + `); - 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");`, - ); + await knex.raw(` + create type "package_class" as enum ( + 'silver', + 'gold', + 'platinum' + ); + `); - 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");`, - ); + await knex.raw(` + create type "room_type" as enum ( + 'quad', + 'triple', + 'double', + 'infant' + ); + `); - 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"));`, - ); + await knex.raw(` + 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', + 'tag:create', + 'tag:update', + 'tag:delete', + 'article:create', + 'article:update', + 'article:delete' + ); + `); - 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"));`, - ); + // Tables + await knex.schema.createTable("airline", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("code", 10).notNullable(); + table.string("logo", 100).notNullable(); + table.integer("skytrax_rating").notNullable(); + table + .enum("skytrax_type", null, { + useNative: true, + existingType: true, + enumName: "skytrax_type", + }) + .notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "airline_pkey" }); + table.unique(["code"], { indexName: "airline_code_unique" }); + }); - 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"));`, - ); + await knex.schema.createTable("article", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("thumbnail", 100).notNullable(); + table.string("slug", 100).notNullable(); + table.string("title", 100).notNullable(); + table.text("content").notNullable(); + table.integer("views").notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "article_pkey" }); + table.unique(["slug"], { indexName: "article_slug_unique" }); + }); - 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"));`, - ); + await knex.schema.createTable("country", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "country_pkey" }); + }); - 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"));`, - ); + await knex.schema.createTable("city", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("country_id", 30).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "city_pkey" }); + table + .foreign("country_id", "city_country_id_foreign") + .references("country.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - 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"));`, - ); + await knex.schema.createTable("airport", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("code", 10).notNullable(); + table.string("city_id", 30).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "airport_pkey" }); + table.unique(["code"], { indexName: "airport_code_unique" }); + table + .foreign("city_id", "airport_city_id_foreign") + .references("city.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - 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"));`, - ); + await knex.schema.createTable("flight", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("airline_id", 30).notNullable(); + table.integer("number").notNullable(); + table.string("departure_airport_id", 30).notNullable(); + table.string("departure_terminal", 100).nullable(); + table.string("departure_gate", 100).nullable(); + table.time("departure_time").notNullable(); + table.string("arrival_airport_id", 30).notNullable(); + table.string("arrival_terminal", 100).nullable(); + table.string("arrival_gate", 100).nullable(); + table.integer("duration").notNullable(); + table.string("aircraft", 100).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "flight_pkey" }); + table.unique(["airline_id", "number"], { + indexName: "flight_airline_id_number_unique", + }); + table + .foreign("airline_id", "flight_airline_id_foreign") + .references("airline.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("departure_airport_id", "flight_departure_airport_id_foreign") + .references("airport.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("arrival_airport_id", "flight_arrival_airport_id_foreign") + .references("airport.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - 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"));`, - ); + await knex.schema.createTable("flight_class", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("flight_id", 30).notNullable(); + table.string("class", 100).notNullable(); + table.string("seat_layout", 10).notNullable(); + table.integer("baggage").notNullable(); + table.integer("cabin_baggage").notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "flight_class_pkey" }); + table.unique(["flight_id", "class"], { + indexName: "flight_class_flight_id_class_unique", + }); + }); - 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 ('hotel', 'information', 'transport')) 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");`, - ); + await knex.schema.createTable("flight_schedule", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("flight_id", 30).notNullable(); + table.string("next_id", 30).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "flight_schedule_pkey" }); + table + .foreign("flight_id", "flight_schedule_flight_id_foreign") + .references("flight_class.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("next_id", "flight_schedule_next_id_foreign") + .references("flight_schedule.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + }); - this.addSql( - `create table "tag" ("id" varchar(30) not null, "slug" varchar(100) not null, "name" varchar(100) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "tag_pkey" primary key ("id"));`, - ); - this.addSql( - `alter table "tag" add constraint "tag_slug_unique" unique ("slug");`, - ); + await knex.schema.createTable("hotel", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("city_id", 30).notNullable(); + table.integer("star").notNullable(); + table.string("google_maps_link", 1000).notNullable(); + table.string("google_maps_embed", 1000).notNullable(); + table.string("google_reviews_link", 1000).notNullable(); + table.string("description", 1000).notNullable(); + table.string("address", 100).notNullable(); + table.string("landmark", 100).notNullable(); + table.integer("distance_to_landmark").notNullable(); + table.string("food_type", 100).notNullable(); + table.integer("food_amount").notNullable(); + table.string("food_menu", 100).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "hotel_pkey" }); + table + .foreign("city_id", "hotel_city_id_foreign") + .references("city.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - this.addSql( - `create table "article_tags" ("article_id" varchar(30) not null, "tag_id" varchar(30) not null, constraint "article_tags_pkey" primary key ("article_id", "tag_id"));`, - ); + await knex.schema.createTable("hotel_facility", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("icon", 100).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "hotel_facility_pkey" }); + }); - 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"));`, - ); + await knex.schema.createTable("hotel_facilities", (table) => { + // Columns + table.string("hotel_id", 30).notNullable(); + table.string("hotel_facility_id", 30).notNullable(); + // Constraints + table.primary(["hotel_id", "hotel_facility_id"], { + constraintName: "hotel_facilities_pkey", + }); + table + .foreign("hotel_id", "hotel_facilities_hotel_id_foreign") + .references("hotel.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign( + "hotel_facility_id", + "hotel_facilities_hotel_facility_id_foreign", + ) + .references("hotel_facility.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - 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");`, - ); + await knex.schema.createTable("hotel_image", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("hotel_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: "hotel_image_pkey" }); + table + .foreign("hotel_id", "hotel_image_hotel_id_foreign") + .references("hotel.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - 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"));`, - ); + await knex.schema.createTable("package_itinerary_day", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("title", 100).notNullable(); + table.string("description", 1000).notNullable(); + table.string("next_id", 30).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "package_itinerary_day_pkey" }); + table + .foreign("next_id", "package_itinerary_day_next_id_foreign") + .references("package_itinerary_day.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + }); - this.addSql( - `create table "verification" ("id" varchar(30) not null, "code" char(6) not null, "type" text check ("type" in ('admin:create', 'admin:changeEmail', 'admin:changePassword', 'admin:update', 'partner:create', 'partner:changeEmail', 'partner:changePassword', 'partner:update', 'order:create')) not null, "expired_at" timestamptz not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "verification_pkey" primary key ("id"));`, - ); + await knex.schema.createTable("package_itinerary", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("location", 100).notNullable(); + table.string("day_id", 30).nullable(); + table.string("next_id", 30).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "package_itinerary_pkey" }); + table + .foreign("day_id", "package_itinerary_day_id_foreign") + .references("package_itinerary_day.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + table + .foreign("next_id", "package_itinerary_next_id_foreign") + .references("package_itinerary.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + }); - 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");`, - ); + await knex.schema.createTable("package_itinerary_image", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("package_itinerary_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: "package_itinerary_image_pkey" }); + table + .foreign( + "package_itinerary_id", + "package_itinerary_image_package_itinerary_id_foreign", + ) + .references("package_itinerary.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - this.addSql( - `create table "package" ("id" varchar(30) not null, "slug" varchar(100) 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, "partner_id" varchar(30) 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");`, - ); + await knex.schema.createTable("package_itinerary_widget", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("package_itinerary_day_id", 30).notNullable(); + table + .enum("type", null, { + useNative: true, + existingType: true, + enumName: "package_itinerary_widget_type", + }) + .notNullable(); + table.string("hotel_id", 30).nullable(); + table.string("description", 1000).nullable(); + table.string("transportation", 100).nullable(); + table.string("from", 100).nullable(); + table.string("to", 100).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { + constraintName: "package_itinerary_widget_pkey", + }); + table.index(["type"], "package_itinerary_widget_type_index"); + table + .foreign( + "package_itinerary_day_id", + "package_itinerary_widget_package_itinerary_day_id_foreign", + ) + .references("package_itinerary_day.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + table + .foreign("hotel_id", "package_itinerary_widget_hotel_id_foreign") + .references("hotel.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - 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");`, - ); + await knex.schema.createTable("tag", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("slug", 100).notNullable(); + table.string("name", 100).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "tag_pkey" }); + table.unique(["slug"], { indexName: "tag_slug_unique" }); + }); - 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"));`, - ); + await knex.schema.createTable("article_tags", (table) => { + // Columns + table.string("article_id", 30).notNullable(); + table.string("tag_id", 30).notNullable(); + // Constraints + table.primary(["article_id", "tag_id"], { + constraintName: "article_tags_pkey", + }); + table + .foreign("article_id", "article_tags_article_id_foreign") + .references("article.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("tag_id", "article_tags_tag_id_foreign") + .references("tag.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - this.addSql( - `create table "package_consult_session" ("id" varchar(30) not null, "code" varchar(6) not null, "package_id" varchar(30) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_consult_session_pkey" primary key ("id"));`, - ); - this.addSql( - `alter table "package_consult_session" add constraint "package_consult_session_code_unique" unique ("code");`, - ); + await knex.schema.createTable("transportation", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("type", 100).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "transportation_pkey" }); + }); - 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"));`, - ); + await knex.schema.createTable("transportation_class", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("transportation_id", 30).notNullable(); + table.string("class", 100).notNullable(); + table.integer("total_seats").notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "transportation_class_pkey" }); + table.unique(["transportation_id", "class"], { + indexName: "transportation_class_transportation_id_class_unique", + }); + table + .foreign( + "transportation_id", + "transportation_class_transportation_id_foreign", + ) + .references("transportation.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - this.addSql( - `create table "order_detail" ("id" varchar(30) not null, "order_id" varchar(30) not null, "room_type" text check ("room_type" in ('double', 'triple', 'quad', 'infant')) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "order_detail_pkey" primary key ("id"));`, - ); + 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"); + }); - 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" text[] 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");`, - ); + await knex.schema.createTable("verification", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("code", 6).notNullable(); + table + .enum("type", null, { + useNative: true, + existingType: true, + enumName: "verification_type", + }) + .notNullable(); + table.timestamp("expired_at", { useTz: true }).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "verification_pkey" }); + }); - this.addSql( - `alter table "city" add constraint "city_country_id_foreign" foreign key ("country_id") references "country" ("id") on update cascade;`, - ); + await knex.schema.createTable("partner", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("email", 254).notNullable(); + table.string("whatsapp", 20).notNullable(); + table.text("password").notNullable(); + table.string("avatar", 100).nullable(); + table.string("verification_id", 30).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "partner_pkey" }); + table.unique(["email"], { indexName: "partner_email_unique" }); + table.unique(["whatsapp"], { indexName: "partner_whatsapp_unique" }); + table + .foreign("verification_id", "partner_verification_id_foreign") + .references("verification.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + }); - this.addSql( - `alter table "airport" add constraint "airport_city_id_foreign" foreign key ("city_id") references "city" ("id") on update cascade;`, - ); + await knex.schema.createTable("package", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("slug", 100).notNullable(); + table.string("name", 100).notNullable(); + table + .enum("type", null, { + useNative: true, + existingType: true, + enumName: "package_type", + }) + .notNullable(); + table + .enum("class", null, { + useNative: true, + existingType: true, + enumName: "package_class", + }) + .notNullable(); + table.string("thumbnail", 100).notNullable(); + table.boolean("use_fast_train").notNullable(); + table.string("partner_id", 30).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "package_pkey" }); + table.unique(["slug"], { indexName: "package_slug_unique" }); + table + .foreign("partner_id", "package_partner_id_foreign") + .references("partner.id") + .onUpdate("NO ACTION") + .onDelete("RESTRICT"); + }); - 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;`, - ); + await knex.schema.createTable("package_detail", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("package_id", 30).notNullable(); + table.date("departure_date").notNullable(); + table.string("tour_flight_id", 30).nullable(); + table.string("outbound_flight_id", 30).notNullable(); + table.string("inbound_flight_id", 30).notNullable(); + table.string("makkah_hotel_id", 30).notNullable(); + table.string("madinah_hotel_id", 30).notNullable(); + table.string("transportation_id", 30).notNullable(); + table.decimal("quad_price", 10, 0).notNullable(); + table.decimal("triple_price", 10, 0).notNullable(); + table.decimal("double_price", 10, 0).notNullable(); + table.decimal("infant_price", 10, 0).nullable(); + table.string("itinerary_id", 30).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "package_detail_pkey" }); + table.unique(["package_id", "departure_date"], { + indexName: "package_detail_package_id_departure_date_unique", + }); + table + .foreign("package_id", "package_detail_package_id_foreign") + .references("package.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("tour_flight_id", "package_detail_tour_flight_id_foreign") + .references("flight_schedule.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign( + "outbound_flight_id", + "package_detail_outbound_flight_id_foreign", + ) + .references("flight_schedule.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign( + "inbound_flight_id", + "package_detail_inbound_flight_id_foreign", + ) + .references("flight_schedule.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("makkah_hotel_id", "package_detail_makkah_hotel_id_foreign") + .references("hotel.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("madinah_hotel_id", "package_detail_madinah_hotel_id_foreign") + .references("hotel.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign( + "transportation_id", + "package_detail_transportation_id_foreign", + ) + .references("transportation.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("itinerary_id", "package_detail_itinerary_id_foreign") + .references("package_itinerary.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - this.addSql( - `alter table "flight_class" add constraint "flight_class_flight_id_foreign" foreign key ("flight_id") references "flight" ("id") on update cascade;`, - ); + await knex.schema.createTable("package_detail_tour_hotels", (table) => { + // Columns + table.string("package_detail_id", 30).notNullable(); + table.string("hotel_id", 30).notNullable(); + // Constraints + table.primary(["package_detail_id", "hotel_id"], { + constraintName: "package_detail_tour_hotels_pkey", + }); + table + .foreign( + "package_detail_id", + "package_detail_tour_hotels_package_detail_id_foreign", + ) + .references("package_detail.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("hotel_id", "package_detail_tour_hotels_hotel_id_foreign") + .references("hotel.id") + .onUpdate("NO ACTION") + .onDelete("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;`, - ); + await knex.schema.createTable("package_consult_session", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("code", 6).notNullable(); + table.string("package_id", 30).notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "package_consult_session_pkey" }); + table.unique(["code"], { + indexName: "package_consult_session_code_unique", + }); + table + .foreign("package_id", "package_consult_session_package_id_foreign") + .references("package.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + }); - this.addSql( - `alter table "hotel" add constraint "hotel_city_id_foreign" foreign key ("city_id") references "city" ("id") on update cascade;`, - ); + await knex.schema.createTable("order", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("package_id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("whatsapp", 20).notNullable(); + table.string("verification_id", 30).nullable(); + table.string("partner_id", 30).nullable(); + table.timestamp("expired_at", { useTz: true }).nullable(); + table.timestamp("purchased_at", { useTz: true }).nullable(); + table.timestamp("finished_at", { useTz: true }).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "order_pkey" }); + table + .foreign("package_id", "order_package_id_foreign") + .references("package.id") + .onUpdate("NO ACTION") + .onDelete("CASCADE"); + table + .foreign("verification_id", "order_verification_id_foreign") + .references("verification.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + table + .foreign("partner_id", "order_partner_id_foreign") + .references("partner.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + }); - 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;`, - ); + await knex.schema.createTable("order_detail", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("order_id", 30).notNullable(); + table + .enum("room_type", null, { + useNative: true, + existingType: true, + enumName: "room_type", + }) + .notNullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "order_detail_pkey" }); + table + .foreign("order_id", "order_detail_order_id_foreign") + .references("order.id") + .onUpdate("NO ACTION") + .onDelete("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 "article_tags" add constraint "article_tags_article_id_foreign" foreign key ("article_id") references "article" ("id") on update cascade on delete cascade;`, - ); - this.addSql( - `alter table "article_tags" add constraint "article_tags_tag_id_foreign" foreign key ("tag_id") references "tag" ("id") on update cascade on delete 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 "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 "package" add constraint "package_partner_id_foreign" foreign key ("partner_id") references "partner" ("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 "package_consult_session" add constraint "package_consult_session_package_id_foreign" foreign key ("package_id") references "package" ("id") on update cascade;`, - ); - - 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;`, - ); + await knex.schema.createTable("admin", (table) => { + // Columns + table.string("id", 30).notNullable(); + table.string("name", 100).notNullable(); + table.string("email", 254).notNullable(); + table.text("password").notNullable(); + table.string("avatar", 100).nullable(); + table.specificType("permissions", "admin_permission[]").notNullable(); + table.string("verification_id", 30).nullable(); + table.timestamp("created_at", { useTz: true }).notNullable(); + table.timestamp("updated_at", { useTz: true }).notNullable(); + // Constraints + table.primary(["id"], { constraintName: "admin_pkey" }); + table.unique(["email"], { indexName: "admin_email_unique" }); + table + .foreign("verification_id", "admin_verification_id_foreign") + .references("verification.id") + .onUpdate("NO ACTION") + .onDelete("SET NULL"); + }); } override async down(): Promise { - this.addSql( - `alter table "flight" drop constraint "flight_airline_id_foreign";`, - ); - - this.addSql( - `alter table "article_tags" drop constraint "article_tags_article_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_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 "article_tags" drop constraint "article_tags_tag_id_foreign";`, - ); - - this.addSql( - `alter table "transportation_class" drop constraint "transportation_class_transportation_id_foreign";`, - ); - - this.addSql( - `alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`, - ); - - this.addSql( - `alter table "package_detail" drop constraint "package_detail_transportation_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 "package" drop constraint "package_partner_id_foreign";`, - ); - - this.addSql( - `alter table "order" drop constraint "order_partner_id_foreign";`, - ); - - this.addSql( - `alter table "package_detail" drop constraint "package_detail_package_id_foreign";`, - ); - - this.addSql( - `alter table "package_consult_session" drop constraint "package_consult_session_package_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 "order_detail" drop constraint "order_detail_order_id_foreign";`, - ); - - this.addSql(`drop table if exists "airline" cascade;`); - - this.addSql(`drop table if exists "article" 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_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 "tag" cascade;`); - - this.addSql(`drop table if exists "article_tags" cascade;`); - - this.addSql(`drop table if exists "transportation" cascade;`); - - this.addSql(`drop table if exists "transportation_class" 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 "package" 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_consult_session" 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;`); + const knex = this.getKnex(); + + await knex.schema.dropTable("admin"); + await knex.schema.dropTable("order_detail"); + await knex.schema.dropTable("order"); + await knex.schema.dropTable("package_consult_session"); + await knex.schema.dropTable("package_detail_tour_hotels"); + await knex.schema.dropTable("package_detail"); + await knex.schema.dropTable("package"); + await knex.schema.dropTable("partner"); + await knex.schema.dropTable("verification"); + await knex.schema.dropTable("transportation_image"); + await knex.schema.dropTable("transportation_class"); + await knex.schema.dropTable("transportation"); + await knex.schema.dropTable("article_tags"); + await knex.schema.dropTable("tag"); + await knex.schema.dropTable("package_itinerary_widget"); + await knex.schema.dropTable("package_itinerary_image"); + await knex.schema.dropTable("package_itinerary"); + await knex.schema.dropTable("package_itinerary_day"); + await knex.schema.dropTable("hotel_image"); + await knex.schema.dropTable("hotel_facilities"); + await knex.schema.dropTable("hotel_facility"); + await knex.schema.dropTable("hotel"); + await knex.schema.dropTable("flight_schedule"); + await knex.schema.dropTable("flight_class"); + await knex.schema.dropTable("flight"); + await knex.schema.dropTable("airport"); + await knex.schema.dropTable("city"); + await knex.schema.dropTable("country"); + await knex.schema.dropTable("article"); + await knex.schema.dropTable("airline"); + + await knex.raw(`drop type "admin_permission";`); + await knex.raw(`drop type "room_type";`); + await knex.raw(`drop type "package_class";`); + await knex.raw(`drop type "package_type";`); + await knex.raw(`drop type "verification_type";`); + await knex.raw(`drop type "package_itinerary_widget_type";`); + await knex.raw(`drop type "skytrax_type";`); } }