@nextblock-cms/db 0.17.0 → 0.17.1
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/package.json +1 -1
- package/supabase/migrations/02000_catchup_gen1.sql +5880 -0
- package/supabase/migrations/{00000000000000_baseline_schema.sql → 02001_baseline_schema.sql} +305 -25
- package/supabase/migrations/{00000000000001_baseline_constraints_and_indexes.sql → 02002_baseline_constraints_and_indexes.sql} +194 -3
- package/supabase/migrations/{00000000000002_baseline_security_and_grants.sql → 02003_baseline_security_and_grants.sql} +403 -161
- package/supabase/migrations/02004_baseline_seed.sql +565 -0
- package/supabase/migrations/00000000000003_baseline_seed.sql +0 -468
- package/supabase/migrations/00000000000004_default_logo_email_safe.sql +0 -24
- package/supabase/migrations/00000000000005_add_custom_canonical.sql +0 -13
- package/supabase/migrations/00000000000006_home_live_demo_promo.sql +0 -67
- package/supabase/migrations/00000000000007_home_live_demo_promo_copy_fix.sql +0 -49
- package/supabase/migrations/00000000000008_setup_article_reorder.sql +0 -30
- package/supabase/migrations/00000000000009_home_live_demo_promo_contrast.sql +0 -52
- package/supabase/migrations/00000000000010_drop_github_username.sql +0 -79
- package/supabase/migrations/00000000000011_language_detection_admin_only.sql +0 -21
- package/supabase/migrations/00000000000012_cortex_ai_stock_photo_settings.sql +0 -25
- package/supabase/migrations/00000000000013_youtube_nocookie_embeds.sql +0 -136
- package/supabase/migrations/00000000000014_site_themes.sql +0 -254
- package/supabase/migrations/00000000000015_scheduled_publishing.sql +0 -43
- package/supabase/migrations/00000000000016_product_revisions_and_revision_baseline.sql +0 -310
- package/supabase/migrations/00000000000017_cortex_ai_mcp_server.sql +0 -91
- package/supabase/migrations/00000000000018_site_scripts.sql +0 -96
- package/supabase/migrations/00000000000019_site_script_revisions.sql +0 -85
- package/supabase/migrations/00000000000020_updating_article.sql +0 -162
- package/supabase/migrations/00000000000021_updating_article_git_merge.sql +0 -91
- package/supabase/migrations/00000000000022_updating_article_accuracy.sql +0 -94
- package/supabase/migrations/00000000000023_updating_article_layout_not_host.sql +0 -87
- package/supabase/migrations/00000000000024_updating_article_newline_fix.sql +0 -70
- package/supabase/migrations/00000000000025_rebrand_nextblock_dev.sql +0 -53
- package/supabase/migrations/00000000000026_product_inquiries.sql +0 -118
- package/supabase/migrations/00000000000027_message_threads.sql +0 -391
- package/supabase/migrations/00000000000028_interaction_replies.sql +0 -86
- package/supabase/migrations/00000000000029_form_endpoints_default_empty.sql +0 -52
- package/supabase/migrations/00000000000030_seo_redirects_and_robots.sql +0 -149
- package/supabase/migrations/00000000000031_seo_robots_settings_admin_only.sql +0 -35
- package/supabase/migrations/00000000000032_seed_seo_score_optimizations.sql +0 -1172
- package/supabase/migrations/00000000000033_seed_seo_score_optimizations_p2.sql +0 -353
- package/supabase/migrations/00000000000034_seed_seo_french_legal_readability.sql +0 -101
- package/supabase/migrations/00000000000035_digital_products_seo_optimizations.sql +0 -134
- package/supabase/migrations/00000000000036_seed_posts_missing_seo_metadata.sql +0 -37
- package/supabase/migrations/00000000000037_reposition_marketing_and_cortex_mcp.sql +0 -501
- package/supabase/migrations/00000000000038_mcp_guide_visual_refresh.sql +0 -64
- package/supabase/migrations/00000000000039_mcp_guide_diagram_dimensions.sql +0 -21
- package/supabase/migrations/00000000000040_home_comparison_chart_free_cms.sql +0 -81
- package/supabase/migrations/00000000000041_marketing_review_free_cms_trial.sql +0 -141
- package/supabase/migrations/00000000000042_how_nextblock_works_css_diagram.sql +0 -66
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
-- AUTO-GENERATED baseline (
|
|
2
|
-
--
|
|
3
|
-
-- Regenerate via tools/scripts/rebaseline-transform.mjs
|
|
1
|
+
-- AUTO-GENERATED baseline: squash generation 2 (of migrations 00000000000000..00000000000042).
|
|
2
|
+
-- 002 · constraints (PK / unique / check / FK) + indexes
|
|
3
|
+
-- Idempotent; safe to replay. Regenerate via tools/scripts/rebaseline-transform.mjs — do not hand-edit.
|
|
4
|
+
-- Naming: GGNNN_name.sql (GG = squash generation, NNN = sequence). See docs/04-DATABASE-AND-AUTH.md.
|
|
4
5
|
|
|
5
6
|
DO $rb$ BEGIN
|
|
6
7
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'blocks_pkey' AND conrelid = 'public.blocks'::regclass) THEN
|
|
@@ -30,6 +31,20 @@ DO $rb$ BEGIN
|
|
|
30
31
|
END IF;
|
|
31
32
|
END $rb$;
|
|
32
33
|
|
|
34
|
+
DO $rb$ BEGIN
|
|
35
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cms_redirects_pkey' AND conrelid = 'public.cms_redirects'::regclass) THEN
|
|
36
|
+
ALTER TABLE ONLY public.cms_redirects
|
|
37
|
+
ADD CONSTRAINT cms_redirects_pkey PRIMARY KEY (id);
|
|
38
|
+
END IF;
|
|
39
|
+
END $rb$;
|
|
40
|
+
|
|
41
|
+
DO $rb$ BEGIN
|
|
42
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cms_redirects_source_path_key' AND conrelid = 'public.cms_redirects'::regclass) THEN
|
|
43
|
+
ALTER TABLE ONLY public.cms_redirects
|
|
44
|
+
ADD CONSTRAINT cms_redirects_source_path_key UNIQUE (source_path);
|
|
45
|
+
END IF;
|
|
46
|
+
END $rb$;
|
|
47
|
+
|
|
33
48
|
DO $rb$ BEGIN
|
|
34
49
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'content_drafts_parent_unique' AND conrelid = 'public.content_drafts'::regclass) THEN
|
|
35
50
|
ALTER TABLE ONLY public.content_drafts
|
|
@@ -114,6 +129,13 @@ DO $rb$ BEGIN
|
|
|
114
129
|
END IF;
|
|
115
130
|
END $rb$;
|
|
116
131
|
|
|
132
|
+
DO $rb$ BEGIN
|
|
133
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'form_endpoints_pkey' AND conrelid = 'public.form_endpoints'::regclass) THEN
|
|
134
|
+
ALTER TABLE ONLY public.form_endpoints
|
|
135
|
+
ADD CONSTRAINT form_endpoints_pkey PRIMARY KEY (form_key);
|
|
136
|
+
END IF;
|
|
137
|
+
END $rb$;
|
|
138
|
+
|
|
117
139
|
DO $rb$ BEGIN
|
|
118
140
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'freemius_plans_pkey' AND conrelid = 'public.freemius_plans'::regclass) THEN
|
|
119
141
|
ALTER TABLE ONLY public.freemius_plans
|
|
@@ -156,6 +178,20 @@ DO $rb$ BEGIN
|
|
|
156
178
|
END IF;
|
|
157
179
|
END $rb$;
|
|
158
180
|
|
|
181
|
+
DO $rb$ BEGIN
|
|
182
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'mcp_access_tokens_pkey' AND conrelid = 'public.mcp_access_tokens'::regclass) THEN
|
|
183
|
+
ALTER TABLE ONLY public.mcp_access_tokens
|
|
184
|
+
ADD CONSTRAINT mcp_access_tokens_pkey PRIMARY KEY (id);
|
|
185
|
+
END IF;
|
|
186
|
+
END $rb$;
|
|
187
|
+
|
|
188
|
+
DO $rb$ BEGIN
|
|
189
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'mcp_access_tokens_token_hash_key' AND conrelid = 'public.mcp_access_tokens'::regclass) THEN
|
|
190
|
+
ALTER TABLE ONLY public.mcp_access_tokens
|
|
191
|
+
ADD CONSTRAINT mcp_access_tokens_token_hash_key UNIQUE (token_hash);
|
|
192
|
+
END IF;
|
|
193
|
+
END $rb$;
|
|
194
|
+
|
|
159
195
|
DO $rb$ BEGIN
|
|
160
196
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'media_object_key_key' AND conrelid = 'public.media'::regclass) THEN
|
|
161
197
|
ALTER TABLE ONLY public.media
|
|
@@ -170,6 +206,20 @@ DO $rb$ BEGIN
|
|
|
170
206
|
END IF;
|
|
171
207
|
END $rb$;
|
|
172
208
|
|
|
209
|
+
DO $rb$ BEGIN
|
|
210
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'message_threads_pkey' AND conrelid = 'public.message_threads'::regclass) THEN
|
|
211
|
+
ALTER TABLE ONLY public.message_threads
|
|
212
|
+
ADD CONSTRAINT message_threads_pkey PRIMARY KEY (id);
|
|
213
|
+
END IF;
|
|
214
|
+
END $rb$;
|
|
215
|
+
|
|
216
|
+
DO $rb$ BEGIN
|
|
217
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'message_threads_token_hash_key' AND conrelid = 'public.message_threads'::regclass) THEN
|
|
218
|
+
ALTER TABLE ONLY public.message_threads
|
|
219
|
+
ADD CONSTRAINT message_threads_token_hash_key UNIQUE (token_hash);
|
|
220
|
+
END IF;
|
|
221
|
+
END $rb$;
|
|
222
|
+
|
|
173
223
|
DO $rb$ BEGIN
|
|
174
224
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'navigation_items_pkey' AND conrelid = 'public.navigation_items'::regclass) THEN
|
|
175
225
|
ALTER TABLE ONLY public.navigation_items
|
|
@@ -345,6 +395,13 @@ DO $rb$ BEGIN
|
|
|
345
395
|
END IF;
|
|
346
396
|
END $rb$;
|
|
347
397
|
|
|
398
|
+
DO $rb$ BEGIN
|
|
399
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_inquiries_pkey' AND conrelid = 'public.product_inquiries'::regclass) THEN
|
|
400
|
+
ALTER TABLE ONLY public.product_inquiries
|
|
401
|
+
ADD CONSTRAINT product_inquiries_pkey PRIMARY KEY (id);
|
|
402
|
+
END IF;
|
|
403
|
+
END $rb$;
|
|
404
|
+
|
|
348
405
|
DO $rb$ BEGIN
|
|
349
406
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_media_pkey' AND conrelid = 'public.product_media'::regclass) THEN
|
|
350
407
|
ALTER TABLE ONLY public.product_media
|
|
@@ -352,6 +409,20 @@ DO $rb$ BEGIN
|
|
|
352
409
|
END IF;
|
|
353
410
|
END $rb$;
|
|
354
411
|
|
|
412
|
+
DO $rb$ BEGIN
|
|
413
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_revisions_pkey' AND conrelid = 'public.product_revisions'::regclass) THEN
|
|
414
|
+
ALTER TABLE ONLY public.product_revisions
|
|
415
|
+
ADD CONSTRAINT product_revisions_pkey PRIMARY KEY (id);
|
|
416
|
+
END IF;
|
|
417
|
+
END $rb$;
|
|
418
|
+
|
|
419
|
+
DO $rb$ BEGIN
|
|
420
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_revisions_product_version_key' AND conrelid = 'public.product_revisions'::regclass) THEN
|
|
421
|
+
ALTER TABLE ONLY public.product_revisions
|
|
422
|
+
ADD CONSTRAINT product_revisions_product_version_key UNIQUE (product_id, version);
|
|
423
|
+
END IF;
|
|
424
|
+
END $rb$;
|
|
425
|
+
|
|
355
426
|
DO $rb$ BEGIN
|
|
356
427
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_variants_pkey' AND conrelid = 'public.product_variants'::regclass) THEN
|
|
357
428
|
ALTER TABLE ONLY public.product_variants
|
|
@@ -415,6 +486,20 @@ DO $rb$ BEGIN
|
|
|
415
486
|
END IF;
|
|
416
487
|
END $rb$;
|
|
417
488
|
|
|
489
|
+
DO $rb$ BEGIN
|
|
490
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'site_script_revisions_pkey' AND conrelid = 'public.site_script_revisions'::regclass) THEN
|
|
491
|
+
ALTER TABLE ONLY public.site_script_revisions
|
|
492
|
+
ADD CONSTRAINT site_script_revisions_pkey PRIMARY KEY (id);
|
|
493
|
+
END IF;
|
|
494
|
+
END $rb$;
|
|
495
|
+
|
|
496
|
+
DO $rb$ BEGIN
|
|
497
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'site_scripts_pkey' AND conrelid = 'public.site_scripts'::regclass) THEN
|
|
498
|
+
ALTER TABLE ONLY public.site_scripts
|
|
499
|
+
ADD CONSTRAINT site_scripts_pkey PRIMARY KEY (id);
|
|
500
|
+
END IF;
|
|
501
|
+
END $rb$;
|
|
502
|
+
|
|
418
503
|
DO $rb$ BEGIN
|
|
419
504
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'site_settings_pkey' AND conrelid = 'public.site_settings'::regclass) THEN
|
|
420
505
|
ALTER TABLE ONLY public.site_settings
|
|
@@ -422,6 +507,20 @@ DO $rb$ BEGIN
|
|
|
422
507
|
END IF;
|
|
423
508
|
END $rb$;
|
|
424
509
|
|
|
510
|
+
DO $rb$ BEGIN
|
|
511
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'site_themes_pkey' AND conrelid = 'public.site_themes'::regclass) THEN
|
|
512
|
+
ALTER TABLE ONLY public.site_themes
|
|
513
|
+
ADD CONSTRAINT site_themes_pkey PRIMARY KEY (id);
|
|
514
|
+
END IF;
|
|
515
|
+
END $rb$;
|
|
516
|
+
|
|
517
|
+
DO $rb$ BEGIN
|
|
518
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'site_themes_slug_key' AND conrelid = 'public.site_themes'::regclass) THEN
|
|
519
|
+
ALTER TABLE ONLY public.site_themes
|
|
520
|
+
ADD CONSTRAINT site_themes_slug_key UNIQUE (slug);
|
|
521
|
+
END IF;
|
|
522
|
+
END $rb$;
|
|
523
|
+
|
|
425
524
|
DO $rb$ BEGIN
|
|
426
525
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'system_alerts_pkey' AND conrelid = 'public.system_alerts'::regclass) THEN
|
|
427
526
|
ALTER TABLE ONLY public.system_alerts
|
|
@@ -443,6 +542,13 @@ DO $rb$ BEGIN
|
|
|
443
542
|
END IF;
|
|
444
543
|
END $rb$;
|
|
445
544
|
|
|
545
|
+
DO $rb$ BEGIN
|
|
546
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'thread_messages_pkey' AND conrelid = 'public.thread_messages'::regclass) THEN
|
|
547
|
+
ALTER TABLE ONLY public.thread_messages
|
|
548
|
+
ADD CONSTRAINT thread_messages_pkey PRIMARY KEY (id);
|
|
549
|
+
END IF;
|
|
550
|
+
END $rb$;
|
|
551
|
+
|
|
446
552
|
DO $rb$ BEGIN
|
|
447
553
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'translations_pkey' AND conrelid = 'public.translations'::regclass) THEN
|
|
448
554
|
ALTER TABLE ONLY public.translations
|
|
@@ -492,6 +598,16 @@ DO $rb$ BEGIN
|
|
|
492
598
|
END IF;
|
|
493
599
|
END $rb$;
|
|
494
600
|
|
|
601
|
+
CREATE INDEX IF NOT EXISTS cms_interactions_inbox_idx ON public.cms_interactions USING btree (created_at DESC) WHERE (parent_id IS NULL);
|
|
602
|
+
|
|
603
|
+
CREATE INDEX IF NOT EXISTS cms_interactions_parent_idx ON public.cms_interactions USING btree (parent_id, created_at) WHERE (parent_id IS NOT NULL);
|
|
604
|
+
|
|
605
|
+
CREATE INDEX IF NOT EXISTS cms_interactions_post_type_status_idx ON public.cms_interactions USING btree (post_id, type, status, created_at DESC) WHERE (post_id IS NOT NULL);
|
|
606
|
+
|
|
607
|
+
CREATE INDEX IF NOT EXISTS cms_interactions_product_type_status_idx ON public.cms_interactions USING btree (product_id, type, status, created_at DESC) WHERE (product_id IS NOT NULL);
|
|
608
|
+
|
|
609
|
+
CREATE INDEX IF NOT EXISTS cms_redirects_active_source_idx ON public.cms_redirects USING btree (source_path) WHERE is_active;
|
|
610
|
+
|
|
495
611
|
CREATE INDEX IF NOT EXISTS content_drafts_author_id_idx ON public.content_drafts USING btree (author_id);
|
|
496
612
|
|
|
497
613
|
CREATE INDEX IF NOT EXISTS content_drafts_parent_idx ON public.content_drafts USING btree (parent_type, parent_id);
|
|
@@ -606,6 +722,10 @@ CREATE INDEX IF NOT EXISTS idx_product_media_media_id ON public.product_media US
|
|
|
606
722
|
|
|
607
723
|
CREATE INDEX IF NOT EXISTS idx_product_media_product_id ON public.product_media USING btree (product_id);
|
|
608
724
|
|
|
725
|
+
CREATE INDEX IF NOT EXISTS idx_product_revisions_author_id ON public.product_revisions USING btree (author_id);
|
|
726
|
+
|
|
727
|
+
CREATE INDEX IF NOT EXISTS idx_product_revisions_product_id_version ON public.product_revisions USING btree (product_id, version);
|
|
728
|
+
|
|
609
729
|
CREATE INDEX IF NOT EXISTS idx_product_variants_main_media_id ON public.product_variants USING btree (main_media_id);
|
|
610
730
|
|
|
611
731
|
CREATE INDEX IF NOT EXISTS idx_product_variants_prices_gin ON public.product_variants USING gin (prices jsonb_path_ops);
|
|
@@ -646,14 +766,34 @@ CREATE INDEX IF NOT EXISTS idx_user_trusted_devices_user_id ON public.user_trust
|
|
|
646
766
|
|
|
647
767
|
CREATE INDEX IF NOT EXISTS idx_variant_attribute_mapping_attribute_term_id ON public.variant_attribute_mapping USING btree (attribute_term_id);
|
|
648
768
|
|
|
769
|
+
CREATE INDEX IF NOT EXISTS mcp_access_tokens_created_at_idx ON public.mcp_access_tokens USING btree (created_at DESC);
|
|
770
|
+
|
|
771
|
+
CREATE INDEX IF NOT EXISTS mcp_access_tokens_token_hash_idx ON public.mcp_access_tokens USING btree (token_hash);
|
|
772
|
+
|
|
649
773
|
CREATE INDEX IF NOT EXISTS media_folder_idx ON public.media USING btree (folder);
|
|
650
774
|
|
|
775
|
+
CREATE INDEX IF NOT EXISTS message_threads_last_message_idx ON public.message_threads USING btree (last_message_at DESC);
|
|
776
|
+
|
|
777
|
+
CREATE INDEX IF NOT EXISTS message_threads_source_last_idx ON public.message_threads USING btree (source, last_message_at DESC);
|
|
778
|
+
|
|
779
|
+
CREATE INDEX IF NOT EXISTS message_threads_subject_idx ON public.message_threads USING btree (subject_id) WHERE (subject_id IS NOT NULL);
|
|
780
|
+
|
|
781
|
+
CREATE INDEX IF NOT EXISTS message_threads_unread_idx ON public.message_threads USING btree (last_message_at DESC) WHERE (unread_for_admin = true);
|
|
782
|
+
|
|
783
|
+
CREATE INDEX IF NOT EXISTS pages_status_published_at_idx ON public.pages USING btree (status, published_at);
|
|
784
|
+
|
|
651
785
|
CREATE INDEX IF NOT EXISTS product_drafts_author_id_idx ON public.product_drafts USING btree (author_id);
|
|
652
786
|
|
|
653
787
|
CREATE INDEX IF NOT EXISTS product_drafts_product_id_idx ON public.product_drafts USING btree (product_id);
|
|
654
788
|
|
|
655
789
|
CREATE INDEX IF NOT EXISTS product_drafts_updated_at_idx ON public.product_drafts USING btree (updated_at DESC);
|
|
656
790
|
|
|
791
|
+
CREATE INDEX IF NOT EXISTS product_inquiries_created_idx ON public.product_inquiries USING btree (created_at DESC);
|
|
792
|
+
|
|
793
|
+
CREATE INDEX IF NOT EXISTS product_inquiries_ip_created_idx ON public.product_inquiries USING btree (ip_masked, created_at DESC);
|
|
794
|
+
|
|
795
|
+
CREATE INDEX IF NOT EXISTS product_inquiries_unresolved_idx ON public.product_inquiries USING btree (created_at DESC) WHERE (is_resolved = false);
|
|
796
|
+
|
|
657
797
|
CREATE INDEX IF NOT EXISTS product_variants_sale_window_idx ON public.product_variants USING btree (sale_start_at, sale_end_at) WHERE ((sale_start_at IS NOT NULL) OR (sale_end_at IS NOT NULL));
|
|
658
798
|
|
|
659
799
|
CREATE INDEX IF NOT EXISTS product_variants_scheduled_price_idx ON public.product_variants USING btree (scheduled_price_at) WHERE (scheduled_price_at IS NOT NULL);
|
|
@@ -662,8 +802,24 @@ CREATE INDEX IF NOT EXISTS products_sale_window_idx ON public.products USING btr
|
|
|
662
802
|
|
|
663
803
|
CREATE INDEX IF NOT EXISTS products_scheduled_price_idx ON public.products USING btree (scheduled_price_at) WHERE (scheduled_price_at IS NOT NULL);
|
|
664
804
|
|
|
805
|
+
CREATE INDEX IF NOT EXISTS products_status_published_at_idx ON public.products USING btree (status, published_at);
|
|
806
|
+
|
|
807
|
+
CREATE INDEX IF NOT EXISTS site_script_revisions_created_idx ON public.site_script_revisions USING btree (created_at DESC);
|
|
808
|
+
|
|
809
|
+
CREATE INDEX IF NOT EXISTS site_script_revisions_script_created_idx ON public.site_script_revisions USING btree (script_id, created_at DESC);
|
|
810
|
+
|
|
811
|
+
CREATE INDEX IF NOT EXISTS site_scripts_active_placement_sort_idx ON public.site_scripts USING btree (is_active, placement, sort_order);
|
|
812
|
+
|
|
813
|
+
CREATE INDEX IF NOT EXISTS site_themes_active_sort_idx ON public.site_themes USING btree (is_active, sort_order);
|
|
814
|
+
|
|
815
|
+
CREATE UNIQUE INDEX IF NOT EXISTS site_themes_single_default_idx ON public.site_themes USING btree (is_default) WHERE (is_default = true);
|
|
816
|
+
|
|
665
817
|
CREATE UNIQUE INDEX IF NOT EXISTS tax_rates_country_state_name_key ON public.tax_rates USING btree (country_code, COALESCE(state_code, ''::text), lower(tax_name));
|
|
666
818
|
|
|
819
|
+
CREATE INDEX IF NOT EXISTS thread_messages_ip_created_idx ON public.thread_messages USING btree (ip_masked, created_at DESC);
|
|
820
|
+
|
|
821
|
+
CREATE INDEX IF NOT EXISTS thread_messages_thread_created_idx ON public.thread_messages USING btree (thread_id, created_at);
|
|
822
|
+
|
|
667
823
|
DO $rb$ BEGIN
|
|
668
824
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'blocks_language_id_fkey' AND conrelid = 'public.blocks'::regclass) THEN
|
|
669
825
|
ALTER TABLE ONLY public.blocks
|
|
@@ -692,6 +848,13 @@ DO $rb$ BEGIN
|
|
|
692
848
|
END IF;
|
|
693
849
|
END $rb$;
|
|
694
850
|
|
|
851
|
+
DO $rb$ BEGIN
|
|
852
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cms_interactions_parent_id_fkey' AND conrelid = 'public.cms_interactions'::regclass) THEN
|
|
853
|
+
ALTER TABLE ONLY public.cms_interactions
|
|
854
|
+
ADD CONSTRAINT cms_interactions_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES public.cms_interactions(id) ON DELETE CASCADE;
|
|
855
|
+
END IF;
|
|
856
|
+
END $rb$;
|
|
857
|
+
|
|
695
858
|
DO $rb$ BEGIN
|
|
696
859
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'cms_interactions_post_id_fkey' AND conrelid = 'public.cms_interactions'::regclass) THEN
|
|
697
860
|
ALTER TABLE ONLY public.cms_interactions
|
|
@@ -804,6 +967,13 @@ DO $rb$ BEGIN
|
|
|
804
967
|
END IF;
|
|
805
968
|
END $rb$;
|
|
806
969
|
|
|
970
|
+
DO $rb$ BEGIN
|
|
971
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'mcp_access_tokens_created_by_fkey' AND conrelid = 'public.mcp_access_tokens'::regclass) THEN
|
|
972
|
+
ALTER TABLE ONLY public.mcp_access_tokens
|
|
973
|
+
ADD CONSTRAINT mcp_access_tokens_created_by_fkey FOREIGN KEY (created_by) REFERENCES auth.users(id) ON DELETE SET NULL;
|
|
974
|
+
END IF;
|
|
975
|
+
END $rb$;
|
|
976
|
+
|
|
807
977
|
DO $rb$ BEGIN
|
|
808
978
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'media_uploader_id_fkey' AND conrelid = 'public.media'::regclass) THEN
|
|
809
979
|
ALTER TABLE ONLY public.media
|
|
@@ -993,6 +1163,20 @@ DO $rb$ BEGIN
|
|
|
993
1163
|
END IF;
|
|
994
1164
|
END $rb$;
|
|
995
1165
|
|
|
1166
|
+
DO $rb$ BEGIN
|
|
1167
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_revisions_author_id_fkey' AND conrelid = 'public.product_revisions'::regclass) THEN
|
|
1168
|
+
ALTER TABLE ONLY public.product_revisions
|
|
1169
|
+
ADD CONSTRAINT product_revisions_author_id_fkey FOREIGN KEY (author_id) REFERENCES public.profiles(id) ON DELETE SET NULL;
|
|
1170
|
+
END IF;
|
|
1171
|
+
END $rb$;
|
|
1172
|
+
|
|
1173
|
+
DO $rb$ BEGIN
|
|
1174
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_revisions_product_id_fkey' AND conrelid = 'public.product_revisions'::regclass) THEN
|
|
1175
|
+
ALTER TABLE ONLY public.product_revisions
|
|
1176
|
+
ADD CONSTRAINT product_revisions_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;
|
|
1177
|
+
END IF;
|
|
1178
|
+
END $rb$;
|
|
1179
|
+
|
|
996
1180
|
DO $rb$ BEGIN
|
|
997
1181
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'product_variants_main_media_id_fkey' AND conrelid = 'public.product_variants'::regclass) THEN
|
|
998
1182
|
ALTER TABLE ONLY public.product_variants
|
|
@@ -1035,6 +1219,13 @@ DO $rb$ BEGIN
|
|
|
1035
1219
|
END IF;
|
|
1036
1220
|
END $rb$;
|
|
1037
1221
|
|
|
1222
|
+
DO $rb$ BEGIN
|
|
1223
|
+
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'thread_messages_thread_id_fkey' AND conrelid = 'public.thread_messages'::regclass) THEN
|
|
1224
|
+
ALTER TABLE ONLY public.thread_messages
|
|
1225
|
+
ADD CONSTRAINT thread_messages_thread_id_fkey FOREIGN KEY (thread_id) REFERENCES public.message_threads(id) ON DELETE CASCADE;
|
|
1226
|
+
END IF;
|
|
1227
|
+
END $rb$;
|
|
1228
|
+
|
|
1038
1229
|
DO $rb$ BEGIN
|
|
1039
1230
|
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'user_addresses_user_id_fkey' AND conrelid = 'public.user_addresses'::regclass) THEN
|
|
1040
1231
|
ALTER TABLE ONLY public.user_addresses
|