Merge branch 'develop' into MED-97

This commit is contained in:
2025-09-26 17:01:24 +03:00
86 changed files with 11249 additions and 3151 deletions

View File

@@ -0,0 +1,14 @@
select
cron.schedule(
'sync-connected-online-every-night', -- Unique job name
'0 1 * * *', -- Cron schedule: every night at 04:00 (GMT +3)
$$
select
net.http_post(
url := 'https://test.medreport.ee/api/job/sync-connected-online',
headers := jsonb_build_object(
'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
)
) as request_id;
$$
);

View File

@@ -0,0 +1,11 @@
ALTER TABLE medreport.connected_online_providers ADD COLUMN key text not null DEFAULT ''; -- avoid conflict with already existing data, will be filled on next sync
ALTER TABLE medreport.connected_online_providers
ALTER key DROP DEFAULT;
ALTER TABLE medreport.connected_online_providers ADD COLUMN address text not null DEFAULT '';
ALTER TABLE medreport.connected_online_providers
ALTER key DROP DEFAULT;
ALTER TABLE medreport.connected_online_services
ALTER COLUMN sync_id TYPE bigint
USING sync_id::bigint;

View File

@@ -0,0 +1,60 @@
create table "medreport"."connected_online_service_providers" (
"id" bigint not null primary key,
"name" text not null,
"spoken_languages" text[],
"prefix" text,
"job_title_et" text,
"job_title_en" text,
"job_title_ru" text,
"clinic_id" bigint not null REFERENCES medreport.connected_online_providers(id),
"job_title_id" bigint,
"is_deleted" boolean,
"created_at" timestamp with time zone not null default now(),
"updated_at" timestamp without time zone default now()
);
ALTER TABLE audit.request_entries
DROP COLUMN personal_code;
ALTER TABLE audit.request_entries ADD COLUMN user_id uuid default auth.uid();
create policy "insert_own"
on "audit"."request_entries"
as permissive
for insert
to authenticated
with check ((( SELECT auth.uid() AS uid) = user_id));
alter table "medreport"."connected_online_service_providers" enable row level security;
create policy "service_role_all"
on "medreport"."connected_online_service_providers"
as permissive
for all
to service_role
using (true);
grant delete on table "medreport"."connected_online_service_providers" to "service_role";
grant insert on table "medreport"."connected_online_service_providers" to "service_role";
grant references on table "medreport"."connected_online_service_providers" to "service_role";
grant select on table "medreport"."connected_online_service_providers" to "service_role";
grant trigger on table "medreport"."connected_online_service_providers" to "service_role";
grant truncate on table "medreport"."connected_online_service_providers" to "service_role";
grant update on table "medreport"."connected_online_service_providers" to "service_role";
grant select on table "medreport"."connected_online_service_providers" to "authenticated";
create policy "authenticated_select"
on "medreport"."connected_online_service_providers"
as permissive
for select
to authenticated
using (true);

View File

@@ -0,0 +1,14 @@
ALTER TABLE medreport.connected_online_reservation
ADD COLUMN medusa_cart_line_item_id TEXT references public.cart_line_item(id);
ALTER TABLE medreport.connected_online_reservation
ADD COLUMN location_sync_id bigint;
create type medreport.connected_online_order_status as enum ('PENDING', 'CONFIRMED', 'REJECTED', 'CANCELLED');
ALTER TABLE medreport.connected_online_reservation
ADD COLUMN status medreport.connected_online_order_status not null;
ALTER TABLE medreport.connected_online_reservation ALTER COLUMN booking_code DROP NOT NULL;
ALTER TABLE medreport.connected_online_reservation ALTER COLUMN requires_payment DROP NOT NULL;
ALTER TABLE medreport.connected_online_reservation ALTER COLUMN service_user_id SET NOT NULL;

View File

@@ -0,0 +1,43 @@
create table "medreport"."connected_online_locations" (
"id" bigint generated by default as identity not null,
"sync_id" bigint not null,
"name" text not null,
"address" text,
"clinic_id" bigint not null REFERENCES medreport.connected_online_providers(id),
"created_at" timestamp with time zone not null default now(),
"updated_at" timestamp without time zone default now()
);
alter table "medreport"."connected_online_locations" enable row level security;
create policy "service_role_all"
on "medreport"."connected_online_locations"
as permissive
for all
to service_role
using (true);
grant delete on table "medreport"."connected_online_locations" to "service_role";
grant insert on table "medreport"."connected_online_locations" to "service_role";
grant references on table "medreport"."connected_online_locations" to "service_role";
grant select on table "medreport"."connected_online_locations" to "service_role";
grant trigger on table "medreport"."connected_online_locations" to "service_role";
grant truncate on table "medreport"."connected_online_locations" to "service_role";
grant update on table "medreport"."connected_online_locations" to "service_role";
grant select on table "medreport"."connected_online_locations" to "authenticated";
create policy "authenticated_select"
on "medreport"."connected_online_locations"
as permissive
for select
to authenticated
using (true);

View File

@@ -0,0 +1,12 @@
ALTER TABLE medreport.connected_online_reservation
ADD CONSTRAINT fk_reservation_clinic
FOREIGN KEY (clinic_id)
REFERENCES medreport.connected_online_providers(id);
ALTER TABLE medreport.connected_online_services
ADD CONSTRAINT constraint_name UNIQUE (sync_id);
ALTER TABLE medreport.connected_online_reservation
ADD CONSTRAINT fk_reservation_service
FOREIGN KEY (service_id)
REFERENCES medreport.connected_online_services(id);