@nextblock-cms/db 0.11.3 → 0.12.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.
Files changed (62) hide show
  1. package/lib/supabase/server.d.ts +9 -0
  2. package/lib/supabase/types.d.ts +9 -0
  3. package/package.json +1 -1
  4. package/supabase/migrations/00000000000000_baseline_schema.sql +2454 -0
  5. package/supabase/migrations/00000000000001_baseline_constraints_and_indexes.sql +1071 -0
  6. package/supabase/migrations/00000000000002_baseline_security_and_grants.sql +1335 -0
  7. package/supabase/migrations/00000000000003_baseline_seed.sql +468 -0
  8. package/supabase/migrations/00000000000004_default_logo_email_safe.sql +24 -0
  9. package/supabase/migrations/00000000000005_add_custom_canonical.sql +13 -0
  10. package/supabase/migrations/00000000000006_home_live_demo_promo.sql +67 -0
  11. package/supabase/migrations/00000000000007_home_live_demo_promo_copy_fix.sql +49 -0
  12. package/supabase/templates/confirmation.html +1 -1
  13. package/supabase/templates/email_change.html +1 -1
  14. package/supabase/templates/invite.html +1 -1
  15. package/supabase/templates/magic_link.html +1 -1
  16. package/supabase/templates/reauthentication.html +1 -1
  17. package/supabase/templates/recovery.html +1 -1
  18. package/supabase/migrations/00000000000000_setup_foundation_and_enums.sql +0 -40
  19. package/supabase/migrations/00000000000001_setup_cms_core.sql +0 -124
  20. package/supabase/migrations/00000000000002_setup_content_tables.sql +0 -138
  21. package/supabase/migrations/00000000000003_setup_catalog_and_licensing.sql +0 -160
  22. package/supabase/migrations/00000000000004_setup_fulfillment_shipping_taxes_and_currencies.sql +0 -797
  23. package/supabase/migrations/00000000000005_setup_functions_and_triggers.sql +0 -767
  24. package/supabase/migrations/00000000000006_setup_rls_and_grants.sql +0 -872
  25. package/supabase/migrations/00000000000007_setup_indexes.sql +0 -158
  26. package/supabase/migrations/00000000000008_seed_platform_defaults.sql +0 -155
  27. package/supabase/migrations/00000000000009_seed_translations.sql +0 -801
  28. package/supabase/migrations/00000000000010_seed_content_scaffold.sql +0 -1088
  29. package/supabase/migrations/00000000000011_setup_cortex_ai_settings.sql +0 -81
  30. package/supabase/migrations/00000000000012_setup_commerce_coupons.sql +0 -275
  31. package/supabase/migrations/00000000000013_setup_cortex_ai_db_mutation_audit.sql +0 -47
  32. package/supabase/migrations/00000000000014_setup_content_drafts.sql +0 -119
  33. package/supabase/migrations/00000000000015_setup_product_drafts.sql +0 -97
  34. package/supabase/migrations/00000000000016_add_feature_image_to_pages.sql +0 -8
  35. package/supabase/migrations/00000000000017_add_product_blocks.sql +0 -118
  36. package/supabase/migrations/00000000000018_setup_bot_protection_settings.sql +0 -77
  37. package/supabase/migrations/00000000000019_add_product_categories.sql +0 -64
  38. package/supabase/migrations/00000000000020_add_category_translations.sql +0 -10
  39. package/supabase/migrations/00000000000021_migrate_hero_blocks_to_sections.sql +0 -29
  40. package/supabase/migrations/00000000000022_seed_cortex_ai_guide_post.sql +0 -184
  41. package/supabase/migrations/00000000000023_setup_custom_block_definitions.sql +0 -183
  42. package/supabase/migrations/00000000000024_setup_ucp_cart_sessions.sql +0 -72
  43. package/supabase/migrations/00000000000025_add_sale_schedule_columns.sql +0 -406
  44. package/supabase/migrations/00000000000026_seed_on_sale_translation.sql +0 -9
  45. package/supabase/migrations/00000000000027_setup_privacy_and_mfa.sql +0 -479
  46. package/supabase/migrations/00000000000028_clear_advisor_warnings.sql +0 -93
  47. package/supabase/migrations/00000000000029_refresh_setup_article.sql +0 -252
  48. package/supabase/migrations/00000000000030_setup_system_configuration.sql +0 -80
  49. package/supabase/migrations/00000000000031_seed_footer_navigation.sql +0 -85
  50. package/supabase/migrations/00000000000032_neutralize_seeded_contact_emails.sql +0 -34
  51. package/supabase/migrations/00000000000033_setup_config_settings.sql +0 -99
  52. package/supabase/migrations/00000000000034_enable_staff_2fa_reminder_default.sql +0 -15
  53. package/supabase/migrations/00000000000035_reassert_advisor_fixes.sql +0 -33
  54. package/supabase/migrations/00000000000036_setup_system_alerts.sql +0 -72
  55. package/supabase/migrations/00000000000037_refresh_setup_article_install_paths.sql +0 -317
  56. package/supabase/migrations/00000000000038_seed_consent_banner_translations.sql +0 -126
  57. package/supabase/migrations/00000000000039_setup_interactions.sql +0 -153
  58. package/supabase/migrations/00000000000040_add_profiles_fk_to_interactions.sql +0 -8
  59. package/supabase/migrations/00000000000041_seed_interactions_translations.sql +0 -145
  60. package/supabase/migrations/00000000000042_seed_deploy_to_vercel_ctas.sql +0 -72
  61. package/supabase/migrations/00000000000043_swap_home_hero_media_to_youtube.sql +0 -42
  62. package/supabase/migrations/00000000000044_swap_article_nx_graph_for_youtube.sql +0 -66
@@ -1,160 +0,0 @@
1
- -- 00000000000003_setup_catalog_and_licensing.sql
2
- -- Consolidated migration preserving original statement order within grouped sections.
3
-
4
- -- 00000000000009_setup_products_and_media.sql
5
- -- Core product catalog tables.
6
-
7
- CREATE TABLE public.products (
8
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
9
- language_id bigint NOT NULL REFERENCES public.languages(id) ON DELETE CASCADE,
10
- translation_group_id uuid NOT NULL DEFAULT gen_random_uuid(),
11
- sku text NOT NULL,
12
- title text NOT NULL,
13
- slug text NOT NULL,
14
- product_type text NOT NULL CHECK (product_type IN ('physical', 'digital')),
15
- payment_provider text NOT NULL CHECK (payment_provider IN ('stripe', 'freemius')),
16
- price integer NOT NULL,
17
- prices jsonb NOT NULL DEFAULT '{}'::jsonb,
18
- sale_price integer,
19
- sale_prices jsonb,
20
- stock integer DEFAULT 0,
21
- status text NOT NULL CHECK (status IN ('draft', 'active', 'archived')) DEFAULT 'draft',
22
- meta_title text,
23
- meta_description text,
24
- short_description text,
25
- description_json jsonb,
26
- metadata jsonb,
27
- freemius_plan_id text,
28
- freemius_product_id text,
29
- trial_period_days integer NOT NULL DEFAULT 0 CHECK (trial_period_days >= 0),
30
- trial_requires_payment_method boolean NOT NULL DEFAULT false,
31
- upc text,
32
- is_taxable boolean NOT NULL DEFAULT true,
33
- created_at timestamptz DEFAULT now(),
34
- updated_at timestamptz DEFAULT now(),
35
- CONSTRAINT products_type_provider_consistency_check CHECK (
36
- (product_type = 'physical' AND payment_provider = 'stripe')
37
- OR (product_type = 'digital' AND payment_provider = 'freemius')
38
- ),
39
- CONSTRAINT products_language_id_slug_key UNIQUE (language_id, slug),
40
- CONSTRAINT products_language_id_sku_key UNIQUE (language_id, sku)
41
- );
42
-
43
- COMMENT ON COLUMN public.products.is_taxable IS
44
- 'When true, this product participates in Stripe tax calculation.';
45
- COMMENT ON COLUMN public.products.prices IS
46
- 'Regular prices by ISO 4217 code in the smallest currency unit.';
47
- COMMENT ON COLUMN public.products.sale_prices IS
48
- 'Sale prices by ISO 4217 code in the smallest currency unit.';
49
-
50
- CREATE TABLE public.product_media (
51
- product_id uuid NOT NULL REFERENCES public.products(id) ON DELETE CASCADE,
52
- media_id uuid NOT NULL REFERENCES public.media(id) ON DELETE CASCADE,
53
- sort_order integer DEFAULT 0,
54
- PRIMARY KEY (product_id, media_id)
55
- );
56
-
57
- -- 00000000000010_setup_product_variants_and_attributes.sql
58
- -- Variant attributes, terms, and sellable variants.
59
-
60
- CREATE TABLE public.product_attributes (
61
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
62
- name text NOT NULL,
63
- slug text NOT NULL UNIQUE,
64
- name_translations jsonb NOT NULL DEFAULT '{}'::jsonb,
65
- created_at timestamptz DEFAULT now(),
66
- updated_at timestamptz DEFAULT now()
67
- );
68
-
69
- CREATE TABLE public.product_attribute_terms (
70
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
71
- attribute_id uuid NOT NULL REFERENCES public.product_attributes(id) ON DELETE CASCADE,
72
- value text NOT NULL,
73
- slug text NOT NULL,
74
- sort_order integer NOT NULL DEFAULT 0,
75
- value_translations jsonb NOT NULL DEFAULT '{}'::jsonb,
76
- created_at timestamptz DEFAULT now(),
77
- updated_at timestamptz DEFAULT now(),
78
- CONSTRAINT product_attribute_terms_attribute_id_slug_key UNIQUE (attribute_id, slug)
79
- );
80
-
81
- CREATE TABLE public.product_variants (
82
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
83
- product_id uuid NOT NULL REFERENCES public.products(id) ON DELETE CASCADE,
84
- sku text NOT NULL,
85
- price_adjustment integer NOT NULL DEFAULT 0,
86
- price integer NOT NULL DEFAULT 0,
87
- prices jsonb NOT NULL DEFAULT '{}'::jsonb,
88
- sale_price integer,
89
- sale_prices jsonb,
90
- stock_quantity integer NOT NULL DEFAULT 0,
91
- upc text,
92
- main_media_id uuid REFERENCES public.media(id) ON DELETE SET NULL,
93
- created_at timestamptz DEFAULT now(),
94
- updated_at timestamptz DEFAULT now(),
95
- CONSTRAINT product_variants_product_id_sku_key UNIQUE (product_id, sku)
96
- );
97
-
98
- COMMENT ON COLUMN public.product_variants.prices IS
99
- 'Variant regular prices by ISO 4217 code in the smallest currency unit.';
100
- COMMENT ON COLUMN public.product_variants.sale_prices IS
101
- 'Variant sale prices by ISO 4217 code in the smallest currency unit.';
102
-
103
- CREATE TABLE public.inventory_items (
104
- sku text PRIMARY KEY,
105
- quantity integer NOT NULL DEFAULT 0 CHECK (quantity >= 0),
106
- created_at timestamptz NOT NULL DEFAULT now(),
107
- updated_at timestamptz NOT NULL DEFAULT now()
108
- );
109
-
110
- COMMENT ON TABLE public.inventory_items IS
111
- 'Source-of-truth inventory records keyed by sellable SKU.';
112
- COMMENT ON COLUMN public.inventory_items.sku IS
113
- 'Global sellable SKU. Matching products or variants share inventory.';
114
- COMMENT ON COLUMN public.inventory_items.quantity IS
115
- 'Available quantity for this SKU.';
116
-
117
- CREATE TABLE public.variant_attribute_mapping (
118
- variant_id uuid NOT NULL REFERENCES public.product_variants(id) ON DELETE CASCADE,
119
- attribute_term_id uuid NOT NULL REFERENCES public.product_attribute_terms(id) ON DELETE CASCADE,
120
- PRIMARY KEY (variant_id, attribute_term_id)
121
- );
122
-
123
- -- 00000000000011_setup_licensing_and_freemius.sql
124
- -- Package activations and Freemius plan metadata.
125
-
126
- CREATE TABLE public.package_activations (
127
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
128
- license_key text NOT NULL,
129
- instance_name text NOT NULL,
130
- package_id text NOT NULL,
131
- status text NOT NULL DEFAULT 'active',
132
- meta jsonb DEFAULT '{}'::jsonb,
133
- last_validated_at timestamptz DEFAULT now(),
134
- created_at timestamptz DEFAULT now(),
135
- UNIQUE (license_key, package_id)
136
- );
137
-
138
- CREATE TABLE public.freemius_plans (
139
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
140
- product_id uuid NOT NULL REFERENCES public.products(id) ON DELETE CASCADE,
141
- name text NOT NULL,
142
- title text,
143
- created_at timestamptz NOT NULL DEFAULT now(),
144
- updated_at timestamptz NOT NULL DEFAULT now()
145
- );
146
-
147
- CREATE TABLE public.freemius_pricing (
148
- id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
149
- plan_id uuid NOT NULL REFERENCES public.freemius_plans(id) ON DELETE CASCADE,
150
- api_monthly_price numeric,
151
- api_annual_price numeric,
152
- api_lifetime_price numeric,
153
- override_monthly_price numeric,
154
- override_annual_price numeric,
155
- override_lifetime_price numeric,
156
- license_quota integer,
157
- is_active boolean NOT NULL DEFAULT true,
158
- created_at timestamptz NOT NULL DEFAULT now(),
159
- updated_at timestamptz NOT NULL DEFAULT now()
160
- );