Skip to content

Commit cd7bd2d

Browse files
committed
chore: collapse timezone migrations
1 parent 458d777 commit cd7bd2d

File tree

7 files changed

+57
-882
lines changed

7 files changed

+57
-882
lines changed

database/migrations/0002_dapper_blob.sql renamed to database/migrations/0002_fat_white_tiger.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ CREATE TABLE "location_hours" (
33
"location_uuid" text NOT NULL,
44
"day_of_week" integer NOT NULL,
55
"period_number" integer DEFAULT 1 NOT NULL,
6-
"open_time" text NOT NULL,
7-
"close_time" text NOT NULL,
6+
"open_time" time NOT NULL,
7+
"close_time" time NOT NULL,
88
"is_24_hours" boolean DEFAULT false NOT NULL,
99
"is_closed" boolean DEFAULT false NOT NULL,
1010
"created_at" timestamp
1111
);
1212
--> statement-breakpoint
13+
ALTER TABLE "locations" ADD COLUMN "timezone" text DEFAULT 'Europe/Zurich' NOT NULL;--> statement-breakpoint
1314
ALTER TABLE "location_hours" ADD CONSTRAINT "location_hours_location_uuid_locations_uuid_fk" FOREIGN KEY ("location_uuid") REFERENCES "public"."locations"("uuid") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
1415
CREATE INDEX "location_hours_location_idx" ON "location_hours" USING btree ("location_uuid","day_of_week","period_number");--> statement-breakpoint
15-
CREATE INDEX "location_hours_day_time_idx" ON "location_hours" USING btree ("day_of_week","open_time","close_time");
16+
CREATE INDEX "location_hours_day_time_idx" ON "location_hours" USING btree ("day_of_week","open_time","close_time");--> statement-breakpoint
17+
CREATE INDEX "location_hours_open_now_idx" ON "location_hours" USING btree ("location_uuid","day_of_week","open_time","close_time","period_number") WHERE "location_hours"."is_closed" = false;

database/migrations/0003_glamorous_wong.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.

database/migrations/0004_flat_blob.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

database/migrations/meta/0002_snapshot.json

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "304027b0-06bc-4d00-9cb0-3360b2d749a4",
2+
"id": "54de420f-7cef-4ad2-bdee-2635300520a5",
33
"prevId": "6b68c759-0cf3-434e-b465-3b299ee5c3e2",
44
"version": "7",
55
"dialect": "postgresql",
@@ -169,13 +169,13 @@
169169
},
170170
"open_time": {
171171
"name": "open_time",
172-
"type": "text",
172+
"type": "time",
173173
"primaryKey": false,
174174
"notNull": true
175175
},
176176
"close_time": {
177177
"name": "close_time",
178-
"type": "text",
178+
"type": "time",
179179
"primaryKey": false,
180180
"notNull": true
181181
},
@@ -254,6 +254,46 @@
254254
"concurrently": false,
255255
"method": "btree",
256256
"with": {}
257+
},
258+
"location_hours_open_now_idx": {
259+
"name": "location_hours_open_now_idx",
260+
"columns": [
261+
{
262+
"expression": "location_uuid",
263+
"isExpression": false,
264+
"asc": true,
265+
"nulls": "last"
266+
},
267+
{
268+
"expression": "day_of_week",
269+
"isExpression": false,
270+
"asc": true,
271+
"nulls": "last"
272+
},
273+
{
274+
"expression": "open_time",
275+
"isExpression": false,
276+
"asc": true,
277+
"nulls": "last"
278+
},
279+
{
280+
"expression": "close_time",
281+
"isExpression": false,
282+
"asc": true,
283+
"nulls": "last"
284+
},
285+
{
286+
"expression": "period_number",
287+
"isExpression": false,
288+
"asc": true,
289+
"nulls": "last"
290+
}
291+
],
292+
"isUnique": false,
293+
"where": "\"location_hours\".\"is_closed\" = false",
294+
"concurrently": false,
295+
"method": "btree",
296+
"with": {}
257297
}
258298
},
259299
"foreignKeys": {
@@ -341,6 +381,13 @@
341381
"primaryKey": false,
342382
"notNull": true
343383
},
384+
"timezone": {
385+
"name": "timezone",
386+
"type": "text",
387+
"primaryKey": false,
388+
"notNull": true,
389+
"default": "'Europe/Zurich'"
390+
},
344391
"updated_at": {
345392
"name": "updated_at",
346393
"type": "timestamp",

0 commit comments

Comments
 (0)