feat: allow bookings.status to be marked completed

This commit is contained in:
belviskhoremk
2026-08-12 10:51:17 +02:00
parent acc4b02a20
commit bcc606db28
2 changed files with 18 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
-- Widen the bookings.status check constraint to allow 'completed', so the
-- admin panel can mark past appointments completed (not just cancelled).
alter table public.bookings drop constraint bookings_status_check;
alter table public.bookings add constraint bookings_status_check
check (status in ('confirmed', 'cancelled', 'completed'));

View File

@@ -1,5 +1,5 @@
begin; begin;
select plan(15); select plan(17);
-- Seed reference data as service_role (bypasses RLS) -- Seed reference data as service_role (bypasses RLS)
set local role service_role; set local role service_role;
@@ -123,5 +123,17 @@ select lives_ok(
'admin can upload to salon-images' 'admin can upload to salon-images'
); );
select lives_ok(
$$ update public.bookings set status = 'completed' where service_id = 'knotless' $$,
'admin can mark a booking completed'
);
select throws_ok(
$$ update public.bookings set status = 'bogus' where service_id = 'knotless' $$,
'23514',
null,
'booking status is still constrained to known values'
);
select * from finish(); select * from finish();
rollback; rollback;