@fayz-ai/plugin-scribe 0.14.11 → 0.14.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ // node_modules/.cache/fayz-migration-stubs/main.ts
2
+ var MIGRATION_000_BASELINE = "";
3
+ var MIGRATIONS = [];
4
+
5
+ export { MIGRATIONS, MIGRATION_000_BASELINE };
6
+ //# sourceMappingURL=main.browser.js.map
7
+ //# sourceMappingURL=main.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../node_modules/.cache/fayz-migration-stubs/main.ts"],"names":[],"mappings":";AAEO,IAAM,sBAAA,GAAyB;AAC/B,IAAM,aAAiD","file":"main.browser.js","sourcesContent":["// GENERATED by scripts/tsup-migrations.mjs — the browser build of a\n// migrations barrel: the same names, no SQL. See that script for why.\nexport const MIGRATION_000_BASELINE = ''\nexport const MIGRATIONS: Array<{ id: string; sql: string }> = []\n"]}
@@ -0,0 +1,575 @@
1
+ // src/migrations/index.ts
2
+ var MIGRATION_000_BASELINE = `-- ============================================================================
3
+ -- plugins/plugin-scribe/src/migrations/000_baseline.sql \u2014 what installing this provisions, as one file.
4
+ --
5
+ -- GENERATED by scripts/emit-unit-baselines.mjs (#338). Do not edit by hand:
6
+ -- change the schema, regenerate, and let scripts/check-chain-equivalence.mjs
7
+ -- prove the result still matches.
8
+ --
9
+ -- This replaced 3 migration files. They are kept, unapplied, in
10
+ -- migrations.archive/ \u2014 a year of decisions is worth reading even when it is no
11
+ -- longer worth replaying.
12
+ --
13
+ -- Object order is fixed rather than dependency-sorted: schemas, types,
14
+ -- sequences, tables, defaults, functions, constraints, views, indexes, foreign
15
+ -- keys, triggers, row security, policies, grants. Dependencies BETWEEN units
16
+ -- are carried by the order packages/db/chain.json declares.
17
+ -- ============================================================================
18
+
19
+ -- A LANGUAGE sql function binds its body at CREATE time, and 570 functions
20
+ -- sorted by name are not sorted by who calls whom. This is what lets them load
21
+ -- in any order; every body is still compiled on first call, so a genuinely
22
+ -- broken reference surfaces then rather than never. Session-scoped.
23
+ SET check_function_bodies = false;
24
+
25
+
26
+
27
+ -- \u2500\u2500 default privileges: reset \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
28
+ -- Cleared BEFORE anything is created, so every object below gets the ACL the
29
+ -- dump describes rather than the image's defaults on top of it. Restored at
30
+ -- the end of this file.
31
+
32
+ DO $dp$ BEGIN
33
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
34
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
35
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
36
+ END $dp$;
37
+
38
+ DO $dp$ BEGIN
39
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
40
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
41
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
42
+ END $dp$;
43
+
44
+ DO $dp$ BEGIN
45
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
46
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
47
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
48
+ END $dp$;
49
+
50
+ DO $dp$ BEGIN
51
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
52
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
53
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
54
+ END $dp$;
55
+
56
+ DO $dp$ BEGIN
57
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
58
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
59
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
60
+ END $dp$;
61
+
62
+ DO $dp$ BEGIN
63
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
64
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
65
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
66
+ END $dp$;
67
+
68
+
69
+ -- \u2500\u2500 table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
70
+
71
+ CREATE TABLE public.plg_scribe_generations (
72
+ id uuid DEFAULT gen_random_uuid() NOT NULL,
73
+ tenant_id uuid NOT NULL,
74
+ session_id uuid NOT NULL,
75
+ template_id uuid,
76
+ template_key text,
77
+ tab_order integer DEFAULT 0 NOT NULL,
78
+ title text,
79
+ status text DEFAULT 'pending'::text NOT NULL,
80
+ markdown text,
81
+ markdown_edited text,
82
+ facts jsonb,
83
+ model text,
84
+ prompt_version text,
85
+ input_tokens integer,
86
+ output_tokens integer,
87
+ error text,
88
+ document_id uuid,
89
+ created_by uuid,
90
+ created_at timestamp with time zone DEFAULT now() NOT NULL,
91
+ updated_at timestamp with time zone DEFAULT now() NOT NULL,
92
+ CONSTRAINT plg_scribe_generations_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'running'::text, 'ready'::text, 'failed'::text, 'committed'::text, 'discarded'::text])))
93
+ );
94
+
95
+ CREATE TABLE public.plg_scribe_segments (
96
+ session_id uuid NOT NULL,
97
+ seg_index integer NOT NULL,
98
+ tenant_id uuid NOT NULL,
99
+ storage_path text,
100
+ bytes integer,
101
+ start_offset_ms integer NOT NULL,
102
+ duration_ms integer,
103
+ partial boolean DEFAULT false NOT NULL,
104
+ gap boolean DEFAULT false NOT NULL,
105
+ upload_state text DEFAULT 'pending'::text NOT NULL,
106
+ uploaded_at timestamp with time zone,
107
+ stt_state text DEFAULT 'pending'::text NOT NULL,
108
+ stt_provider text,
109
+ stt_attempts smallint DEFAULT 0 NOT NULL,
110
+ stt_error text,
111
+ text text,
112
+ words jsonb,
113
+ confidence real,
114
+ created_at timestamp with time zone DEFAULT now() NOT NULL,
115
+ updated_at timestamp with time zone DEFAULT now() NOT NULL,
116
+ CONSTRAINT plg_scribe_segments_stt_state_check CHECK ((stt_state = ANY (ARRAY['pending'::text, 'running'::text, 'done'::text, 'failed'::text, 'skipped'::text]))),
117
+ CONSTRAINT plg_scribe_segments_upload_state_check CHECK ((upload_state = ANY (ARRAY['pending'::text, 'uploaded'::text, 'missing'::text])))
118
+ );
119
+
120
+ CREATE TABLE public.plg_scribe_sessions (
121
+ id uuid NOT NULL,
122
+ tenant_id uuid NOT NULL,
123
+ subject_id uuid,
124
+ context_kind text DEFAULT 'person'::text NOT NULL,
125
+ appointment_id uuid,
126
+ owner_user_id uuid NOT NULL,
127
+ status text DEFAULT 'recording'::text NOT NULL,
128
+ locale text DEFAULT 'pt-BR'::text NOT NULL,
129
+ mime_type text,
130
+ started_at timestamp with time zone DEFAULT now() NOT NULL,
131
+ ended_at timestamp with time zone,
132
+ wall_duration_ms integer DEFAULT 0 NOT NULL,
133
+ audio_duration_ms integer DEFAULT 0 NOT NULL,
134
+ segment_count integer DEFAULT 0 NOT NULL,
135
+ uploaded_segment_count integer DEFAULT 0 NOT NULL,
136
+ transcribed_segment_count integer DEFAULT 0 NOT NULL,
137
+ transcript_chars integer DEFAULT 0 NOT NULL,
138
+ consent_at timestamp with time zone,
139
+ consent_mode text,
140
+ retention_until date,
141
+ audio_deleted_at timestamp with time zone,
142
+ error text,
143
+ metadata jsonb DEFAULT '{}'::jsonb NOT NULL,
144
+ created_at timestamp with time zone DEFAULT now() NOT NULL,
145
+ updated_at timestamp with time zone DEFAULT now() NOT NULL,
146
+ CONSTRAINT plg_scribe_sessions_consent_mode_check CHECK ((consent_mode = ANY (ARRAY['verbal'::text, 'written'::text, 'implied_contract'::text]))),
147
+ CONSTRAINT plg_scribe_sessions_context_kind_check CHECK ((context_kind = ANY (ARRAY['person'::text, 'appointment'::text, 'standalone'::text]))),
148
+ CONSTRAINT plg_scribe_sessions_status_check CHECK ((status = ANY (ARRAY['recording'::text, 'paused'::text, 'interrupted'::text, 'uploading'::text, 'transcribing'::text, 'ready'::text, 'generating'::text, 'completed'::text, 'abandoned'::text, 'failed'::text])))
149
+ );
150
+
151
+
152
+ -- \u2500\u2500 function \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
153
+
154
+ CREATE FUNCTION public.scribe_audio_path_ok(p_name text) RETURNS boolean
155
+ LANGUAGE sql STABLE SECURITY DEFINER
156
+ SET search_path TO 'public'
157
+ AS $_$
158
+ SELECT
159
+ p_name IS NOT NULL
160
+ AND length(p_name) <= 200
161
+ AND p_name ~ ('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
162
+ || '/[0-9]{4}/[0-9]{2}'
163
+ || '/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
164
+ || '/[0-9]{5}\\.(webm|ogg|m4a|mp3)$')
165
+ -- compara\xE7\xE3o em texto (nunca \`::uuid\`): entrada malformada devolve falso em
166
+ -- vez de derrubar a policy com erro de cast.
167
+ AND EXISTS (
168
+ SELECT 1 FROM public.tenants t WHERE t.id::text = split_part(p_name, '/', 1)
169
+ );
170
+ $_$;
171
+
172
+ CREATE FUNCTION public.scribe_record_segment(p_payload jsonb) RETURNS jsonb
173
+ LANGUAGE plpgsql
174
+ SET search_path TO 'public'
175
+ AS $$
176
+ DECLARE
177
+ v_session_id uuid;
178
+ v_seg_index integer;
179
+ v_tenant_id uuid;
180
+ v_result jsonb;
181
+ BEGIN
182
+ v_session_id := (p_payload->>'session_id')::uuid;
183
+ v_seg_index := (p_payload->>'seg_index')::integer;
184
+
185
+ IF v_session_id IS NULL OR v_seg_index IS NULL THEN
186
+ RAISE EXCEPTION 'session_id and seg_index are required';
187
+ END IF;
188
+
189
+ -- O tenant vem da SESS\xC3O, nunca do payload. Se o cliente pudesse informar o
190
+ -- tenant, ele escolheria em que pasta escrever.
191
+ SELECT s.tenant_id INTO v_tenant_id
192
+ FROM plg_scribe_sessions s WHERE s.id = v_session_id;
193
+
194
+ IF v_tenant_id IS NULL THEN
195
+ -- Sess\xE3o inexistente OU invis\xEDvel pela RLS: a mesma resposta nos dois
196
+ -- casos, de prop\xF3sito \u2014 n\xE3o vaza a exist\xEAncia de sess\xE3o de outro tenant.
197
+ RAISE EXCEPTION 'unknown session';
198
+ END IF;
199
+
200
+ INSERT INTO plg_scribe_segments (
201
+ session_id, seg_index, tenant_id, storage_path, bytes,
202
+ start_offset_ms, duration_ms, partial, gap, upload_state, uploaded_at, stt_state
203
+ ) VALUES (
204
+ v_session_id, v_seg_index, v_tenant_id,
205
+ p_payload->>'storage_path',
206
+ (p_payload->>'bytes')::integer,
207
+ COALESCE((p_payload->>'start_offset_ms')::integer, 0),
208
+ (p_payload->>'duration_ms')::integer,
209
+ COALESCE((p_payload->>'partial')::boolean, false),
210
+ COALESCE((p_payload->>'gap')::boolean, false),
211
+ CASE WHEN COALESCE((p_payload->>'gap')::boolean, false) THEN 'missing' ELSE 'uploaded' END,
212
+ now(),
213
+ -- Buraco n\xE3o vai para o STT: n\xE3o h\xE1 \xE1udio para transcrever, e mand\xE1-lo
214
+ -- queimaria uma chamada para receber string vazia.
215
+ CASE WHEN COALESCE((p_payload->>'gap')::boolean, false) THEN 'skipped' ELSE 'pending' END
216
+ )
217
+ ON CONFLICT (session_id, seg_index) DO UPDATE SET
218
+ storage_path = COALESCE(EXCLUDED.storage_path, plg_scribe_segments.storage_path),
219
+ bytes = COALESCE(EXCLUDED.bytes, plg_scribe_segments.bytes),
220
+ duration_ms = COALESCE(EXCLUDED.duration_ms, plg_scribe_segments.duration_ms),
221
+ partial = EXCLUDED.partial,
222
+ upload_state = EXCLUDED.upload_state,
223
+ uploaded_at = COALESCE(plg_scribe_segments.uploaded_at, EXCLUDED.uploaded_at),
224
+ updated_at = now();
225
+
226
+ -- Contadores derivados. \`audio_duration_ms\` soma s\xF3 o que tem dura\xE7\xE3o medida,
227
+ -- ent\xE3o um segmento que ainda n\xE3o voltou do STT n\xE3o infla o total.
228
+ UPDATE plg_scribe_sessions s SET
229
+ segment_count = agg.total,
230
+ uploaded_segment_count = agg.uploaded,
231
+ transcribed_segment_count = agg.transcribed,
232
+ audio_duration_ms = agg.audio_ms,
233
+ transcript_chars = agg.chars,
234
+ updated_at = now()
235
+ FROM (
236
+ SELECT
237
+ count(*)::int AS total,
238
+ count(*) FILTER (WHERE upload_state = 'uploaded')::int AS uploaded,
239
+ count(*) FILTER (WHERE stt_state = 'done')::int AS transcribed,
240
+ COALESCE(sum(duration_ms) FILTER (WHERE NOT gap), 0)::int AS audio_ms,
241
+ COALESCE(sum(length(text)), 0)::int AS chars
242
+ FROM plg_scribe_segments WHERE session_id = v_session_id
243
+ ) agg
244
+ WHERE s.id = v_session_id;
245
+
246
+ SELECT to_jsonb(x) INTO v_result FROM (
247
+ SELECT s.segment_count, s.uploaded_segment_count,
248
+ s.transcribed_segment_count, s.audio_duration_ms, s.status
249
+ FROM plg_scribe_sessions s WHERE s.id = v_session_id
250
+ ) x;
251
+
252
+ RETURN v_result;
253
+ END;
254
+ $$;
255
+
256
+
257
+ -- \u2500\u2500 constraint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
258
+
259
+ ALTER TABLE ONLY public.plg_scribe_generations
260
+ ADD CONSTRAINT plg_scribe_generations_pkey PRIMARY KEY (id);
261
+
262
+ ALTER TABLE ONLY public.plg_scribe_segments
263
+ ADD CONSTRAINT plg_scribe_segments_pkey PRIMARY KEY (session_id, seg_index);
264
+
265
+ ALTER TABLE ONLY public.plg_scribe_sessions
266
+ ADD CONSTRAINT plg_scribe_sessions_pkey PRIMARY KEY (id);
267
+
268
+
269
+ -- \u2500\u2500 view \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
270
+
271
+ CREATE VIEW public.v_scribe_generations WITH (security_invoker='true') AS
272
+ SELECT g.id,
273
+ g.tenant_id,
274
+ g.session_id,
275
+ g.template_id,
276
+ g.template_key,
277
+ g.tab_order,
278
+ g.title,
279
+ g.status,
280
+ g.markdown,
281
+ g.markdown_edited,
282
+ g.facts,
283
+ g.model,
284
+ g.prompt_version,
285
+ g.input_tokens,
286
+ g.output_tokens,
287
+ g.error,
288
+ g.document_id,
289
+ g.created_by,
290
+ g.created_at,
291
+ g.updated_at,
292
+ (t.id IS NOT NULL) AS template_exists,
293
+ t.name AS template_name
294
+ FROM (public.plg_scribe_generations g
295
+ LEFT JOIN public.plg_forms_templates t ON ((t.id = g.template_id)));
296
+
297
+
298
+ -- \u2500\u2500 index \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
299
+
300
+ CREATE INDEX idx_plg_scribe_generations_session ON public.plg_scribe_generations USING btree (session_id, tab_order);
301
+
302
+ CREATE INDEX idx_plg_scribe_generations_tenant ON public.plg_scribe_generations USING btree (tenant_id);
303
+
304
+ CREATE INDEX idx_plg_scribe_segments_stt_queue ON public.plg_scribe_segments USING btree (tenant_id, stt_state, created_at) WHERE ((upload_state = 'uploaded'::text) AND (stt_state = ANY (ARRAY['pending'::text, 'failed'::text])));
305
+
306
+ CREATE INDEX idx_plg_scribe_segments_tenant ON public.plg_scribe_segments USING btree (tenant_id);
307
+
308
+ CREATE INDEX idx_plg_scribe_sessions_appointment ON public.plg_scribe_sessions USING btree (appointment_id) WHERE (appointment_id IS NOT NULL);
309
+
310
+ CREATE INDEX idx_plg_scribe_sessions_open ON public.plg_scribe_sessions USING btree (tenant_id, owner_user_id, status) WHERE (status = ANY (ARRAY['recording'::text, 'paused'::text, 'interrupted'::text, 'uploading'::text, 'transcribing'::text, 'ready'::text, 'generating'::text]));
311
+
312
+ CREATE INDEX idx_plg_scribe_sessions_retention ON public.plg_scribe_sessions USING btree (retention_until) WHERE ((audio_deleted_at IS NULL) AND (retention_until IS NOT NULL));
313
+
314
+ CREATE INDEX idx_plg_scribe_sessions_subject ON public.plg_scribe_sessions USING btree (subject_id) WHERE (subject_id IS NOT NULL);
315
+
316
+ CREATE INDEX idx_plg_scribe_sessions_tenant ON public.plg_scribe_sessions USING btree (tenant_id);
317
+
318
+
319
+ -- \u2500\u2500 fk constraint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
320
+
321
+ ALTER TABLE ONLY public.plg_scribe_generations
322
+ ADD CONSTRAINT plg_scribe_generations_document_fk FOREIGN KEY (document_id) REFERENCES public.documents(id) ON DELETE SET NULL;
323
+
324
+ ALTER TABLE ONLY public.plg_scribe_generations
325
+ ADD CONSTRAINT plg_scribe_generations_session_id_fkey FOREIGN KEY (session_id) REFERENCES public.plg_scribe_sessions(id) ON DELETE CASCADE;
326
+
327
+ ALTER TABLE ONLY public.plg_scribe_generations
328
+ ADD CONSTRAINT plg_scribe_generations_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
329
+
330
+ ALTER TABLE ONLY public.plg_scribe_segments
331
+ ADD CONSTRAINT plg_scribe_segments_session_id_fkey FOREIGN KEY (session_id) REFERENCES public.plg_scribe_sessions(id) ON DELETE CASCADE;
332
+
333
+ ALTER TABLE ONLY public.plg_scribe_segments
334
+ ADD CONSTRAINT plg_scribe_segments_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
335
+
336
+ ALTER TABLE ONLY public.plg_scribe_sessions
337
+ ADD CONSTRAINT plg_scribe_sessions_appointment_id_fkey FOREIGN KEY (appointment_id) REFERENCES public.appointments(id) ON DELETE SET NULL;
338
+
339
+ ALTER TABLE ONLY public.plg_scribe_sessions
340
+ ADD CONSTRAINT plg_scribe_sessions_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES public.people(id) ON DELETE SET NULL;
341
+
342
+ ALTER TABLE ONLY public.plg_scribe_sessions
343
+ ADD CONSTRAINT plg_scribe_sessions_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
344
+
345
+
346
+ -- \u2500\u2500 row security \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
347
+
348
+ ALTER TABLE public.plg_scribe_generations ENABLE ROW LEVEL SECURITY;
349
+
350
+ ALTER TABLE public.plg_scribe_segments ENABLE ROW LEVEL SECURITY;
351
+
352
+ ALTER TABLE public.plg_scribe_sessions ENABLE ROW LEVEL SECURITY;
353
+
354
+
355
+ -- \u2500\u2500 policy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
356
+
357
+ CREATE POLICY plg_scribe_generations_delete ON public.plg_scribe_generations FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
358
+
359
+ CREATE POLICY plg_scribe_generations_insert ON public.plg_scribe_generations FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
360
+
361
+ CREATE POLICY plg_scribe_generations_select ON public.plg_scribe_generations FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
362
+
363
+ CREATE POLICY plg_scribe_generations_update ON public.plg_scribe_generations FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
364
+
365
+ CREATE POLICY plg_scribe_segments_delete ON public.plg_scribe_segments FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
366
+
367
+ CREATE POLICY plg_scribe_segments_insert ON public.plg_scribe_segments FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
368
+
369
+ CREATE POLICY plg_scribe_segments_select ON public.plg_scribe_segments FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
370
+
371
+ CREATE POLICY plg_scribe_segments_update ON public.plg_scribe_segments FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
372
+
373
+ CREATE POLICY plg_scribe_sessions_delete ON public.plg_scribe_sessions FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
374
+
375
+ CREATE POLICY plg_scribe_sessions_insert ON public.plg_scribe_sessions FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
376
+
377
+ CREATE POLICY plg_scribe_sessions_select ON public.plg_scribe_sessions FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
378
+
379
+ CREATE POLICY plg_scribe_sessions_update ON public.plg_scribe_sessions FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
380
+
381
+
382
+ -- \u2500\u2500 acl \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
383
+
384
+ GRANT ALL ON FUNCTION public.scribe_audio_path_ok(p_name text) TO authenticated;
385
+ GRANT ALL ON FUNCTION public.scribe_audio_path_ok(p_name text) TO service_role;
386
+
387
+ GRANT ALL ON FUNCTION public.scribe_record_segment(p_payload jsonb) TO authenticated;
388
+ GRANT ALL ON FUNCTION public.scribe_record_segment(p_payload jsonb) TO service_role;
389
+
390
+ GRANT MAINTAIN ON TABLE public.plg_scribe_generations TO anon;
391
+ GRANT ALL ON TABLE public.plg_scribe_generations TO authenticated;
392
+ GRANT ALL ON TABLE public.plg_scribe_generations TO service_role;
393
+
394
+ GRANT MAINTAIN ON TABLE public.plg_scribe_segments TO anon;
395
+ GRANT ALL ON TABLE public.plg_scribe_segments TO authenticated;
396
+ GRANT ALL ON TABLE public.plg_scribe_segments TO service_role;
397
+
398
+ GRANT MAINTAIN ON TABLE public.plg_scribe_sessions TO anon;
399
+ GRANT ALL ON TABLE public.plg_scribe_sessions TO authenticated;
400
+ GRANT ALL ON TABLE public.plg_scribe_sessions TO service_role;
401
+
402
+ GRANT MAINTAIN ON TABLE public.v_scribe_generations TO anon;
403
+ GRANT ALL ON TABLE public.v_scribe_generations TO authenticated;
404
+ GRANT ALL ON TABLE public.v_scribe_generations TO service_role;
405
+
406
+
407
+ -- \u2500\u2500 comment \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
408
+
409
+ COMMENT ON FUNCTION public.scribe_audio_path_ok(p_name text) IS 'True when a storage object name follows the scribe-audio grammar {tenant}/{yyyy}/{mm}/{session}/{segIndex}.{ext} and segment 1 is a real tenant. Used by the INSERT policy on that bucket.';
410
+
411
+ COMMENT ON FUNCTION public.scribe_record_segment(p_payload jsonb) IS 'Idempotent upsert of one audio segment + recomputation of the parent session counters from the segments table. Called by the browser upload pump after each successful Storage write.';
412
+
413
+ COMMENT ON COLUMN public.plg_scribe_generations.template_id IS 'The forms template this generation came from, by id and not by foreign key (003, ADR 0015). A soft reference on purpose: forms owns that table and must be able to release it without scribe''s permission. A row whose template is gone reads as absent, which is what the old ON DELETE SET NULL was arranging.';
414
+
415
+ COMMENT ON VIEW public.v_scribe_generations IS 'Generations with their forms template resolved by LEFT JOIN rather than by foreign key (003). \`template_exists\` is the honest answer on a cluster where forms is not installed, or where the template was deleted.';
416
+
417
+
418
+ -- \u2500\u2500 default privileges: restore \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
419
+ -- Put back, so the NEXT thing installed inherits what the chain had.
420
+
421
+ DO $dp$ BEGIN
422
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
423
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
424
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
425
+ END $dp$;
426
+
427
+ DO $dp$ BEGIN
428
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
429
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
430
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
431
+ END $dp$;
432
+
433
+ DO $dp$ BEGIN
434
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
435
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
436
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
437
+ END $dp$;
438
+
439
+ DO $dp$ BEGIN
440
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
441
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
442
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
443
+ END $dp$;
444
+
445
+ DO $dp$ BEGIN
446
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
447
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
448
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
449
+ END $dp$;
450
+
451
+ DO $dp$ BEGIN
452
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
453
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
454
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
455
+ END $dp$;
456
+
457
+ DO $dp$ BEGIN
458
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
459
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
460
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
461
+ END $dp$;
462
+
463
+ DO $dp$ BEGIN
464
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
465
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
466
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
467
+ END $dp$;
468
+
469
+ DO $dp$ BEGIN
470
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
471
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
472
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
473
+ END $dp$;
474
+
475
+ DO $dp$ BEGIN
476
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
477
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
478
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
479
+ END $dp$;
480
+
481
+ DO $dp$ BEGIN
482
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
483
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
484
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
485
+ END $dp$;
486
+
487
+ DO $dp$ BEGIN
488
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
489
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
490
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
491
+ END $dp$;
492
+
493
+ DO $dp$ BEGIN
494
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon$stmt$;
495
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
496
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon$stmt$;
497
+ END $dp$;
498
+
499
+ DO $dp$ BEGIN
500
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
501
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
502
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
503
+ END $dp$;
504
+
505
+ DO $dp$ BEGIN
506
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
507
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
508
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
509
+ END $dp$;
510
+
511
+ DO $dp$ BEGIN
512
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
513
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
514
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
515
+ END $dp$;
516
+
517
+ DO $dp$ BEGIN
518
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT MAINTAIN ON TABLES TO anon$stmt$;
519
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
520
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT MAINTAIN ON TABLES TO anon$stmt$;
521
+ END $dp$;
522
+
523
+ DO $dp$ BEGIN
524
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
525
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
526
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
527
+ END $dp$;
528
+
529
+ DO $dp$ BEGIN
530
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
531
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
532
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
533
+ END $dp$;
534
+
535
+ DO $dp$ BEGIN
536
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
537
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
538
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
539
+ END $dp$;
540
+
541
+ DO $dp$ BEGIN
542
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon$stmt$;
543
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
544
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon$stmt$;
545
+ END $dp$;
546
+
547
+ DO $dp$ BEGIN
548
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
549
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
550
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
551
+ END $dp$;
552
+
553
+ DO $dp$ BEGIN
554
+ EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
555
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
556
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
557
+ END $dp$;
558
+
559
+ DO $dp$ BEGIN
560
+ EXECUTE $stmt$--
561
+ -- PostgreSQL database dump complete
562
+ --$stmt$;
563
+ EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
564
+ RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$--
565
+ -- PostgreSQL database dump complete
566
+ --$stmt$;
567
+ END $dp$;
568
+ `;
569
+ var MIGRATIONS = [
570
+ { id: "000_baseline", sql: MIGRATION_000_BASELINE }
571
+ ];
572
+
573
+ export { MIGRATIONS, MIGRATION_000_BASELINE };
574
+ //# sourceMappingURL=main.js.map
575
+ //# sourceMappingURL=main.js.map