-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration.sql
More file actions
77 lines (77 loc) · 7.34 KB
/
migration.sql
File metadata and controls
77 lines (77 loc) · 7.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
BEGIN;
--
-- Create model Customer
--
CREATE TABLE "cinemahall_customer" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "password" varchar(128) NOT NULL, "last_login" timestamp with time zone NULL, "is_superuser" boolean NOT NULL, "customer_email" varchar(254) NOT NULL UNIQUE, "customer_contact_info" varchar(15) NOT NULL, "is_staff" boolean NOT NULL, "is_active" boolean NOT NULL);
CREATE TABLE "cinemahall_customer_groups" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "customer_id" bigint NOT NULL, "group_id" integer NOT NULL);
CREATE TABLE "cinemahall_customer_user_permissions" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "customer_id" bigint NOT NULL, "permission_id" integer NOT NULL);
--
-- Create model Film
--
CREATE TABLE "cinemahall_film" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "film_name" varchar(50) NOT NULL, "film_director" varchar(50) NOT NULL, "film_released_state" boolean NOT NULL, "film_released_date" date NOT NULL, "film_imdb_id" integer NOT NULL, "film_cast" varchar(200) NOT NULL);
--
-- Create model Reservation
--
CREATE TABLE "cinemahall_reservation" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "Customer_id" bigint NOT NULL);
--
-- Create model ReservationType
--
CREATE TABLE "cinemahall_reservationtype" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "reservation_type" varchar(200) NOT NULL);
--
-- Create model Screening
--
CREATE TABLE "cinemahall_screening" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "screening_start_time" timestamp with time zone NOT NULL, "Film_id" bigint NOT NULL);
--
-- Create model Seat
--
CREATE TABLE "cinemahall_seat" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "seat_row" varchar(2) NOT NULL, "seat_column" integer NOT NULL);
--
-- Create model Theatre
--
CREATE TABLE "cinemahall_theatre" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "theatre_name" varchar(30) NOT NULL, "theatre_no_of_seats" integer NOT NULL);
--
-- Create model SeatReserved
--
CREATE TABLE "cinemahall_seatreserved" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "Reservation_id" bigint NOT NULL, "Screening_id" bigint NOT NULL, "Seat_id" bigint NOT NULL);
--
-- Add field Theatre to seat
--
ALTER TABLE "cinemahall_seat" ADD COLUMN "Theatre_id" bigint NOT NULL CONSTRAINT "cinemahall_seat_Theatre_id_b901a4f5_fk_cinemahall_theatre_id" REFERENCES "cinemahall_theatre"("id") DEFERRABLE INITIALLY DEFERRED; SET CONSTRAINTS "cinemahall_seat_Theatre_id_b901a4f5_fk_cinemahall_theatre_id" IMMEDIATE;
--
-- Add field Theatre to screening
--
ALTER TABLE "cinemahall_screening" ADD COLUMN "Theatre_id" bigint NOT NULL CONSTRAINT "cinemahall_screening_Theatre_id_da12593f_fk_cinemahal" REFERENCES "cinemahall_theatre"("id") DEFERRABLE INITIALLY DEFERRED; SET CONSTRAINTS "cinemahall_screening_Theatre_id_da12593f_fk_cinemahal" IMMEDIATE;
--
-- Add field ReservationType to reservation
--
ALTER TABLE "cinemahall_reservation" ADD COLUMN "ReservationType_id" bigint NOT NULL CONSTRAINT "cinemahall_reservati_ReservationType_id_c93dd87b_fk_cinemahal" REFERENCES "cinemahall_reservationtype"("id") DEFERRABLE INITIALLY DEFERRED; SET CONSTRAINTS "cinemahall_reservati_ReservationType_id_c93dd87b_fk_cinemahal" IMMEDIATE;
--
-- Add field Screening to reservation
--
ALTER TABLE "cinemahall_reservation" ADD COLUMN "Screening_id" bigint NOT NULL CONSTRAINT "cinemahall_reservati_Screening_id_94bab94d_fk_cinemahal" REFERENCES "cinemahall_screening"("id") DEFERRABLE INITIALLY DEFERRED; SET CONSTRAINTS "cinemahall_reservati_Screening_id_94bab94d_fk_cinemahal" IMMEDIATE;
CREATE INDEX "cinemahall_customer_customer_email_25feacbc_like" ON "cinemahall_customer" ("customer_email" varchar_pattern_ops);
ALTER TABLE "cinemahall_customer_groups" ADD CONSTRAINT "cinemahall_customer_groups_customer_id_group_id_1d9a95b5_uniq" UNIQUE ("customer_id", "group_id");
ALTER TABLE "cinemahall_customer_groups" ADD CONSTRAINT "cinemahall_customer__customer_id_e98f7256_fk_cinemahal" FOREIGN KEY ("customer_id") REFERENCES "cinemahall_customer" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "cinemahall_customer_groups" ADD CONSTRAINT "cinemahall_customer_groups_group_id_f868ddcd_fk_auth_group_id" FOREIGN KEY ("group_id") REFERENCES "auth_group" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "cinemahall_customer_groups_customer_id_e98f7256" ON "cinemahall_customer_groups" ("customer_id");
CREATE INDEX "cinemahall_customer_groups_group_id_f868ddcd" ON "cinemahall_customer_groups" ("group_id");
ALTER TABLE "cinemahall_customer_user_permissions" ADD CONSTRAINT "cinemahall_customer_user_customer_id_permission_i_a83c1c75_uniq" UNIQUE ("customer_id", "permission_id");
ALTER TABLE "cinemahall_customer_user_permissions" ADD CONSTRAINT "cinemahall_customer__customer_id_ec3f8cd1_fk_cinemahal" FOREIGN KEY ("customer_id") REFERENCES "cinemahall_customer" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "cinemahall_customer_user_permissions" ADD CONSTRAINT "cinemahall_customer__permission_id_946a3514_fk_auth_perm" FOREIGN KEY ("permission_id") REFERENCES "auth_permission" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "cinemahall_customer_user_permissions_customer_id_ec3f8cd1" ON "cinemahall_customer_user_permissions" ("customer_id");
CREATE INDEX "cinemahall_customer_user_permissions_permission_id_946a3514" ON "cinemahall_customer_user_permissions" ("permission_id");
ALTER TABLE "cinemahall_reservation" ADD CONSTRAINT "cinemahall_reservati_Customer_id_82d32fcc_fk_cinemahal" FOREIGN KEY ("Customer_id") REFERENCES "cinemahall_customer" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "cinemahall_reservation_Customer_id_82d32fcc" ON "cinemahall_reservation" ("Customer_id");
ALTER TABLE "cinemahall_screening" ADD CONSTRAINT "cinemahall_screening_Film_id_ade956cc_fk_cinemahall_film_id" FOREIGN KEY ("Film_id") REFERENCES "cinemahall_film" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "cinemahall_screening_Film_id_ade956cc" ON "cinemahall_screening" ("Film_id");
ALTER TABLE "cinemahall_seatreserved" ADD CONSTRAINT "cinemahall_seatreser_Reservation_id_05a990a7_fk_cinemahal" FOREIGN KEY ("Reservation_id") REFERENCES "cinemahall_reservation" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "cinemahall_seatreserved" ADD CONSTRAINT "cinemahall_seatreser_Screening_id_bfe06b6c_fk_cinemahal" FOREIGN KEY ("Screening_id") REFERENCES "cinemahall_screening" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "cinemahall_seatreserved" ADD CONSTRAINT "cinemahall_seatreserved_Seat_id_f73cd3d7_fk_cinemahall_seat_id" FOREIGN KEY ("Seat_id") REFERENCES "cinemahall_seat" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "cinemahall_seatreserved_Reservation_id_05a990a7" ON "cinemahall_seatreserved" ("Reservation_id");
CREATE INDEX "cinemahall_seatreserved_Screening_id_bfe06b6c" ON "cinemahall_seatreserved" ("Screening_id");
CREATE INDEX "cinemahall_seatreserved_Seat_id_f73cd3d7" ON "cinemahall_seatreserved" ("Seat_id");
CREATE INDEX "cinemahall_seat_Theatre_id_b901a4f5" ON "cinemahall_seat" ("Theatre_id");
CREATE INDEX "cinemahall_screening_Theatre_id_da12593f" ON "cinemahall_screening" ("Theatre_id");
CREATE INDEX "cinemahall_reservation_ReservationType_id_c93dd87b" ON "cinemahall_reservation" ("ReservationType_id");
CREATE INDEX "cinemahall_reservation_Screening_id_94bab94d" ON "cinemahall_reservation" ("Screening_id");
COMMIT;