File tree 2 files changed +7
-3
lines changed
migrations/20240320000001_add_booking_time_status_denormalized
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,14 @@ CREATE TABLE "BookingTimeStatusDenormalized" (
29
29
CREATE INDEX "idx_booking_user_id " ON " BookingTimeStatusDenormalized" (" userId" );
30
30
CREATE INDEX "idx_booking_created_at " ON " BookingTimeStatusDenormalized" (" createdAt" );
31
31
CREATE INDEX "idx_event_type_id " ON " BookingTimeStatusDenormalized" (" eventTypeId" );
32
- CREATE INDEX "idx_event_type_hierarchy " ON " BookingTimeStatusDenormalized" (" eventTypeId " , " eventParentId" );
32
+ CREATE INDEX "idx_event_parent_id " ON " BookingTimeStatusDenormalized" (" eventParentId" );
33
33
CREATE INDEX "idx_booking_time_status " ON " BookingTimeStatusDenormalized" (" timeStatus" );
34
34
CREATE INDEX "idx_booking_team_id " ON " BookingTimeStatusDenormalized" (" teamId" );
35
35
CREATE INDEX "idx_booking_start_time " ON " BookingTimeStatusDenormalized" (" startTime" );
36
36
CREATE INDEX "idx_booking_end_time " ON " BookingTimeStatusDenormalized" (" endTime" );
37
37
CREATE INDEX "idx_booking_status " ON " BookingTimeStatusDenormalized" (" status" );
38
+ CREATE INDEX "idx_booking_team_id_team_booking " ON " BookingTimeStatusDenormalized" (" teamId" , " isTeamBooking" );
39
+ CREATE INDEX "idx_booking_user_id_team_booking " ON " BookingTimeStatusDenormalized" (" userId" , " isTeamBooking" );
38
40
39
41
-- Function to calculate timeStatus
40
42
CREATE OR REPLACE FUNCTION calculate_time_status (
@@ -67,7 +69,7 @@ RETURNS VOID AS $$
67
69
BEGIN
68
70
-- Delete existing entry if any
69
71
DELETE FROM " BookingTimeStatusDenormalized" WHERE id = booking_id;
70
-
72
+
71
73
-- Insert non-team booking
72
74
INSERT INTO " BookingTimeStatusDenormalized"
73
75
SELECT
Original file line number Diff line number Diff line change @@ -2114,10 +2114,12 @@ model BookingTimeStatusDenormalized {
2114
2114
@@index ([userId ] , name : " idx_booking_user_id " )
2115
2115
@@index ([createdAt ] , name : " idx_booking_created_at " )
2116
2116
@@index ([eventTypeId ] , name : " idx_event_type_id " )
2117
- @@index ([eventTypeId , eventParentId ] , name : " idx_event_type_hierarchy " )
2117
+ @@index ([eventParentId ] , name : " idx_event_parent_id " )
2118
2118
@@index ([timeStatus ] , name : " idx_booking_time_status " )
2119
2119
@@index ([teamId ] , name : " idx_booking_team_id " )
2120
2120
@@index ([startTime ] , name : " idx_booking_start_time " )
2121
2121
@@index ([endTime ] , name : " idx_booking_end_time " )
2122
2122
@@index ([status ] , name : " idx_booking_status " )
2123
+ @@index ([teamId , isTeamBooking ] , name : " idx_booking_team_id_team_booking " )
2124
+ @@index ([userId , isTeamBooking ] , name : " idx_booking_user_id_team_booking " )
2123
2125
}
You can’t perform that action at this time.
0 commit comments