File size: 1,234 Bytes
c35213b | 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 | -- Create the web_drops table
CREATE TABLE IF NOT EXISTS public.web_drops (
id BIGSERIAL PRIMARY KEY,
user_id TEXT NOT NULL,
title TEXT NOT NULL,
description TEXT,
status TEXT DEFAULT 'ACTIVE',
is_external BOOLEAN DEFAULT FALSE,
asset_id TEXT,
file_url TEXT,
image_url TEXT,
category TEXT DEFAULT 'sources',
published_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- Create the vip_users table
CREATE TABLE IF NOT EXISTS public.vip_users (
discord_id TEXT PRIMARY KEY,
purchased_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP WITH TIME ZONE
);
-- Enable Row Level Security (RLS)
ALTER TABLE public.web_drops ENABLE ROW LEVEL SECURITY;
ALTER TABLE public.vip_users ENABLE ROW LEVEL SECURITY;
-- Create policies for public reading
CREATE POLICY "Allow public read access on web_drops"
ON public.web_drops FOR SELECT
USING (true);
CREATE POLICY "Allow public read access on vip_users"
ON public.vip_users FOR SELECT
USING (true);
-- Indices for performance
CREATE INDEX IF NOT EXISTS idx_web_drops_category ON public.web_drops(category);
CREATE INDEX IF NOT EXISTS idx_web_drops_published_at ON public.web_drops(published_at DESC);
|