Initialize Next.js app with Supabase, Brevo config and migration
This commit is contained in:
1 parent
af8dc721a1
commit
8763c5bace
21 files changed
+8299
-1
No files matched your search
@@ -0,0 +1,72 @@
|
||||
-- Schéma pre Modulárny generátor newsletterov (COOP Jednota)
|
||||
|
||||
-- 1. Tabuľka šablón / konceptov newslettera
|
||||
CREATE TABLE IF NOT EXISTS templates (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
title TEXT NOT NULL DEFAULT 'Nový newsletter',
|
||||
status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'ready', 'exported')),
|
||||
data JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
brevo_campaign_id INTEGER,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- Index pre rýchle zoradenie podľa dátumu úpravy
|
||||
CREATE INDEX IF NOT EXISTS idx_templates_updated_at ON templates(updated_at DESC);
|
||||
|
||||
-- 2. Tabuľka cenoviek (Badges)
|
||||
CREATE TABLE IF NOT EXISTS badges (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name TEXT NOT NULL,
|
||||
svg_background_url TEXT,
|
||||
svg_raw TEXT,
|
||||
layers_config JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
preview_image_url TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- 3. Tabuľka uložených profilov mapovania (Data Mapper Presets)
|
||||
CREATE TABLE IF NOT EXISTS mapping_presets (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name TEXT NOT NULL,
|
||||
file_type TEXT NOT NULL CHECK (file_type IN ('csv', 'json', 'xml')),
|
||||
mapping_rules JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- 4. Východiskové referenčné cenovky (Seed dát pre COOP Jednota)
|
||||
INSERT INTO badges (name, svg_raw, layers_config) VALUES
|
||||
(
|
||||
'Žltá AKCIA',
|
||||
'<svg viewBox="0 0 160 80" xmlns="http://www.w3.org/2000/svg"><rect width="160" height="80" rx="8" fill="#ffd100"/><rect x="4" y="4" width="152" height="72" rx="6" fill="none" stroke="#e0001b" stroke-width="3"/></svg>',
|
||||
'[
|
||||
{"id": "l1", "type": "text", "text": "AKCIA", "x": 80, "y": 32, "fontSize": 24, "fontWeight": "900", "fill": "#e0001b", "align": "center"},
|
||||
{"id": "l2", "type": "text", "text": "{zlava}", "x": 80, "y": 64, "fontSize": 22, "fontWeight": "800", "fill": "#001a33", "align": "center"}
|
||||
]'::jsonb
|
||||
),
|
||||
(
|
||||
'Červená SUPER CENA',
|
||||
'<svg viewBox="0 0 160 80" xmlns="http://www.w3.org/2000/svg"><rect width="160" height="80" rx="8" fill="#e0001b"/></svg>',
|
||||
'[
|
||||
{"id": "l1", "type": "text", "text": "SUPER CENA", "x": 80, "y": 34, "fontSize": 18, "fontWeight": "900", "fill": "#ffffff", "align": "center"},
|
||||
{"id": "l2", "type": "text", "text": "{zlava}", "x": 80, "y": 64, "fontSize": 24, "fontWeight": "900", "fill": "#ffd100", "align": "center"}
|
||||
]'::jsonb
|
||||
),
|
||||
(
|
||||
'Percentuálna zľava (Kruh)',
|
||||
'<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="48" fill="#e0001b" stroke="#ffd100" stroke-width="4"/></svg>',
|
||||
'[
|
||||
{"id": "l1", "type": "text", "text": "ZĽAVA", "x": 50, "y": 36, "fontSize": 13, "fontWeight": "800", "fill": "#ffffff", "align": "center"},
|
||||
{"id": "l2", "type": "text", "text": "{zlava}%", "x": 50, "y": 68, "fontSize": 24, "fontWeight": "900", "fill": "#ffd100", "align": "center"}
|
||||
]'::jsonb
|
||||
)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- 5. Nastavenie RLS (Row Level Security) - pre interný nástroj povolíme verejný prístup cez anon kľúč
|
||||
ALTER TABLE templates ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE badges ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE mapping_presets ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
CREATE POLICY "Allow public all on templates" ON templates FOR ALL USING (true) WITH CHECK (true);
|
||||
CREATE POLICY "Allow public all on badges" ON badges FOR ALL USING (true) WITH CHECK (true);
|
||||
CREATE POLICY "Allow public all on mapping_presets" ON mapping_presets FOR ALL USING (true) WITH CHECK (true);
|
||||
Reference in new issue
Block a user