-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase_schema.sql
More file actions
65 lines (53 loc) · 1.98 KB
/
supabase_schema.sql
File metadata and controls
65 lines (53 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- Schema SQL para Supabase
-- Execute este SQL no SQL Editor do Supabase
CREATE TABLE IF NOT EXISTS bundles (
-- Identificação
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
url TEXT NOT NULL,
-- Imagens
header_image TEXT,
capsule_image TEXT,
library_image TEXT,
-- Preços
final_price NUMERIC(10, 2),
original_price NUMERIC(10, 2),
discount INTEGER DEFAULT 0,
formatted_final_price TEXT,
formatted_original_price TEXT,
currency TEXT DEFAULT 'BRL',
-- Plataformas (booleanos)
platform_windows BOOLEAN DEFAULT false,
platform_mac BOOLEAN DEFAULT false,
platform_linux BOOLEAN DEFAULT false,
-- VR
vr_supported BOOLEAN DEFAULT false,
vr_only BOOLEAN DEFAULT false,
-- Outros
games_count INTEGER DEFAULT 0,
is_nsfw BOOLEAN DEFAULT false,
coming_soon BOOLEAN DEFAULT false,
-- Timestamps
last_updated TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Índices para performance
CREATE INDEX IF NOT EXISTS idx_bundles_discount ON bundles(discount DESC);
CREATE INDEX IF NOT EXISTS idx_bundles_final_price ON bundles(final_price);
CREATE INDEX IF NOT EXISTS idx_bundles_last_updated ON bundles(last_updated DESC);
CREATE INDEX IF NOT EXISTS idx_bundles_name ON bundles(name);
-- Habilitar Row Level Security (RLS)
ALTER TABLE bundles ENABLE ROW LEVEL SECURITY;
-- Política: Permitir leitura pública (para frontend)
CREATE POLICY "Allow public read access" ON bundles
FOR SELECT
USING (true);
-- Política: Apenas service_role pode inserir/atualizar (scraper)
CREATE POLICY "Allow service_role full access" ON bundles
FOR ALL
USING (auth.role() = 'service_role');
-- Comentários
COMMENT ON TABLE bundles IS 'Steam bundles scrapeados do Orange Pi';
COMMENT ON COLUMN bundles.id IS 'Bundle ID da Steam';
COMMENT ON COLUMN bundles.discount IS 'Desconto em porcentagem (0-100)';
COMMENT ON COLUMN bundles.last_updated IS 'Última vez que foi atualizado pelo scraper';