add core api
This commit is contained in:
@@ -1,24 +1,11 @@
|
||||
import { Flight } from "@/database/entities/flight.entity";
|
||||
import { SkytraxType } from "@/database/enums/skytrax-type.enum";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
Enum,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
} from "@mikro-orm/core";
|
||||
import { Entity, Enum, PrimaryKey, Property, Unique } from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class Airline {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -30,7 +17,7 @@ export class Airline {
|
||||
@Unique()
|
||||
logo!: string;
|
||||
|
||||
@Property({ type: "int", nullable: true })
|
||||
@Property({ type: "int", unsigned: true })
|
||||
skytraxRating!: number;
|
||||
|
||||
@Enum(() => SkytraxType)
|
||||
@@ -48,9 +35,4 @@ export class Airline {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => Flight, (flight) => flight.airline)
|
||||
flights = new Collection<Flight>(this);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { City } from "@/database/entities/city.entity";
|
||||
import { Flight } from "@/database/entities/flight.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
@@ -16,10 +13,6 @@ export class Airport {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -42,12 +35,4 @@ export class Airport {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => Flight, (flight) => flight.departureAirport)
|
||||
departureFlights = new Collection<Flight>(this);
|
||||
|
||||
@OneToMany(() => Flight, (flight) => flight.arrivalAirport)
|
||||
arrivalFlights = new Collection<Flight>(this);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import { Airport } from "@/database/entities/airport.entity";
|
||||
import { Country } from "@/database/entities/country.entity";
|
||||
import { Hotel } from "@/database/entities/hotel.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@@ -17,10 +12,6 @@ export class City {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -39,12 +30,4 @@ export class City {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => Airport, (airport) => airport.city)
|
||||
cities = new Collection<City>(this);
|
||||
|
||||
@OneToMany(() => Hotel, (hotel) => hotel.city)
|
||||
hotels = new Collection<Hotel>(this);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
import { City } from "@/database/entities/city.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
} from "@mikro-orm/core";
|
||||
import { Entity, PrimaryKey, Property } from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class Country {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -32,9 +20,4 @@ export class Country {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => City, (city) => city.country)
|
||||
cities = new Collection<City>(this);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Flight } from "@/database/entities/flight.entity";
|
||||
import { PackageDetail } from "@/database/entities/package-detail.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
@@ -17,10 +14,6 @@ export class FlightClass {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@ManyToOne(() => Flight)
|
||||
flight!: Rel<Flight>;
|
||||
|
||||
@@ -48,24 +41,4 @@ export class FlightClass {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@ManyToMany(
|
||||
() => PackageDetail,
|
||||
(packageDetail) => packageDetail.tourFlightClasses,
|
||||
)
|
||||
tourPackageDetails = new Collection<PackageDetail>(this);
|
||||
|
||||
@ManyToMany(
|
||||
() => PackageDetail,
|
||||
(packageDetail) => packageDetail.outboundFlightClasses,
|
||||
)
|
||||
outboundPackageDetails = new Collection<PackageDetail>(this);
|
||||
|
||||
@ManyToMany(
|
||||
() => PackageDetail,
|
||||
(packageDetail) => packageDetail.inboundFlightClasses,
|
||||
)
|
||||
inboundPackageDetails = new Collection<PackageDetail>(this);
|
||||
}
|
||||
|
||||
37
src/database/entities/flight-schedule.entity.ts
Normal file
37
src/database/entities/flight-schedule.entity.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { FlightClass } from "@/database/entities/flight-class.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class FlightSchedule {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => FlightClass)
|
||||
flight!: Rel<FlightClass>;
|
||||
|
||||
@ManyToOne(() => FlightSchedule, {
|
||||
nullable: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
next!: Rel<FlightSchedule> | null;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { Airline } from "@/database/entities/airline.entity";
|
||||
import { Airport } from "@/database/entities/airport.entity";
|
||||
import { FlightClass } from "@/database/entities/flight-class.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
@@ -18,10 +19,6 @@ export class Flight {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 220 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@ManyToOne(() => Airline)
|
||||
airline!: Rel<Airline>;
|
||||
|
||||
@@ -32,10 +29,10 @@ export class Flight {
|
||||
departureAirport!: Rel<Airport>;
|
||||
|
||||
@Property({ type: "varchar", length: 100, nullable: true })
|
||||
departureTerminal?: string;
|
||||
departureTerminal!: string | null;
|
||||
|
||||
@Property({ type: "varchar", length: 100, nullable: true })
|
||||
departureGate?: string;
|
||||
departureGate!: string | null;
|
||||
|
||||
@Property({ type: "time" })
|
||||
departureTime!: string;
|
||||
@@ -44,10 +41,10 @@ export class Flight {
|
||||
arrivalAirport!: Rel<Airport>;
|
||||
|
||||
@Property({ type: "varchar", length: 100, nullable: true })
|
||||
arrivalTerminal?: string;
|
||||
arrivalTerminal!: string | null;
|
||||
|
||||
@Property({ type: "varchar", length: 100, nullable: true })
|
||||
arrivalGate?: string;
|
||||
arrivalGate!: string | null;
|
||||
|
||||
@Property({ type: "integer", unsigned: true })
|
||||
duration!: number;
|
||||
@@ -70,6 +67,9 @@ export class Flight {
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => FlightClass, (flightClass) => flightClass.flight)
|
||||
@OneToMany(() => FlightClass, (flightClass) => flightClass.flight, {
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
classes = new Collection<FlightClass>(this);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
import { Hotel } from "@/database/entities/hotel.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
} from "@mikro-orm/core";
|
||||
import { Entity, PrimaryKey, Property } from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class HotelFacility {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -35,9 +23,4 @@ export class HotelFacility {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@ManyToMany(() => Hotel, (hotel) => hotel.facilities)
|
||||
hotels = new Collection<HotelFacility>(this);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { Hotel } from "@/database/entities/hotel.entity";
|
||||
import { PackageDetail } from "@/database/entities/package-detail.entity";
|
||||
import {
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
@@ -36,9 +33,4 @@ export class HotelSchedule {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Inverse side
|
||||
|
||||
@ManyToMany(() => PackageDetail, (packageDetail) => packageDetail.tourHotels)
|
||||
tourPackageDetails = new Collection<PackageDetail>(this);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { City } from "@/database/entities/city.entity";
|
||||
import { HotelFacility } from "@/database/entities/hotel-facility.entity";
|
||||
import { HotelImage } from "@/database/entities/hotel-image.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
@@ -9,7 +10,6 @@ import {
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@@ -18,10 +18,6 @@ export class Hotel {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -31,18 +27,27 @@ export class Hotel {
|
||||
@Property({ type: "integer", unsigned: true })
|
||||
star!: number;
|
||||
|
||||
@Property({ type: "varchar", length: 500 })
|
||||
@OneToMany(() => HotelImage, (hotelImage) => hotelImage.hotel, {
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
images = new Collection<HotelImage>(this);
|
||||
|
||||
@Property({ type: "varchar", length: 1000 })
|
||||
googleMapsLink!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 500 })
|
||||
@Property({ type: "varchar", length: 1000 })
|
||||
googleMapsEmbed!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 500 })
|
||||
@Property({ type: "varchar", length: 1000 })
|
||||
googleReviewsLink!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 1000 })
|
||||
description!: string;
|
||||
|
||||
@ManyToMany(() => HotelFacility)
|
||||
facilities = new Collection<HotelFacility>(this);
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
address!: string;
|
||||
|
||||
@@ -50,13 +55,13 @@ export class Hotel {
|
||||
landmark!: string;
|
||||
|
||||
@Property({ type: "decimal" })
|
||||
distanceToLandmark!: string;
|
||||
distanceToLandmark!: number;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
foodType!: string;
|
||||
|
||||
@Property({ type: "integer", unsigned: true })
|
||||
foodAmount!: string;
|
||||
foodAmount!: number;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
foodMenu!: string;
|
||||
@@ -73,14 +78,4 @@ export class Hotel {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => HotelImage, (hotelImage) => hotelImage.hotel)
|
||||
images = new Collection<HotelImage>(this);
|
||||
|
||||
@ManyToMany(() => HotelFacility, (hotelFacility) => hotelFacility.hotels, {
|
||||
owner: true,
|
||||
})
|
||||
facilities = new Collection<HotelFacility>(this);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { FlightClass } from "@/database/entities/flight-class.entity";
|
||||
import { FlightSchedule } from "@/database/entities/flight-schedule.entity";
|
||||
import { HotelSchedule } from "@/database/entities/hotel-schedule.entity";
|
||||
import { PackageItinerary } from "@/database/entities/package-itinerary.entity";
|
||||
import { Package } from "@/database/entities/package.entity";
|
||||
import { TransportationClass } from "@/database/entities/transportation-class.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
@@ -19,60 +21,42 @@ export class PackageDetail {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@ManyToOne(() => Package)
|
||||
package!: Rel<Package>;
|
||||
|
||||
@Property({ type: "date" })
|
||||
departureDate!: Date;
|
||||
|
||||
@ManyToMany(
|
||||
() => FlightClass,
|
||||
(flightClass) => flightClass.tourPackageDetails,
|
||||
{
|
||||
owner: true,
|
||||
fixedOrder: true,
|
||||
},
|
||||
)
|
||||
tourFlightClasses = new Collection<FlightClass>(this);
|
||||
@ManyToOne(() => FlightSchedule, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
nullable: true,
|
||||
})
|
||||
tourFlight!: Rel<FlightSchedule> | null;
|
||||
|
||||
@ManyToMany(
|
||||
() => FlightClass,
|
||||
(flightClass) => flightClass.outboundPackageDetails,
|
||||
{
|
||||
owner: true,
|
||||
fixedOrder: true,
|
||||
},
|
||||
)
|
||||
outboundFlightClasses = new Collection<FlightClass>(this);
|
||||
@ManyToOne(() => FlightSchedule, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
outboundFlight!: Rel<FlightSchedule>;
|
||||
|
||||
@ManyToMany(
|
||||
() => FlightClass,
|
||||
(flightClass) => flightClass.inboundPackageDetails,
|
||||
{
|
||||
owner: true,
|
||||
fixedOrder: true,
|
||||
},
|
||||
)
|
||||
inboundFlightClasses = new Collection<FlightClass>(this);
|
||||
@ManyToOne(() => FlightSchedule, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
inboundFlight!: Rel<FlightSchedule>;
|
||||
|
||||
@ManyToMany(
|
||||
() => HotelSchedule,
|
||||
(hotelSchedule) => hotelSchedule.tourPackageDetails,
|
||||
{
|
||||
owner: true,
|
||||
fixedOrder: true,
|
||||
},
|
||||
)
|
||||
@ManyToMany(() => HotelSchedule, undefined, {
|
||||
owner: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
tourHotels = new Collection<HotelSchedule>(this);
|
||||
|
||||
@ManyToOne(() => HotelSchedule)
|
||||
@ManyToOne(() => HotelSchedule, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
makkahHotel!: Rel<HotelSchedule>;
|
||||
|
||||
@ManyToOne(() => HotelSchedule)
|
||||
@ManyToOne(() => HotelSchedule, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
madinahHotel!: Rel<HotelSchedule>;
|
||||
|
||||
@ManyToOne(() => TransportationClass)
|
||||
@@ -88,7 +72,12 @@ export class PackageDetail {
|
||||
doublePrice!: number;
|
||||
|
||||
@Property({ type: "decimal", nullable: true, unsigned: true })
|
||||
infantPrice?: number;
|
||||
infantPrice!: number | null;
|
||||
|
||||
@ManyToOne(() => PackageItinerary, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
itinerary!: Rel<PackageItinerary>;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
|
||||
52
src/database/entities/package-itinerary-day.entity.ts
Normal file
52
src/database/entities/package-itinerary-day.entity.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { PackageItineraryWidget } from "@/database/entities/package-itinerary-widget.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class PackageItineraryDay {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
title!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 1000 })
|
||||
description!: string;
|
||||
|
||||
@OneToMany(
|
||||
() => PackageItineraryWidget,
|
||||
(widget) => widget.packageItineraryDay,
|
||||
{
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
},
|
||||
)
|
||||
widgets = new Collection<PackageItineraryWidget>(this);
|
||||
|
||||
@ManyToOne(() => PackageItineraryDay, {
|
||||
nullable: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
next!: Rel<PackageItineraryDay> | null;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
}
|
||||
34
src/database/entities/package-itinerary-image.entity.ts
Normal file
34
src/database/entities/package-itinerary-image.entity.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { PackageItinerary } from "@/database/entities/package-itinerary.entity";
|
||||
import {
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class PackageItineraryImage {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => PackageItinerary)
|
||||
packageItinerary!: Rel<PackageItinerary>;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
src!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
}
|
||||
63
src/database/entities/package-itinerary-widget.entity.ts
Normal file
63
src/database/entities/package-itinerary-widget.entity.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Hotel } from "@/database/entities/hotel.entity";
|
||||
import { PackageItineraryDay } from "@/database/entities/package-itinerary-day.entity";
|
||||
import { PackageItineraryWidgetType } from "@/database/enums/package-itinerary-widget-type.enum";
|
||||
import {
|
||||
Entity,
|
||||
Enum,
|
||||
ManyToOne,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity({
|
||||
abstract: true,
|
||||
discriminatorColumn: "type",
|
||||
})
|
||||
export abstract class PackageItineraryWidget {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => PackageItineraryDay)
|
||||
packageItineraryDay!: Rel<PackageItineraryDay>;
|
||||
|
||||
@Enum(() => PackageItineraryWidgetType)
|
||||
type!: PackageItineraryWidgetType;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
}
|
||||
|
||||
@Entity({ discriminatorValue: "transport" })
|
||||
export class PackageItineraryWidgetTransport extends PackageItineraryWidget {
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
transportation!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
from!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
to!: string;
|
||||
}
|
||||
|
||||
@Entity({ discriminatorValue: "hotel" })
|
||||
export class PackageItineraryWidgetHotel extends PackageItineraryWidget {
|
||||
@ManyToOne(() => Hotel)
|
||||
hotel!: Rel<Hotel>;
|
||||
}
|
||||
|
||||
@Entity({ discriminatorValue: "information" })
|
||||
export class PackageItineraryWidgetInformation extends PackageItineraryWidget {
|
||||
@Property({ type: "varchar", length: 1000 })
|
||||
description!: string;
|
||||
}
|
||||
55
src/database/entities/package-itinerary.entity.ts
Normal file
55
src/database/entities/package-itinerary.entity.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { PackageItineraryDay } from "@/database/entities/package-itinerary-day.entity";
|
||||
import { PackageItineraryImage } from "@/database/entities/package-itinerary-image.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
type Rel,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class PackageItinerary {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
location!: string;
|
||||
|
||||
@OneToMany(
|
||||
() => PackageItineraryImage,
|
||||
(packageItineraryImage) => packageItineraryImage.packageItinerary,
|
||||
{
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
},
|
||||
)
|
||||
images = new Collection<PackageItineraryImage>(this);
|
||||
|
||||
@ManyToOne(() => PackageItineraryDay, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
day!: Rel<PackageItineraryDay>;
|
||||
|
||||
@ManyToOne(() => PackageItinerary, {
|
||||
nullable: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
next!: Rel<PackageItinerary> | null;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { PackageDetail } from "@/database/entities/package-detail.entity";
|
||||
import { PackageClass } from "@/database/enums/package-class.enum";
|
||||
import { PackageType } from "@/database/enums/package-type.enum";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
Enum,
|
||||
@@ -16,10 +17,6 @@ export class Package {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -51,6 +48,9 @@ export class Package {
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(() => PackageDetail, (packageDetail) => packageDetail.package)
|
||||
@OneToMany(() => PackageDetail, (packageDetail) => packageDetail.package, {
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
})
|
||||
details = new Collection<PackageDetail>(this);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PackageDetail } from "@/database/entities/package-detail.entity";
|
||||
import { TransportationClassImage } from "@/database/entities/transportation-class-image.entity";
|
||||
import { TransportationImage } from "@/database/entities/transportation-image.entity";
|
||||
import { Transportation } from "@/database/entities/transportation.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
@@ -18,10 +18,6 @@ export class TransportationClass {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 200 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@ManyToOne(() => Transportation)
|
||||
transportation!: Rel<Transportation>;
|
||||
|
||||
@@ -31,6 +27,16 @@ export class TransportationClass {
|
||||
@Property({ type: "integer", unsigned: true })
|
||||
totalSeats!: number;
|
||||
|
||||
@OneToMany(
|
||||
() => TransportationImage,
|
||||
(transportationClassImage) => transportationClassImage.transportation,
|
||||
{
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
},
|
||||
)
|
||||
images = new Collection<TransportationImage>(this);
|
||||
|
||||
@Property({
|
||||
type: "timestamp",
|
||||
onCreate: () => new Date(),
|
||||
@@ -43,18 +49,4 @@ export class TransportationClass {
|
||||
onUpdate: () => new Date(),
|
||||
})
|
||||
updatedAt!: Date;
|
||||
|
||||
// Collections
|
||||
|
||||
@OneToMany(
|
||||
() => TransportationClassImage,
|
||||
(transportationClassImage) => transportationClassImage.transportationClass,
|
||||
)
|
||||
images = new Collection<TransportationClass>(this);
|
||||
|
||||
@OneToMany(
|
||||
() => PackageDetail,
|
||||
(packageDetail) => packageDetail.transportation,
|
||||
)
|
||||
packageDetails = new Collection<PackageDetail>(this);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ import {
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
export class TransportationClassImage {
|
||||
export class TransportationImage {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => TransportationClass)
|
||||
transportationClass!: Rel<TransportationClass>;
|
||||
transportation!: Rel<TransportationClass>;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
src!: string;
|
||||
@@ -1,11 +1,11 @@
|
||||
import { TransportationClass } from "@/database/entities/transportation-class.entity";
|
||||
import {
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
OneToMany,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Unique,
|
||||
} from "@mikro-orm/core";
|
||||
|
||||
@Entity()
|
||||
@@ -13,10 +13,6 @@ export class Transportation {
|
||||
@PrimaryKey({ type: "varchar", length: 30 })
|
||||
id!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
@Unique()
|
||||
slug!: string;
|
||||
|
||||
@Property({ type: "varchar", length: 100 })
|
||||
name!: string;
|
||||
|
||||
@@ -41,6 +37,10 @@ export class Transportation {
|
||||
@OneToMany(
|
||||
() => TransportationClass,
|
||||
(transportationClass) => transportationClass.transportation,
|
||||
{
|
||||
orphanRemoval: true,
|
||||
cascade: [Cascade.REMOVE],
|
||||
},
|
||||
)
|
||||
transportationClasses = new Collection<TransportationClass>(this);
|
||||
classes = new Collection<TransportationClass>(this);
|
||||
}
|
||||
|
||||
5
src/database/enums/package-itinerary-widget-type.enum.ts
Normal file
5
src/database/enums/package-itinerary-widget-type.enum.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export enum PackageItineraryWidgetType {
|
||||
transport = "transport",
|
||||
hotel = "hotel",
|
||||
information = "information",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
226
src/database/migrations/Migration20251110080126.ts
Normal file
226
src/database/migrations/Migration20251110080126.ts
Normal file
@@ -0,0 +1,226 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251110080126 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(
|
||||
`create table "flight_schedule" ("id" varchar(30) not null, "flight_id" varchar(30) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "flight_schedule_pkey" primary key ("id"));`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_itinerary_day" ("id" varchar(30) not null, "title" varchar(100) not null, "description" varchar(1000) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_itinerary_day_pkey" primary key ("id"));`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_itinerary" ("id" varchar(30) not null, "location" varchar(100) not null, "day_id" varchar(30) not null, "next_id" varchar(30) null, "created_at" timestamptz not null, "updated_at" timestamptz not null, constraint "package_itinerary_pkey" primary key ("id"));`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_itinerary_image" ("id" varchar(30) not null, "package_itinerary_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "package_itinerary_image_pkey" primary key ("id"));`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_itinerary_widget" ("id" varchar(30) not null, "package_itinerary_day_id" varchar(30) not null, "type" text check ("type" in ('transport', 'hotel', 'information')) not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, "hotel_id" varchar(30) null, "description" varchar(1000) null, "transportation" varchar(100) null, "from" varchar(100) null, "to" varchar(100) null, constraint "package_itinerary_widget_pkey" primary key ("id"));`,
|
||||
);
|
||||
this.addSql(
|
||||
`create index "package_itinerary_widget_type_index" on "package_itinerary_widget" ("type");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "transportation_image" ("id" varchar(30) not null, "transportation_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "transportation_image_pkey" primary key ("id"));`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" add constraint "flight_schedule_flight_id_foreign" foreign key ("flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_image" add constraint "package_itinerary_image_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_package_itinerary_day_id_foreign" foreign key ("package_itinerary_day_id") references "package_itinerary_day" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_widget" add constraint "package_itinerary_widget_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`drop table if exists "package_detail_tour_flight_classes" cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`drop table if exists "package_detail_outbound_flight_classes" cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`drop table if exists "package_detail_inbound_flight_classes" cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(`drop table if exists "transportation_class_image" cascade;`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "airline" alter column "skytrax_rating" type int using ("skytrax_rating"::int);`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "airline" alter column "skytrax_rating" set not null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" add column "tour_flight_id" varchar(30) not null, add column "outbound_flight_id" varchar(30) not null, add column "inbound_flight_id" varchar(30) not null, add column "package_itinerary_id" varchar(30) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_pkey";`,
|
||||
);
|
||||
this.addSql(`alter table "package_detail_tour_hotels" drop column "id";`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_pkey" primary key ("package_detail_id", "hotel_schedule_id");`,
|
||||
);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_widget" drop constraint "package_itinerary_widget_package_itinerary_day_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_image" drop constraint "package_itinerary_image_package_itinerary_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_package_itinerary_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_detail_tour_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_detail_outbound_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "package_detail_inbound_flight_classes" ("id" serial primary key, "package_detail_id" varchar(30) not null, "flight_class_id" varchar(30) not null);`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`create table "transportation_class_image" ("id" varchar(30) not null, "transportation_class_id" varchar(30) not null, "src" varchar(100) not null, "created_at" varchar(100) not null, "updated_at" timestamptz not null, constraint "transportation_class_image_pkey" primary key ("id"));`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_flight_classes" add constraint "package_detail_tour_flight_classes_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_flight_classes" add constraint "package_detail_tour_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_outbound_flight_classes" add constraint "package_detail_outbound_flight_classes_package_d_8b70d_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail_outbound_flight_classes" add constraint "package_detail_outbound_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_inbound_flight_classes" add constraint "package_detail_inbound_flight_classes_package_detail_id_foreign" foreign key ("package_detail_id") references "package_detail" ("id") on update cascade on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail_inbound_flight_classes" add constraint "package_detail_inbound_flight_classes_flight_class_id_foreign" foreign key ("flight_class_id") references "flight_class" ("id") on update cascade on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_class_image" add constraint "transportation_class_image_transportation_class_id_foreign" foreign key ("transportation_class_id") references "transportation_class" ("id") on update cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(`drop table if exists "flight_schedule" cascade;`);
|
||||
|
||||
this.addSql(`drop table if exists "package_itinerary_day" cascade;`);
|
||||
|
||||
this.addSql(`drop table if exists "package_itinerary" cascade;`);
|
||||
|
||||
this.addSql(`drop table if exists "package_itinerary_image" cascade;`);
|
||||
|
||||
this.addSql(`drop table if exists "package_itinerary_widget" cascade;`);
|
||||
|
||||
this.addSql(`drop table if exists "transportation_image" cascade;`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "airline" alter column "skytrax_rating" type int using ("skytrax_rating"::int);`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "airline" alter column "skytrax_rating" drop not null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop column "tour_flight_id", drop column "outbound_flight_id", drop column "inbound_flight_id", drop column "package_itinerary_id";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_hotels" drop constraint "package_detail_tour_hotels_pkey";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_hotels" add column "id" serial not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail_tour_hotels" add constraint "package_detail_tour_hotels_pkey" primary key ("id");`,
|
||||
);
|
||||
}
|
||||
}
|
||||
133
src/database/migrations/Migration20251111010042.ts
Normal file
133
src/database/migrations/Migration20251111010042.ts
Normal file
@@ -0,0 +1,133 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251111010042 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(`alter table "airline" drop constraint "airline_slug_unique";`);
|
||||
this.addSql(`alter table "airline" drop column "slug";`);
|
||||
|
||||
this.addSql(`alter table "country" drop constraint "country_slug_unique";`);
|
||||
this.addSql(`alter table "country" drop column "slug";`);
|
||||
|
||||
this.addSql(`alter table "city" drop constraint "city_slug_unique";`);
|
||||
this.addSql(`alter table "city" drop column "slug";`);
|
||||
|
||||
this.addSql(`alter table "airport" drop constraint "airport_slug_unique";`);
|
||||
this.addSql(`alter table "airport" drop column "slug";`);
|
||||
|
||||
this.addSql(`alter table "flight" drop constraint "flight_slug_unique";`);
|
||||
this.addSql(`alter table "flight" drop column "slug";`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "flight_class" drop constraint "flight_class_slug_unique";`,
|
||||
);
|
||||
this.addSql(`alter table "flight_class" drop column "slug";`);
|
||||
|
||||
this.addSql(`alter table "hotel" drop constraint "hotel_slug_unique";`);
|
||||
this.addSql(`alter table "hotel" drop column "slug";`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_facility" drop constraint "hotel_facility_slug_unique";`,
|
||||
);
|
||||
this.addSql(`alter table "hotel_facility" drop column "slug";`);
|
||||
|
||||
this.addSql(`alter table "package" drop constraint "package_slug_unique";`);
|
||||
this.addSql(`alter table "package" drop column "slug";`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation" drop constraint "transportation_slug_unique";`,
|
||||
);
|
||||
this.addSql(`alter table "transportation" drop column "slug";`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_class" drop constraint "transportation_class_slug_unique";`,
|
||||
);
|
||||
this.addSql(`alter table "transportation_class" drop column "slug";`);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_slug_unique";`,
|
||||
);
|
||||
this.addSql(`alter table "package_detail" drop column "slug";`);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "airline" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "airline" add constraint "airline_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "country" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "country" add constraint "country_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(`alter table "city" add column "slug" varchar(200) not null;`);
|
||||
this.addSql(
|
||||
`alter table "city" add constraint "city_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "airport" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "airport" add constraint "airport_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "flight" add column "slug" varchar(220) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "flight" add constraint "flight_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "flight_class" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "flight_class" add constraint "flight_class_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(`alter table "hotel" add column "slug" varchar(200) not null;`);
|
||||
this.addSql(
|
||||
`alter table "hotel" add constraint "hotel_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_facility" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_facility" add constraint "hotel_facility_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package" add constraint "package_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation" add column "slug" varchar(100) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "transportation" add constraint "transportation_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_class" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "transportation_class" add constraint "transportation_class_slug_unique" unique ("slug");`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" add column "slug" varchar(200) not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_slug_unique" unique ("slug");`,
|
||||
);
|
||||
}
|
||||
}
|
||||
27
src/database/migrations/Migration20251112104244.ts
Normal file
27
src/database/migrations/Migration20251112104244.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251112104244 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "hotel" alter column "google_maps_link" type varchar(1000) using ("google_maps_link"::varchar(1000));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel" alter column "google_maps_embed" type varchar(1000) using ("google_maps_embed"::varchar(1000));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel" alter column "google_reviews_link" type varchar(1000) using ("google_reviews_link"::varchar(1000));`,
|
||||
);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "hotel" alter column "google_maps_link" type varchar(500) using ("google_maps_link"::varchar(500));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel" alter column "google_maps_embed" type varchar(500) using ("google_maps_embed"::varchar(500));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel" alter column "google_reviews_link" type varchar(500) using ("google_reviews_link"::varchar(500));`,
|
||||
);
|
||||
}
|
||||
}
|
||||
35
src/database/migrations/Migration20251112105017.ts
Normal file
35
src/database/migrations/Migration20251112105017.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251112105017 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on delete cascade;`,
|
||||
);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
21
src/database/migrations/Migration20251112105413.ts
Normal file
21
src/database/migrations/Migration20251112105413.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
export class Migration20251112105413 extends Migration {
|
||||
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`);
|
||||
|
||||
this.addSql(`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`);
|
||||
this.addSql(`alter table "transportation_image" alter column "transportation_id" drop not null;`);
|
||||
this.addSql(`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on delete cascade;`);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`);
|
||||
|
||||
this.addSql(`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`);
|
||||
this.addSql(`alter table "transportation_image" alter column "transportation_id" set not null;`);
|
||||
this.addSql(`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`);
|
||||
}
|
||||
|
||||
}
|
||||
47
src/database/migrations/Migration20251112134446.ts
Normal file
47
src/database/migrations/Migration20251112134446.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251112134446 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_class" ("id") on update cascade;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
29
src/database/migrations/Migration20251112140208.ts
Normal file
29
src/database/migrations/Migration20251112140208.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251112140208 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_package_itinerary_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" rename column "package_itinerary_id" to "itinerary_id";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on update cascade;`,
|
||||
);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" rename column "itinerary_id" to "package_itinerary_id";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_package_itinerary_id_foreign" foreign key ("package_itinerary_id") references "package_itinerary" ("id") on update cascade;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
283
src/database/migrations/Migration20251113230544.ts
Normal file
283
src/database/migrations/Migration20251113230544.ts
Normal file
@@ -0,0 +1,283 @@
|
||||
import { Migration } from "@mikro-orm/migrations";
|
||||
|
||||
export class Migration20251113230544 extends Migration {
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on update cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" alter column "day_id" type varchar(30) using ("day_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" alter column "day_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "tour_flight_id" type varchar(30) using ("tour_flight_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "tour_flight_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "outbound_flight_id" type varchar(30) using ("outbound_flight_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "outbound_flight_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "inbound_flight_id" type varchar(30) using ("inbound_flight_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "inbound_flight_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "makkah_hotel_id" type varchar(30) using ("makkah_hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "makkah_hotel_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "madinah_hotel_id" type varchar(30) using ("madinah_hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "madinah_hotel_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "itinerary_id" type varchar(30) using ("itinerary_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "itinerary_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel_schedule" ("id") on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel_schedule" ("id") on delete cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "transportation_image" alter column "transportation_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on update cascade;`,
|
||||
);
|
||||
}
|
||||
|
||||
override async down(): Promise<void> {
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" drop constraint "flight_schedule_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_image" drop constraint "hotel_image_hotel_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_day" drop constraint "package_itinerary_day_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" drop constraint "package_itinerary_day_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" drop constraint "package_itinerary_next_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_tour_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_outbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_inbound_flight_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_makkah_hotel_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_madinah_hotel_id_foreign";`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" drop constraint "package_detail_itinerary_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_image" drop constraint "transportation_image_transportation_id_foreign";`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "flight_schedule" add constraint "flight_schedule_next_id_foreign" foreign key ("next_id") references "flight_schedule" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" type varchar(30) using ("hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" alter column "hotel_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "hotel_image" add constraint "hotel_image_hotel_id_foreign" foreign key ("hotel_id") references "hotel" ("id") on delete cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary_day" add constraint "package_itinerary_day_next_id_foreign" foreign key ("next_id") references "package_itinerary_day" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" alter column "day_id" type varchar(30) using ("day_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" alter column "day_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" add constraint "package_itinerary_day_id_foreign" foreign key ("day_id") references "package_itinerary_day" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_itinerary" add constraint "package_itinerary_next_id_foreign" foreign key ("next_id") references "package_itinerary" ("id") on update cascade on delete set null;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "tour_flight_id" type varchar(30) using ("tour_flight_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "tour_flight_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "outbound_flight_id" type varchar(30) using ("outbound_flight_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "outbound_flight_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "inbound_flight_id" type varchar(30) using ("inbound_flight_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "inbound_flight_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "makkah_hotel_id" type varchar(30) using ("makkah_hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "makkah_hotel_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "madinah_hotel_id" type varchar(30) using ("madinah_hotel_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "madinah_hotel_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "itinerary_id" type varchar(30) using ("itinerary_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" alter column "itinerary_id" set not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_tour_flight_id_foreign" foreign key ("tour_flight_id") references "flight_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_outbound_flight_id_foreign" foreign key ("outbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_inbound_flight_id_foreign" foreign key ("inbound_flight_id") references "flight_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_makkah_hotel_id_foreign" foreign key ("makkah_hotel_id") references "hotel_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_madinah_hotel_id_foreign" foreign key ("madinah_hotel_id") references "hotel_schedule" ("id") on update cascade;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "package_detail" add constraint "package_detail_itinerary_id_foreign" foreign key ("itinerary_id") references "package_itinerary" ("id") on update cascade;`,
|
||||
);
|
||||
|
||||
this.addSql(
|
||||
`alter table "transportation_image" alter column "transportation_id" type varchar(30) using ("transportation_id"::varchar(30));`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "transportation_image" alter column "transportation_id" drop not null;`,
|
||||
);
|
||||
this.addSql(
|
||||
`alter table "transportation_image" add constraint "transportation_image_transportation_id_foreign" foreign key ("transportation_id") references "transportation_class" ("id") on delete cascade;`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user