fix edit requests
This commit is contained in:
@@ -241,37 +241,18 @@ CREATE TABLE booking_edit_requests (
|
||||
booking_id CHAR(12) NOT NULL REFERENCES bookings(id) ON DELETE CASCADE,
|
||||
requested_by CHAR(12) NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
new_start_time TIMESTAMPTZ,
|
||||
new_services JSONB DEFAULT '[]'::jsonb, -- Array of service IDs to replace booking_services
|
||||
new_services CHAR(12)[] DEFAULT '{}', -- Array of service IDs to replace booking_services
|
||||
notes TEXT,
|
||||
has_overrides BOOLEAN NOT NULL DEFAULT FALSE, -- If TRUE, cannot change services, use existing overrides for duration
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT chk_at_least_one_field CHECK (
|
||||
new_start_time IS NOT NULL OR
|
||||
new_services IS NOT NULL OR
|
||||
array_length(new_services, 1) IS NOT NULL OR
|
||||
notes IS NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_booking_edit_requests_booking ON booking_edit_requests(booking_id);
|
||||
id CHAR(12) PRIMARY KEY DEFAULT generate_booking_id(),
|
||||
booking_id CHAR(12) NOT NULL REFERENCES bookings(id) ON DELETE CASCADE,
|
||||
requested_by CHAR(12) NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
new_start_time TIMESTAMPTZ,
|
||||
new_services JSONB DEFAULT '[]'::jsonb,
|
||||
new_notes TEXT,
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'pending',
|
||||
admin_notes TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT chk_at_least_one_field CHECK (
|
||||
new_start_time IS NOT NULL OR
|
||||
new_services IS NOT NULL OR
|
||||
new_notes IS NOT NULL
|
||||
)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_booking_edit_requests_booking ON booking_edit_requests(booking_id);
|
||||
CREATE INDEX idx_booking_edit_requests_status ON booking_edit_requests(status);
|
||||
|
||||
CREATE TABLE user_referrals (
|
||||
referrer_id CHAR(12) NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user