feat: add default_hours_scheduled_changes table and admin_notifications enum value
Add new table for staging future default hours changes with an upsert guard (at most one pending change). Extend admin_notification_reason enum with 'default_hours_changed'.
This commit is contained in:
@@ -552,6 +552,23 @@ INSERT INTO working_hours VALUES (4, '09:00:00', '17:00:00', TRUE);
|
||||
INSERT INTO working_hours VALUES (5, '09:00:00', '17:00:00', TRUE);
|
||||
INSERT INTO working_hours VALUES (6, '00:00:00', '00:00:00', FALSE);
|
||||
|
||||
-- =======================================
|
||||
-- SCHEDULED DEFAULT HOURS CHANGES
|
||||
-- =======================================
|
||||
CREATE TABLE default_hours_scheduled_changes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
effective_date DATE NOT NULL,
|
||||
created_by CHAR(12) REFERENCES users(id),
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
applied_at TIMESTAMPTZ,
|
||||
cancelled_at TIMESTAMPTZ,
|
||||
hours JSONB NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX idx_one_pending_change
|
||||
ON default_hours_scheduled_changes ((1))
|
||||
WHERE applied_at IS NULL AND cancelled_at IS NULL;
|
||||
|
||||
-- =======================================
|
||||
-- EXCEPTIONAL WORKING HOURS
|
||||
-- =======================================
|
||||
@@ -800,7 +817,7 @@ INSERT INTO business_settings (
|
||||
'https://www.website.co.uk'
|
||||
);
|
||||
|
||||
CREATE TYPE admin_notification_reason AS ENUM ('pending_booking', 'cancelled_booking', 'rescheduled_booking', '1_week_no_pay', '1_month_no_pay', 'affiliate_claim', 'late_cancellation', 'deposit_paid', 'edit_request', 'edit_requested', 'new_booking', 'deposit_not_paid_by_deadline', 'gift_card_purchased_for_friend');
|
||||
CREATE TYPE admin_notification_reason AS ENUM ('pending_booking', 'cancelled_booking', 'rescheduled_booking', '1_week_no_pay', '1_month_no_pay', 'affiliate_claim', 'late_cancellation', 'deposit_paid', 'edit_request', 'edit_requested', 'new_booking', 'deposit_not_paid_by_deadline', 'gift_card_purchased_for_friend', 'default_hours_changed');
|
||||
|
||||
CREATE TABLE admin_notifications (
|
||||
id CHAR(12) PRIMARY KEY DEFAULT generate_admin_notifications_id(),
|
||||
|
||||
Reference in New Issue
Block a user