@@ -21,9 +21,9 @@ CREATE TABLE reservations (
2121 stall_id BIGINT NOT NULL ,
2222 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
2323 qr_code_base64 TEXT ,
24- status VARCHAR (50 ) NOT NULL DEFAULT ' CONFIRMED' ,
2524 payment_expires_at TIMESTAMP NULL ,
2625 payment_completed_at TIMESTAMP NULL ,
26+ status VARCHAR (50 ) NOT NULL DEFAULT ' PENDING_PAYMENT' ,
2727
2828 -- Constraint to ensure status is valid
2929 CONSTRAINT chk_status CHECK (status IN (' PENDING_PAYMENT' , ' CONFIRMED' , ' CANCELLED' , ' EXPIRED' ))
@@ -51,94 +51,3 @@ CREATE INDEX idx_status_stall ON reservations(status, stall_id);
5151
5252-- Show initial record count
5353SELECT COUNT (* ) as total_reservations FROM reservations;
54- -- Example: Creating a 10x10 grid of stalls
55- -- Each stall is approximately 5m x 5m
56- -- Coordinates are in WGS 84 (SRID 4326) - latitude/longitude format
57-
58- -- Zone A - Ground Floor (Stalls A1-A10)
59- INSERT INTO stalls (stall_code, size, price, is_reserved, location, boundary, zone, floor_number, description) VALUES
60- (' A1' , ' Small' , 500 .00 , FALSE,
61- ST_SetSRID(ST_MakePoint(- 0 .001000 , 0 .000000 ), 4326 ),
62- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.001025 -0.000025, -0.000975 -0.000025, -0.000975 0.000025, -0.001025 0.000025, -0.001025 -0.000025)' )), 4326 ),
63- ' Zone A' , 1 , ' Corner stall with good visibility' ),
64- (' A2' , ' Small' , 500 .00 , FALSE,
65- ST_SetSRID(ST_MakePoint(- 0 .000900 , 0 .000000 ), 4326 ),
66- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000925 -0.000025, -0.000875 -0.000025, -0.000875 0.000025, -0.000925 0.000025, -0.000925 -0.000025)' )), 4326 ),
67- ' Zone A' , 1 , ' Central location' ),
68- (' A3' , ' Medium' , 750 .00 , FALSE,
69- ST_SetSRID(ST_MakePoint(- 0 .000800 , 0 .000000 ), 4326 ),
70- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000825 -0.000040, -0.000775 -0.000040, -0.000775 0.000040, -0.000825 0.000040, -0.000825 -0.000040)' )), 4326 ),
71- ' Zone A' , 1 , ' Medium sized stall' ),
72- (' A4' , ' Small' , 500 .00 , TRUE,
73- ST_SetSRID(ST_MakePoint(- 0 .000700 , 0 .000000 ), 4326 ),
74- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000725 -0.000025, -0.000675 -0.000025, -0.000675 0.000025, -0.000725 0.000025, -0.000725 -0.000025)' )), 4326 ),
75- ' Zone A' , 1 , ' Already reserved' ),
76- (' A5' , ' Large' , 1000 .00 , FALSE,
77- ST_SetSRID(ST_MakePoint(- 0 .000600 , 0 .000000 ), 4326 ),
78- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000625 -0.000050, -0.000575 -0.000050, -0.000575 0.000050, -0.000625 0.000050, -0.000625 -0.000050)' )), 4326 ),
79- ' Zone A' , 1 , ' Large premium stall' );
80-
81- -- Zone B - Ground Floor (Stalls B1-B5)
82- INSERT INTO stalls (stall_code, size, price, is_reserved, location, boundary, zone, floor_number, description) VALUES
83- (' B1' , ' Small' , 500 .00 , FALSE,
84- ST_SetSRID(ST_MakePoint(- 0 .001000 , 0 .000100 ), 4326 ),
85- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.001025 0.000075, -0.000975 0.000075, -0.000975 0.000125, -0.001025 0.000125, -0.001025 0.000075)' )), 4326 ),
86- ' Zone B' , 1 , ' North side location' ),
87- (' B2' , ' Medium' , 750 .00 , TRUE,
88- ST_SetSRID(ST_MakePoint(- 0 .000900 , 0 .000100 ), 4326 ),
89- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000925 0.000060, -0.000875 0.000060, -0.000875 0.000140, -0.000925 0.000140, -0.000925 0.000060)' )), 4326 ),
90- ' Zone B' , 1 , ' Already reserved' ),
91- (' B3' , ' Small' , 500 .00 , FALSE,
92- ST_SetSRID(ST_MakePoint(- 0 .000800 , 0 .000100 ), 4326 ),
93- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000825 0.000075, -0.000775 0.000075, -0.000775 0.000125, -0.000825 0.000125, -0.000825 0.000075)' )), 4326 ),
94- ' Zone B' , 1 , ' Available stall' ),
95- (' B4' , ' Large' , 1000 .00 , FALSE,
96- ST_SetSRID(ST_MakePoint(- 0 .000700 , 0 .000100 ), 4326 ),
97- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000725 0.000050, -0.000675 0.000050, -0.000675 0.000150, -0.000725 0.000150, -0.000725 0.000050)' )), 4326 ),
98- ' Zone B' , 1 , ' Large corner stall' ),
99- (' B5' , ' Medium' , 750 .00 , FALSE,
100- ST_SetSRID(ST_MakePoint(- 0 .000600 , 0 .000100 ), 4326 ),
101- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000625 0.000060, -0.000575 0.000060, -0.000575 0.000140, -0.000625 0.000140, -0.000625 0.000060)' )), 4326 ),
102- ' Zone B' , 1 , ' Good traffic flow' );
103-
104- -- Zone C - First Floor (Stalls C1-C5)
105- INSERT INTO stalls (stall_code, size, price, is_reserved, location, boundary, zone, floor_number, description) VALUES
106- (' C1' , ' Small' , 450 .00 , FALSE,
107- ST_SetSRID(ST_MakePoint(- 0 .001000 , - 0 .000100 ), 4326 ),
108- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.001025 -0.000125, -0.000975 -0.000125, -0.000975 -0.000075, -0.001025 -0.000075, -0.001025 -0.000125)' )), 4326 ),
109- ' Zone C' , 2 , ' First floor economy' ),
110- (' C2' , ' Small' , 450 .00 , FALSE,
111- ST_SetSRID(ST_MakePoint(- 0 .000900 , - 0 .000100 ), 4326 ),
112- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000925 -0.000125, -0.000875 -0.000125, -0.000875 -0.000075, -0.000925 -0.000075, -0.000925 -0.000125)' )), 4326 ),
113- ' Zone C' , 2 , ' Available' ),
114- (' C3' , ' Medium' , 700 .00 , TRUE,
115- ST_SetSRID(ST_MakePoint(- 0 .000800 , - 0 .000100 ), 4326 ),
116- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000825 -0.000140, -0.000775 -0.000140, -0.000775 -0.000060, -0.000825 -0.000060, -0.000825 -0.000140)' )), 4326 ),
117- ' Zone C' , 2 , ' Already reserved' ),
118- (' C4' , ' Small' , 450 .00 , FALSE,
119- ST_SetSRID(ST_MakePoint(- 0 .000700 , - 0 .000100 ), 4326 ),
120- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000725 -0.000125, -0.000675 -0.000125, -0.000675 -0.000075, -0.000725 -0.000075, -0.000725 -0.000125)' )), 4326 ),
121- ' Zone C' , 2 , ' Quiet area' ),
122- (' C5' , ' Large' , 900 .00 , FALSE,
123- ST_SetSRID(ST_MakePoint(- 0 .000600 , - 0 .000100 ), 4326 ),
124- ST_SetSRID(ST_MakePolygon(ST_GeomFromText(' LINESTRING(-0.000625 -0.000150, -0.000575 -0.000150, -0.000575 -0.000050, -0.000625 -0.000050, -0.000625 -0.000150)' )), 4326 ),
125- ' Zone C' , 2 , ' Premium first floor location' );
126-
127- ' Zone C' , 2 , ' Premium first floor location' );
128-
129- -- Create a user for the application (optional - update credentials as needed)
130- -- CREATE USER reservation_user WITH PASSWORD 'your_password';
131- -- GRANT ALL PRIVILEGES ON DATABASE reservation_db TO reservation_user;
132- -- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO reservation_user;
133- -- GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO reservation_user;
134-
135- -- Display table structures
136- \d+ stalls;
137- \d+ reservations;
138-
139- -- Show initial record counts
140- SELECT COUNT (* ) as total_stalls FROM stalls;
141- SELECT COUNT (* ) as total_reservations FROM reservations;
142-
143- -- Show spatial reference system info
144- SELECT * FROM spatial_ref_sys WHERE srid = 4326 ;
0 commit comments