@nextblock-cms/db 0.11.2 → 0.12.0
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.
- package/lib/supabase/server.d.ts +9 -0
- package/lib/supabase/types.d.ts +9 -0
- package/package.json +1 -1
- package/supabase/migrations/00000000000000_baseline_schema.sql +2454 -0
- package/supabase/migrations/00000000000001_baseline_constraints_and_indexes.sql +1071 -0
- package/supabase/migrations/00000000000002_baseline_security_and_grants.sql +1335 -0
- package/supabase/migrations/00000000000003_baseline_seed.sql +468 -0
- package/supabase/migrations/00000000000004_default_logo_email_safe.sql +24 -0
- package/supabase/migrations/00000000000005_add_custom_canonical.sql +13 -0
- package/supabase/migrations/00000000000006_home_live_demo_promo.sql +67 -0
- package/supabase/templates/confirmation.html +1 -1
- package/supabase/templates/email_change.html +1 -1
- package/supabase/templates/invite.html +1 -1
- package/supabase/templates/magic_link.html +1 -1
- package/supabase/templates/reauthentication.html +1 -1
- package/supabase/templates/recovery.html +1 -1
- package/supabase/migrations/00000000000000_setup_foundation_and_enums.sql +0 -40
- package/supabase/migrations/00000000000001_setup_cms_core.sql +0 -124
- package/supabase/migrations/00000000000002_setup_content_tables.sql +0 -138
- package/supabase/migrations/00000000000003_setup_catalog_and_licensing.sql +0 -160
- package/supabase/migrations/00000000000004_setup_fulfillment_shipping_taxes_and_currencies.sql +0 -797
- package/supabase/migrations/00000000000005_setup_functions_and_triggers.sql +0 -767
- package/supabase/migrations/00000000000006_setup_rls_and_grants.sql +0 -872
- package/supabase/migrations/00000000000007_setup_indexes.sql +0 -158
- package/supabase/migrations/00000000000008_seed_platform_defaults.sql +0 -155
- package/supabase/migrations/00000000000009_seed_translations.sql +0 -801
- package/supabase/migrations/00000000000010_seed_content_scaffold.sql +0 -1088
- package/supabase/migrations/00000000000011_setup_cortex_ai_settings.sql +0 -81
- package/supabase/migrations/00000000000012_setup_commerce_coupons.sql +0 -275
- package/supabase/migrations/00000000000013_setup_cortex_ai_db_mutation_audit.sql +0 -47
- package/supabase/migrations/00000000000014_setup_content_drafts.sql +0 -119
- package/supabase/migrations/00000000000015_setup_product_drafts.sql +0 -97
- package/supabase/migrations/00000000000016_add_feature_image_to_pages.sql +0 -8
- package/supabase/migrations/00000000000017_add_product_blocks.sql +0 -118
- package/supabase/migrations/00000000000018_setup_bot_protection_settings.sql +0 -77
- package/supabase/migrations/00000000000019_add_product_categories.sql +0 -64
- package/supabase/migrations/00000000000020_add_category_translations.sql +0 -10
- package/supabase/migrations/00000000000021_migrate_hero_blocks_to_sections.sql +0 -29
- package/supabase/migrations/00000000000022_seed_cortex_ai_guide_post.sql +0 -184
- package/supabase/migrations/00000000000023_setup_custom_block_definitions.sql +0 -183
- package/supabase/migrations/00000000000024_setup_ucp_cart_sessions.sql +0 -72
- package/supabase/migrations/00000000000025_add_sale_schedule_columns.sql +0 -406
- package/supabase/migrations/00000000000026_seed_on_sale_translation.sql +0 -9
- package/supabase/migrations/00000000000027_setup_privacy_and_mfa.sql +0 -479
- package/supabase/migrations/00000000000028_clear_advisor_warnings.sql +0 -93
- package/supabase/migrations/00000000000029_refresh_setup_article.sql +0 -252
- package/supabase/migrations/00000000000030_setup_system_configuration.sql +0 -80
- package/supabase/migrations/00000000000031_seed_footer_navigation.sql +0 -85
- package/supabase/migrations/00000000000032_neutralize_seeded_contact_emails.sql +0 -34
- package/supabase/migrations/00000000000033_setup_config_settings.sql +0 -99
- package/supabase/migrations/00000000000034_enable_staff_2fa_reminder_default.sql +0 -15
- package/supabase/migrations/00000000000035_reassert_advisor_fixes.sql +0 -33
- package/supabase/migrations/00000000000036_setup_system_alerts.sql +0 -72
- package/supabase/migrations/00000000000037_refresh_setup_article_install_paths.sql +0 -317
- package/supabase/migrations/00000000000038_seed_consent_banner_translations.sql +0 -126
- package/supabase/migrations/00000000000039_setup_interactions.sql +0 -153
- package/supabase/migrations/00000000000040_add_profiles_fk_to_interactions.sql +0 -8
- package/supabase/migrations/00000000000041_seed_interactions_translations.sql +0 -145
- package/supabase/migrations/00000000000042_seed_deploy_to_vercel_ctas.sql +0 -72
|
@@ -1,872 +0,0 @@
|
|
|
1
|
-
-- 00000000000006_setup_rls_and_grants.sql
|
|
2
|
-
-- Consolidated migration preserving original statement order within grouped sections.
|
|
3
|
-
|
|
4
|
-
-- 00000000000018_setup_core_cms_rls.sql
|
|
5
|
-
-- RLS, grants, and core admin/public access policies.
|
|
6
|
-
|
|
7
|
-
GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role;
|
|
8
|
-
GRANT SELECT ON ALL TABLES IN SCHEMA public TO anon;
|
|
9
|
-
GRANT ALL ON ALL TABLES IN SCHEMA public TO authenticated;
|
|
10
|
-
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO authenticated;
|
|
11
|
-
GRANT ALL ON ALL TABLES IN SCHEMA public TO service_role;
|
|
12
|
-
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO service_role;
|
|
13
|
-
|
|
14
|
-
ALTER TABLE public.site_settings ENABLE ROW LEVEL SECURITY;
|
|
15
|
-
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
|
|
16
|
-
ALTER TABLE public.user_addresses ENABLE ROW LEVEL SECURITY;
|
|
17
|
-
ALTER TABLE public.languages ENABLE ROW LEVEL SECURITY;
|
|
18
|
-
ALTER TABLE public.media ENABLE ROW LEVEL SECURITY;
|
|
19
|
-
ALTER TABLE public.translations ENABLE ROW LEVEL SECURITY;
|
|
20
|
-
ALTER TABLE public.logos ENABLE ROW LEVEL SECURITY;
|
|
21
|
-
|
|
22
|
-
CREATE POLICY profiles_read_policy
|
|
23
|
-
ON public.profiles
|
|
24
|
-
FOR SELECT
|
|
25
|
-
TO public
|
|
26
|
-
USING (true);
|
|
27
|
-
|
|
28
|
-
CREATE POLICY profiles_service_role_policy
|
|
29
|
-
ON public.profiles
|
|
30
|
-
FOR ALL
|
|
31
|
-
TO service_role
|
|
32
|
-
USING (true)
|
|
33
|
-
WITH CHECK (true);
|
|
34
|
-
|
|
35
|
-
CREATE POLICY profiles_update_policy
|
|
36
|
-
ON public.profiles
|
|
37
|
-
FOR UPDATE
|
|
38
|
-
TO authenticated
|
|
39
|
-
USING (
|
|
40
|
-
(id = (SELECT auth.uid()))
|
|
41
|
-
OR ((SELECT public.get_current_user_role()) = 'ADMIN')
|
|
42
|
-
)
|
|
43
|
-
WITH CHECK (
|
|
44
|
-
(id = (SELECT auth.uid()))
|
|
45
|
-
OR ((SELECT public.get_current_user_role()) = 'ADMIN')
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
CREATE POLICY profiles_insert_policy
|
|
49
|
-
ON public.profiles
|
|
50
|
-
FOR INSERT
|
|
51
|
-
TO authenticated
|
|
52
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
53
|
-
|
|
54
|
-
CREATE POLICY "Users can manage own addresses"
|
|
55
|
-
ON public.user_addresses
|
|
56
|
-
FOR ALL
|
|
57
|
-
TO authenticated
|
|
58
|
-
USING (user_id = (SELECT auth.uid()))
|
|
59
|
-
WITH CHECK (user_id = (SELECT auth.uid()));
|
|
60
|
-
|
|
61
|
-
CREATE POLICY "Service role manages all addresses"
|
|
62
|
-
ON public.user_addresses
|
|
63
|
-
FOR ALL
|
|
64
|
-
TO service_role
|
|
65
|
-
USING (true)
|
|
66
|
-
WITH CHECK (true);
|
|
67
|
-
|
|
68
|
-
CREATE POLICY languages_read_policy
|
|
69
|
-
ON public.languages
|
|
70
|
-
FOR SELECT
|
|
71
|
-
TO public
|
|
72
|
-
USING (true);
|
|
73
|
-
|
|
74
|
-
CREATE POLICY languages_insert_policy
|
|
75
|
-
ON public.languages
|
|
76
|
-
FOR INSERT
|
|
77
|
-
TO authenticated
|
|
78
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
79
|
-
|
|
80
|
-
CREATE POLICY languages_update_policy
|
|
81
|
-
ON public.languages
|
|
82
|
-
FOR UPDATE
|
|
83
|
-
TO authenticated
|
|
84
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN')
|
|
85
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
86
|
-
|
|
87
|
-
CREATE POLICY languages_delete_policy
|
|
88
|
-
ON public.languages
|
|
89
|
-
FOR DELETE
|
|
90
|
-
TO authenticated
|
|
91
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
92
|
-
|
|
93
|
-
CREATE POLICY media_read_policy
|
|
94
|
-
ON public.media
|
|
95
|
-
FOR SELECT
|
|
96
|
-
TO public
|
|
97
|
-
USING (true);
|
|
98
|
-
|
|
99
|
-
CREATE POLICY media_insert_policy
|
|
100
|
-
ON public.media
|
|
101
|
-
FOR INSERT
|
|
102
|
-
TO authenticated
|
|
103
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
104
|
-
|
|
105
|
-
CREATE POLICY media_update_policy
|
|
106
|
-
ON public.media
|
|
107
|
-
FOR UPDATE
|
|
108
|
-
TO authenticated
|
|
109
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
110
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
111
|
-
|
|
112
|
-
CREATE POLICY media_delete_policy
|
|
113
|
-
ON public.media
|
|
114
|
-
FOR DELETE
|
|
115
|
-
TO authenticated
|
|
116
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
117
|
-
|
|
118
|
-
CREATE POLICY media_service_role_policy
|
|
119
|
-
ON public.media
|
|
120
|
-
FOR ALL
|
|
121
|
-
TO service_role
|
|
122
|
-
USING (true)
|
|
123
|
-
WITH CHECK (true);
|
|
124
|
-
|
|
125
|
-
CREATE POLICY site_settings_read_policy
|
|
126
|
-
ON public.site_settings
|
|
127
|
-
FOR SELECT
|
|
128
|
-
TO public
|
|
129
|
-
USING (true);
|
|
130
|
-
|
|
131
|
-
CREATE POLICY site_settings_insert_policy
|
|
132
|
-
ON public.site_settings
|
|
133
|
-
FOR INSERT
|
|
134
|
-
TO authenticated
|
|
135
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
136
|
-
|
|
137
|
-
CREATE POLICY site_settings_update_policy
|
|
138
|
-
ON public.site_settings
|
|
139
|
-
FOR UPDATE
|
|
140
|
-
TO authenticated
|
|
141
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
142
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
143
|
-
|
|
144
|
-
CREATE POLICY site_settings_delete_policy
|
|
145
|
-
ON public.site_settings
|
|
146
|
-
FOR DELETE
|
|
147
|
-
TO authenticated
|
|
148
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
149
|
-
|
|
150
|
-
CREATE POLICY translations_read_policy
|
|
151
|
-
ON public.translations
|
|
152
|
-
FOR SELECT
|
|
153
|
-
TO public
|
|
154
|
-
USING (true);
|
|
155
|
-
|
|
156
|
-
CREATE POLICY translations_insert_policy
|
|
157
|
-
ON public.translations
|
|
158
|
-
FOR INSERT
|
|
159
|
-
TO authenticated
|
|
160
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
161
|
-
|
|
162
|
-
CREATE POLICY translations_update_policy
|
|
163
|
-
ON public.translations
|
|
164
|
-
FOR UPDATE
|
|
165
|
-
TO authenticated
|
|
166
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
167
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
168
|
-
|
|
169
|
-
CREATE POLICY translations_delete_policy
|
|
170
|
-
ON public.translations
|
|
171
|
-
FOR DELETE
|
|
172
|
-
TO authenticated
|
|
173
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
174
|
-
|
|
175
|
-
CREATE POLICY logos_read_policy
|
|
176
|
-
ON public.logos
|
|
177
|
-
FOR SELECT
|
|
178
|
-
TO public
|
|
179
|
-
USING (true);
|
|
180
|
-
|
|
181
|
-
CREATE POLICY logos_insert_policy
|
|
182
|
-
ON public.logos
|
|
183
|
-
FOR INSERT
|
|
184
|
-
TO authenticated
|
|
185
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
186
|
-
|
|
187
|
-
CREATE POLICY logos_update_policy
|
|
188
|
-
ON public.logos
|
|
189
|
-
FOR UPDATE
|
|
190
|
-
TO authenticated
|
|
191
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN')
|
|
192
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
193
|
-
|
|
194
|
-
CREATE POLICY logos_delete_policy
|
|
195
|
-
ON public.logos
|
|
196
|
-
FOR DELETE
|
|
197
|
-
TO authenticated
|
|
198
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
199
|
-
|
|
200
|
-
-- 00000000000019_setup_content_rls.sql
|
|
201
|
-
-- RLS policies for authoring and published content access.
|
|
202
|
-
|
|
203
|
-
ALTER TABLE public.pages ENABLE ROW LEVEL SECURITY;
|
|
204
|
-
ALTER TABLE public.posts ENABLE ROW LEVEL SECURITY;
|
|
205
|
-
ALTER TABLE public.blocks ENABLE ROW LEVEL SECURITY;
|
|
206
|
-
ALTER TABLE public.navigation_items ENABLE ROW LEVEL SECURITY;
|
|
207
|
-
ALTER TABLE public.page_revisions ENABLE ROW LEVEL SECURITY;
|
|
208
|
-
ALTER TABLE public.post_revisions ENABLE ROW LEVEL SECURITY;
|
|
209
|
-
|
|
210
|
-
CREATE POLICY pages_anon_read_policy
|
|
211
|
-
ON public.pages
|
|
212
|
-
FOR SELECT
|
|
213
|
-
TO anon
|
|
214
|
-
USING (status = 'published');
|
|
215
|
-
|
|
216
|
-
CREATE POLICY pages_read_policy
|
|
217
|
-
ON public.pages
|
|
218
|
-
FOR SELECT
|
|
219
|
-
TO authenticated
|
|
220
|
-
USING (
|
|
221
|
-
(status = 'published')
|
|
222
|
-
OR (author_id = (SELECT auth.uid()) AND status <> 'published')
|
|
223
|
-
OR ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
CREATE POLICY pages_insert_policy
|
|
227
|
-
ON public.pages
|
|
228
|
-
FOR INSERT
|
|
229
|
-
TO authenticated
|
|
230
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
231
|
-
|
|
232
|
-
CREATE POLICY pages_update_policy
|
|
233
|
-
ON public.pages
|
|
234
|
-
FOR UPDATE
|
|
235
|
-
TO authenticated
|
|
236
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
237
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
238
|
-
|
|
239
|
-
CREATE POLICY pages_delete_policy
|
|
240
|
-
ON public.pages
|
|
241
|
-
FOR DELETE
|
|
242
|
-
TO authenticated
|
|
243
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
244
|
-
|
|
245
|
-
CREATE POLICY posts_anon_read_policy
|
|
246
|
-
ON public.posts
|
|
247
|
-
FOR SELECT
|
|
248
|
-
TO anon
|
|
249
|
-
USING (status = 'published' AND (published_at IS NULL OR published_at <= now()));
|
|
250
|
-
|
|
251
|
-
CREATE POLICY posts_read_policy
|
|
252
|
-
ON public.posts
|
|
253
|
-
FOR SELECT
|
|
254
|
-
TO authenticated
|
|
255
|
-
USING (
|
|
256
|
-
(
|
|
257
|
-
status = 'published'
|
|
258
|
-
AND (published_at IS NULL OR published_at <= now())
|
|
259
|
-
)
|
|
260
|
-
OR (author_id = (SELECT auth.uid()) AND status <> 'published')
|
|
261
|
-
OR ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
CREATE POLICY posts_insert_policy
|
|
265
|
-
ON public.posts
|
|
266
|
-
FOR INSERT
|
|
267
|
-
TO authenticated
|
|
268
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
269
|
-
|
|
270
|
-
CREATE POLICY posts_update_policy
|
|
271
|
-
ON public.posts
|
|
272
|
-
FOR UPDATE
|
|
273
|
-
TO authenticated
|
|
274
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
275
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
276
|
-
|
|
277
|
-
CREATE POLICY posts_delete_policy
|
|
278
|
-
ON public.posts
|
|
279
|
-
FOR DELETE
|
|
280
|
-
TO authenticated
|
|
281
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
282
|
-
|
|
283
|
-
CREATE POLICY blocks_anon_read_policy
|
|
284
|
-
ON public.blocks
|
|
285
|
-
FOR SELECT
|
|
286
|
-
TO anon
|
|
287
|
-
USING (
|
|
288
|
-
(
|
|
289
|
-
page_id IS NOT NULL
|
|
290
|
-
AND EXISTS (
|
|
291
|
-
SELECT 1
|
|
292
|
-
FROM public.pages AS p
|
|
293
|
-
WHERE p.id = blocks.page_id
|
|
294
|
-
AND p.status = 'published'
|
|
295
|
-
)
|
|
296
|
-
)
|
|
297
|
-
OR (
|
|
298
|
-
post_id IS NOT NULL
|
|
299
|
-
AND EXISTS (
|
|
300
|
-
SELECT 1
|
|
301
|
-
FROM public.posts AS pt
|
|
302
|
-
WHERE pt.id = blocks.post_id
|
|
303
|
-
AND pt.status = 'published'
|
|
304
|
-
AND (pt.published_at IS NULL OR pt.published_at <= now())
|
|
305
|
-
)
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
CREATE POLICY blocks_read_policy
|
|
310
|
-
ON public.blocks
|
|
311
|
-
FOR SELECT
|
|
312
|
-
TO authenticated
|
|
313
|
-
USING (
|
|
314
|
-
((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
315
|
-
OR (
|
|
316
|
-
(
|
|
317
|
-
page_id IS NOT NULL
|
|
318
|
-
AND EXISTS (
|
|
319
|
-
SELECT 1
|
|
320
|
-
FROM public.pages AS p
|
|
321
|
-
WHERE p.id = blocks.page_id
|
|
322
|
-
AND p.status = 'published'
|
|
323
|
-
)
|
|
324
|
-
)
|
|
325
|
-
OR (
|
|
326
|
-
post_id IS NOT NULL
|
|
327
|
-
AND EXISTS (
|
|
328
|
-
SELECT 1
|
|
329
|
-
FROM public.posts AS pt
|
|
330
|
-
WHERE pt.id = blocks.post_id
|
|
331
|
-
AND pt.status = 'published'
|
|
332
|
-
AND (pt.published_at IS NULL OR pt.published_at <= now())
|
|
333
|
-
)
|
|
334
|
-
)
|
|
335
|
-
)
|
|
336
|
-
);
|
|
337
|
-
|
|
338
|
-
CREATE POLICY blocks_insert_policy
|
|
339
|
-
ON public.blocks
|
|
340
|
-
FOR INSERT
|
|
341
|
-
TO authenticated
|
|
342
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
343
|
-
|
|
344
|
-
CREATE POLICY blocks_update_policy
|
|
345
|
-
ON public.blocks
|
|
346
|
-
FOR UPDATE
|
|
347
|
-
TO authenticated
|
|
348
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
349
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
350
|
-
|
|
351
|
-
CREATE POLICY blocks_delete_policy
|
|
352
|
-
ON public.blocks
|
|
353
|
-
FOR DELETE
|
|
354
|
-
TO authenticated
|
|
355
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
356
|
-
|
|
357
|
-
CREATE POLICY navigation_read_policy
|
|
358
|
-
ON public.navigation_items
|
|
359
|
-
FOR SELECT
|
|
360
|
-
TO public
|
|
361
|
-
USING (true);
|
|
362
|
-
|
|
363
|
-
CREATE POLICY navigation_items_insert_policy
|
|
364
|
-
ON public.navigation_items
|
|
365
|
-
FOR INSERT
|
|
366
|
-
TO authenticated
|
|
367
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
368
|
-
|
|
369
|
-
CREATE POLICY navigation_items_update_policy
|
|
370
|
-
ON public.navigation_items
|
|
371
|
-
FOR UPDATE
|
|
372
|
-
TO authenticated
|
|
373
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN')
|
|
374
|
-
WITH CHECK ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
375
|
-
|
|
376
|
-
CREATE POLICY navigation_items_delete_policy
|
|
377
|
-
ON public.navigation_items
|
|
378
|
-
FOR DELETE
|
|
379
|
-
TO authenticated
|
|
380
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
381
|
-
|
|
382
|
-
CREATE POLICY page_revisions_read_policy
|
|
383
|
-
ON public.page_revisions
|
|
384
|
-
FOR SELECT
|
|
385
|
-
TO authenticated
|
|
386
|
-
USING (true);
|
|
387
|
-
|
|
388
|
-
CREATE POLICY page_revisions_insert_policy
|
|
389
|
-
ON public.page_revisions
|
|
390
|
-
FOR INSERT
|
|
391
|
-
TO authenticated
|
|
392
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
393
|
-
|
|
394
|
-
CREATE POLICY page_revisions_update_policy
|
|
395
|
-
ON public.page_revisions
|
|
396
|
-
FOR UPDATE
|
|
397
|
-
TO authenticated
|
|
398
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
399
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
400
|
-
|
|
401
|
-
CREATE POLICY page_revisions_delete_policy
|
|
402
|
-
ON public.page_revisions
|
|
403
|
-
FOR DELETE
|
|
404
|
-
TO authenticated
|
|
405
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
406
|
-
|
|
407
|
-
CREATE POLICY post_revisions_read_policy
|
|
408
|
-
ON public.post_revisions
|
|
409
|
-
FOR SELECT
|
|
410
|
-
TO authenticated
|
|
411
|
-
USING (true);
|
|
412
|
-
|
|
413
|
-
CREATE POLICY post_revisions_insert_policy
|
|
414
|
-
ON public.post_revisions
|
|
415
|
-
FOR INSERT
|
|
416
|
-
TO authenticated
|
|
417
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
418
|
-
|
|
419
|
-
CREATE POLICY post_revisions_update_policy
|
|
420
|
-
ON public.post_revisions
|
|
421
|
-
FOR UPDATE
|
|
422
|
-
TO authenticated
|
|
423
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'))
|
|
424
|
-
WITH CHECK ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
425
|
-
|
|
426
|
-
CREATE POLICY post_revisions_delete_policy
|
|
427
|
-
ON public.post_revisions
|
|
428
|
-
FOR DELETE
|
|
429
|
-
TO authenticated
|
|
430
|
-
USING ((SELECT public.get_current_user_role()) IN ('ADMIN', 'WRITER'));
|
|
431
|
-
|
|
432
|
-
-- 00000000000020_setup_commerce_and_financial_rls.sql
|
|
433
|
-
-- Consolidated RLS for commerce, licensing, shipping, tax, and currency tables.
|
|
434
|
-
|
|
435
|
-
ALTER TABLE public.products ENABLE ROW LEVEL SECURITY;
|
|
436
|
-
ALTER TABLE public.product_media ENABLE ROW LEVEL SECURITY;
|
|
437
|
-
ALTER TABLE public.product_attributes ENABLE ROW LEVEL SECURITY;
|
|
438
|
-
ALTER TABLE public.product_attribute_terms ENABLE ROW LEVEL SECURITY;
|
|
439
|
-
ALTER TABLE public.product_variants ENABLE ROW LEVEL SECURITY;
|
|
440
|
-
ALTER TABLE public.variant_attribute_mapping ENABLE ROW LEVEL SECURITY;
|
|
441
|
-
ALTER TABLE public.orders ENABLE ROW LEVEL SECURITY;
|
|
442
|
-
ALTER TABLE public.order_items ENABLE ROW LEVEL SECURITY;
|
|
443
|
-
ALTER TABLE public.package_activations ENABLE ROW LEVEL SECURITY;
|
|
444
|
-
ALTER TABLE public.freemius_plans ENABLE ROW LEVEL SECURITY;
|
|
445
|
-
ALTER TABLE public.freemius_pricing ENABLE ROW LEVEL SECURITY;
|
|
446
|
-
ALTER TABLE public.inventory_items ENABLE ROW LEVEL SECURITY;
|
|
447
|
-
ALTER TABLE public.shipping_zones ENABLE ROW LEVEL SECURITY;
|
|
448
|
-
ALTER TABLE public.shipping_zone_locations ENABLE ROW LEVEL SECURITY;
|
|
449
|
-
ALTER TABLE public.shipping_zone_methods ENABLE ROW LEVEL SECURITY;
|
|
450
|
-
ALTER TABLE public.tax_rates ENABLE ROW LEVEL SECURITY;
|
|
451
|
-
ALTER TABLE public.currencies ENABLE ROW LEVEL SECURITY;
|
|
452
|
-
|
|
453
|
-
CREATE POLICY "Public can view products"
|
|
454
|
-
ON public.products
|
|
455
|
-
FOR SELECT
|
|
456
|
-
TO public
|
|
457
|
-
USING (true);
|
|
458
|
-
|
|
459
|
-
CREATE POLICY products_insert_policy
|
|
460
|
-
ON public.products
|
|
461
|
-
FOR INSERT
|
|
462
|
-
TO authenticated
|
|
463
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
464
|
-
|
|
465
|
-
CREATE POLICY products_update_policy
|
|
466
|
-
ON public.products
|
|
467
|
-
FOR UPDATE
|
|
468
|
-
TO authenticated
|
|
469
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
470
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
471
|
-
|
|
472
|
-
CREATE POLICY products_delete_policy
|
|
473
|
-
ON public.products
|
|
474
|
-
FOR DELETE
|
|
475
|
-
TO authenticated
|
|
476
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
477
|
-
|
|
478
|
-
CREATE POLICY "Public can view product media"
|
|
479
|
-
ON public.product_media
|
|
480
|
-
FOR SELECT
|
|
481
|
-
TO public
|
|
482
|
-
USING (true);
|
|
483
|
-
|
|
484
|
-
CREATE POLICY product_media_insert_policy
|
|
485
|
-
ON public.product_media
|
|
486
|
-
FOR INSERT
|
|
487
|
-
TO authenticated
|
|
488
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
489
|
-
|
|
490
|
-
CREATE POLICY product_media_update_policy
|
|
491
|
-
ON public.product_media
|
|
492
|
-
FOR UPDATE
|
|
493
|
-
TO authenticated
|
|
494
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
495
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
496
|
-
|
|
497
|
-
CREATE POLICY product_media_delete_policy
|
|
498
|
-
ON public.product_media
|
|
499
|
-
FOR DELETE
|
|
500
|
-
TO authenticated
|
|
501
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
502
|
-
|
|
503
|
-
CREATE POLICY "Public read product_attributes"
|
|
504
|
-
ON public.product_attributes
|
|
505
|
-
FOR SELECT
|
|
506
|
-
TO public
|
|
507
|
-
USING (true);
|
|
508
|
-
|
|
509
|
-
CREATE POLICY product_attributes_insert_policy
|
|
510
|
-
ON public.product_attributes
|
|
511
|
-
FOR INSERT
|
|
512
|
-
TO authenticated
|
|
513
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
514
|
-
|
|
515
|
-
CREATE POLICY product_attributes_update_policy
|
|
516
|
-
ON public.product_attributes
|
|
517
|
-
FOR UPDATE
|
|
518
|
-
TO authenticated
|
|
519
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
520
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
521
|
-
|
|
522
|
-
CREATE POLICY product_attributes_delete_policy
|
|
523
|
-
ON public.product_attributes
|
|
524
|
-
FOR DELETE
|
|
525
|
-
TO authenticated
|
|
526
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
527
|
-
|
|
528
|
-
CREATE POLICY "Public read product_attribute_terms"
|
|
529
|
-
ON public.product_attribute_terms
|
|
530
|
-
FOR SELECT
|
|
531
|
-
TO public
|
|
532
|
-
USING (true);
|
|
533
|
-
|
|
534
|
-
CREATE POLICY product_attribute_terms_insert_policy
|
|
535
|
-
ON public.product_attribute_terms
|
|
536
|
-
FOR INSERT
|
|
537
|
-
TO authenticated
|
|
538
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
539
|
-
|
|
540
|
-
CREATE POLICY product_attribute_terms_update_policy
|
|
541
|
-
ON public.product_attribute_terms
|
|
542
|
-
FOR UPDATE
|
|
543
|
-
TO authenticated
|
|
544
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
545
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
546
|
-
|
|
547
|
-
CREATE POLICY product_attribute_terms_delete_policy
|
|
548
|
-
ON public.product_attribute_terms
|
|
549
|
-
FOR DELETE
|
|
550
|
-
TO authenticated
|
|
551
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
552
|
-
|
|
553
|
-
CREATE POLICY "Public read product_variants"
|
|
554
|
-
ON public.product_variants
|
|
555
|
-
FOR SELECT
|
|
556
|
-
TO public
|
|
557
|
-
USING (true);
|
|
558
|
-
|
|
559
|
-
CREATE POLICY product_variants_insert_policy
|
|
560
|
-
ON public.product_variants
|
|
561
|
-
FOR INSERT
|
|
562
|
-
TO authenticated
|
|
563
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
564
|
-
|
|
565
|
-
CREATE POLICY product_variants_update_policy
|
|
566
|
-
ON public.product_variants
|
|
567
|
-
FOR UPDATE
|
|
568
|
-
TO authenticated
|
|
569
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
570
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
571
|
-
|
|
572
|
-
CREATE POLICY product_variants_delete_policy
|
|
573
|
-
ON public.product_variants
|
|
574
|
-
FOR DELETE
|
|
575
|
-
TO authenticated
|
|
576
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
577
|
-
|
|
578
|
-
CREATE POLICY "Public read variant_attribute_mapping"
|
|
579
|
-
ON public.variant_attribute_mapping
|
|
580
|
-
FOR SELECT
|
|
581
|
-
TO public
|
|
582
|
-
USING (true);
|
|
583
|
-
|
|
584
|
-
CREATE POLICY variant_attribute_mapping_insert_policy
|
|
585
|
-
ON public.variant_attribute_mapping
|
|
586
|
-
FOR INSERT
|
|
587
|
-
TO authenticated
|
|
588
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
589
|
-
|
|
590
|
-
CREATE POLICY variant_attribute_mapping_update_policy
|
|
591
|
-
ON public.variant_attribute_mapping
|
|
592
|
-
FOR UPDATE
|
|
593
|
-
TO authenticated
|
|
594
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
595
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
596
|
-
|
|
597
|
-
CREATE POLICY variant_attribute_mapping_delete_policy
|
|
598
|
-
ON public.variant_attribute_mapping
|
|
599
|
-
FOR DELETE
|
|
600
|
-
TO authenticated
|
|
601
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
602
|
-
|
|
603
|
-
CREATE POLICY "Users can view own orders"
|
|
604
|
-
ON public.orders
|
|
605
|
-
FOR SELECT
|
|
606
|
-
TO authenticated
|
|
607
|
-
USING (
|
|
608
|
-
((SELECT public.is_admin()) IS TRUE)
|
|
609
|
-
OR (user_id = (SELECT auth.uid()))
|
|
610
|
-
);
|
|
611
|
-
|
|
612
|
-
CREATE POLICY orders_insert_policy
|
|
613
|
-
ON public.orders
|
|
614
|
-
FOR INSERT
|
|
615
|
-
TO authenticated
|
|
616
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
617
|
-
|
|
618
|
-
CREATE POLICY orders_update_policy
|
|
619
|
-
ON public.orders
|
|
620
|
-
FOR UPDATE
|
|
621
|
-
TO authenticated
|
|
622
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
623
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
624
|
-
|
|
625
|
-
CREATE POLICY orders_delete_policy
|
|
626
|
-
ON public.orders
|
|
627
|
-
FOR DELETE
|
|
628
|
-
TO authenticated
|
|
629
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
630
|
-
|
|
631
|
-
CREATE POLICY "Service Role manages orders"
|
|
632
|
-
ON public.orders
|
|
633
|
-
FOR ALL
|
|
634
|
-
TO service_role
|
|
635
|
-
USING (true)
|
|
636
|
-
WITH CHECK (true);
|
|
637
|
-
|
|
638
|
-
CREATE POLICY "Users can view own order items"
|
|
639
|
-
ON public.order_items
|
|
640
|
-
FOR SELECT
|
|
641
|
-
TO authenticated
|
|
642
|
-
USING (
|
|
643
|
-
((SELECT public.is_admin()) IS TRUE)
|
|
644
|
-
OR EXISTS (
|
|
645
|
-
SELECT 1
|
|
646
|
-
FROM public.orders
|
|
647
|
-
WHERE orders.id = order_items.order_id
|
|
648
|
-
AND orders.user_id = (SELECT auth.uid())
|
|
649
|
-
)
|
|
650
|
-
);
|
|
651
|
-
|
|
652
|
-
CREATE POLICY order_items_insert_policy
|
|
653
|
-
ON public.order_items
|
|
654
|
-
FOR INSERT
|
|
655
|
-
TO authenticated
|
|
656
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
657
|
-
|
|
658
|
-
CREATE POLICY order_items_update_policy
|
|
659
|
-
ON public.order_items
|
|
660
|
-
FOR UPDATE
|
|
661
|
-
TO authenticated
|
|
662
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
663
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
664
|
-
|
|
665
|
-
CREATE POLICY order_items_delete_policy
|
|
666
|
-
ON public.order_items
|
|
667
|
-
FOR DELETE
|
|
668
|
-
TO authenticated
|
|
669
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
670
|
-
|
|
671
|
-
CREATE POLICY "Service Role manages order items"
|
|
672
|
-
ON public.order_items
|
|
673
|
-
FOR ALL
|
|
674
|
-
TO service_role
|
|
675
|
-
USING (true)
|
|
676
|
-
WITH CHECK (true);
|
|
677
|
-
|
|
678
|
-
CREATE POLICY "Allow service role full access"
|
|
679
|
-
ON public.package_activations
|
|
680
|
-
FOR ALL
|
|
681
|
-
TO service_role
|
|
682
|
-
USING (true)
|
|
683
|
-
WITH CHECK (true);
|
|
684
|
-
|
|
685
|
-
CREATE POLICY "Allow authenticated read access"
|
|
686
|
-
ON public.package_activations
|
|
687
|
-
FOR SELECT
|
|
688
|
-
TO authenticated
|
|
689
|
-
USING (true);
|
|
690
|
-
|
|
691
|
-
CREATE POLICY "Public read access for freemius_plans"
|
|
692
|
-
ON public.freemius_plans
|
|
693
|
-
FOR SELECT
|
|
694
|
-
TO public
|
|
695
|
-
USING (true);
|
|
696
|
-
|
|
697
|
-
CREATE POLICY "Public read access for freemius_pricing"
|
|
698
|
-
ON public.freemius_pricing
|
|
699
|
-
FOR SELECT
|
|
700
|
-
TO public
|
|
701
|
-
USING (true);
|
|
702
|
-
|
|
703
|
-
CREATE POLICY "Public can view inventory items"
|
|
704
|
-
ON public.inventory_items
|
|
705
|
-
FOR SELECT
|
|
706
|
-
TO public
|
|
707
|
-
USING (true);
|
|
708
|
-
|
|
709
|
-
CREATE POLICY inventory_items_insert_policy
|
|
710
|
-
ON public.inventory_items
|
|
711
|
-
FOR INSERT
|
|
712
|
-
TO authenticated
|
|
713
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
714
|
-
|
|
715
|
-
CREATE POLICY inventory_items_update_policy
|
|
716
|
-
ON public.inventory_items
|
|
717
|
-
FOR UPDATE
|
|
718
|
-
TO authenticated
|
|
719
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
720
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
721
|
-
|
|
722
|
-
CREATE POLICY inventory_items_delete_policy
|
|
723
|
-
ON public.inventory_items
|
|
724
|
-
FOR DELETE
|
|
725
|
-
TO authenticated
|
|
726
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
727
|
-
|
|
728
|
-
CREATE POLICY "Service Role manages inventory items"
|
|
729
|
-
ON public.inventory_items
|
|
730
|
-
FOR ALL
|
|
731
|
-
TO service_role
|
|
732
|
-
USING (true)
|
|
733
|
-
WITH CHECK (true);
|
|
734
|
-
|
|
735
|
-
CREATE POLICY "Public read shipping_zones"
|
|
736
|
-
ON public.shipping_zones
|
|
737
|
-
FOR SELECT
|
|
738
|
-
TO public
|
|
739
|
-
USING (true);
|
|
740
|
-
|
|
741
|
-
CREATE POLICY shipping_zones_insert_policy
|
|
742
|
-
ON public.shipping_zones
|
|
743
|
-
FOR INSERT
|
|
744
|
-
TO authenticated
|
|
745
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
746
|
-
|
|
747
|
-
CREATE POLICY shipping_zones_update_policy
|
|
748
|
-
ON public.shipping_zones
|
|
749
|
-
FOR UPDATE
|
|
750
|
-
TO authenticated
|
|
751
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
752
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
753
|
-
|
|
754
|
-
CREATE POLICY shipping_zones_delete_policy
|
|
755
|
-
ON public.shipping_zones
|
|
756
|
-
FOR DELETE
|
|
757
|
-
TO authenticated
|
|
758
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
759
|
-
|
|
760
|
-
CREATE POLICY "Public read shipping_zone_locations"
|
|
761
|
-
ON public.shipping_zone_locations
|
|
762
|
-
FOR SELECT
|
|
763
|
-
TO public
|
|
764
|
-
USING (true);
|
|
765
|
-
|
|
766
|
-
CREATE POLICY shipping_zone_locations_insert_policy
|
|
767
|
-
ON public.shipping_zone_locations
|
|
768
|
-
FOR INSERT
|
|
769
|
-
TO authenticated
|
|
770
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
771
|
-
|
|
772
|
-
CREATE POLICY shipping_zone_locations_update_policy
|
|
773
|
-
ON public.shipping_zone_locations
|
|
774
|
-
FOR UPDATE
|
|
775
|
-
TO authenticated
|
|
776
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
777
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
778
|
-
|
|
779
|
-
CREATE POLICY shipping_zone_locations_delete_policy
|
|
780
|
-
ON public.shipping_zone_locations
|
|
781
|
-
FOR DELETE
|
|
782
|
-
TO authenticated
|
|
783
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
784
|
-
|
|
785
|
-
CREATE POLICY "Public read shipping_zone_methods"
|
|
786
|
-
ON public.shipping_zone_methods
|
|
787
|
-
FOR SELECT
|
|
788
|
-
TO public
|
|
789
|
-
USING (true);
|
|
790
|
-
|
|
791
|
-
CREATE POLICY shipping_zone_methods_insert_policy
|
|
792
|
-
ON public.shipping_zone_methods
|
|
793
|
-
FOR INSERT
|
|
794
|
-
TO authenticated
|
|
795
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
796
|
-
|
|
797
|
-
CREATE POLICY shipping_zone_methods_update_policy
|
|
798
|
-
ON public.shipping_zone_methods
|
|
799
|
-
FOR UPDATE
|
|
800
|
-
TO authenticated
|
|
801
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
802
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
803
|
-
|
|
804
|
-
CREATE POLICY shipping_zone_methods_delete_policy
|
|
805
|
-
ON public.shipping_zone_methods
|
|
806
|
-
FOR DELETE
|
|
807
|
-
TO authenticated
|
|
808
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
809
|
-
|
|
810
|
-
CREATE POLICY "Public read tax_rates"
|
|
811
|
-
ON public.tax_rates
|
|
812
|
-
FOR SELECT
|
|
813
|
-
TO public
|
|
814
|
-
USING (true);
|
|
815
|
-
|
|
816
|
-
CREATE POLICY tax_rates_insert_policy
|
|
817
|
-
ON public.tax_rates
|
|
818
|
-
FOR INSERT
|
|
819
|
-
TO authenticated
|
|
820
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
821
|
-
|
|
822
|
-
CREATE POLICY tax_rates_update_policy
|
|
823
|
-
ON public.tax_rates
|
|
824
|
-
FOR UPDATE
|
|
825
|
-
TO authenticated
|
|
826
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
827
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
828
|
-
|
|
829
|
-
CREATE POLICY tax_rates_delete_policy
|
|
830
|
-
ON public.tax_rates
|
|
831
|
-
FOR DELETE
|
|
832
|
-
TO authenticated
|
|
833
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
834
|
-
|
|
835
|
-
CREATE POLICY "Service Role manages tax_rates"
|
|
836
|
-
ON public.tax_rates
|
|
837
|
-
FOR ALL
|
|
838
|
-
TO service_role
|
|
839
|
-
USING (true)
|
|
840
|
-
WITH CHECK (true);
|
|
841
|
-
|
|
842
|
-
CREATE POLICY "Public read active currencies"
|
|
843
|
-
ON public.currencies
|
|
844
|
-
FOR SELECT
|
|
845
|
-
TO anon, authenticated
|
|
846
|
-
USING (is_active = true);
|
|
847
|
-
|
|
848
|
-
CREATE POLICY currencies_insert_policy
|
|
849
|
-
ON public.currencies
|
|
850
|
-
FOR INSERT
|
|
851
|
-
TO authenticated
|
|
852
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
853
|
-
|
|
854
|
-
CREATE POLICY currencies_update_policy
|
|
855
|
-
ON public.currencies
|
|
856
|
-
FOR UPDATE
|
|
857
|
-
TO authenticated
|
|
858
|
-
USING (((SELECT public.is_admin()) IS TRUE))
|
|
859
|
-
WITH CHECK (((SELECT public.is_admin()) IS TRUE));
|
|
860
|
-
|
|
861
|
-
CREATE POLICY currencies_delete_policy
|
|
862
|
-
ON public.currencies
|
|
863
|
-
FOR DELETE
|
|
864
|
-
TO authenticated
|
|
865
|
-
USING (((SELECT public.is_admin()) IS TRUE));
|
|
866
|
-
|
|
867
|
-
CREATE POLICY "Service role manages currencies"
|
|
868
|
-
ON public.currencies
|
|
869
|
-
FOR ALL
|
|
870
|
-
TO service_role
|
|
871
|
-
USING (true)
|
|
872
|
-
WITH CHECK (true);
|