Download supabase_setup.sql from felix-fx/fx-1: direct link, hf CLI and curl.
- Browser
- Download file 2.52 kB
-
https://huggingface.co/felix-fx/fx-1/resolve/main/supabase_setup.sql
- Command line
-
hf download hf://felix-fx/fx-1/supabase_setup.sql
-
curl -L -o supabase_setup.sql https://huggingface.co/felix-fx/fx-1/resolve/main/supabase_setup.sql
2.52 kB
| -- SQL Schema for Craft-FX Addons Management | |
| -- This script creates the addons table and sets up Row Level Security (RLS) | |
| -- إنشاء جدول الإضافات (Addons Table) | |
| CREATE TABLE IF NOT EXISTS public.addons ( | |
| id UUID PRIMARY KEY DEFAULT gen_random_uuid(), | |
| created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), | |
| updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), | |
| -- بيانات الإضافة الأساسية | |
| title TEXT NOT NULL, | |
| description TEXT NOT NULL, | |
| short_description TEXT, | |
| icon_url TEXT, | |
| -- بيانات Modrinth | |
| modrinth_id TEXT UNIQUE, | |
| modrinth_slug TEXT UNIQUE, | |
| project_type TEXT NOT NULL DEFAULT 'mod', -- mod, resourcepack, modpack | |
| -- بيانات الملف والنسخة | |
| file_size BIGINT, | |
| minecraft_versions JSONB DEFAULT '[]'::jsonb, | |
| -- حالة الرفع (لإدارة الظهور) | |
| upload_status TEXT DEFAULT 'unlisted', -- unlisted, published, rejected | |
| -- بيانات المستخدم (إذا كان مسجلاً) | |
| user_id UUID REFERENCES auth.users(id) ON DELETE SET NULL | |
| ); | |
| -- دالة لتحديث حقل updated_at تلقائياً | |
| CREATE OR REPLACE FUNCTION update_updated_at_column() | |
| RETURNS TRIGGER AS $$ | |
| BEGIN | |
| NEW.updated_at = NOW(); | |
| RETURN NEW; | |
| END; | |
| $$ LANGUAGE plpgsql; | |
| -- تفعيل التريجر لتحديث الوقت | |
| DROP TRIGGER IF EXISTS update_addons_updated_at ON public.addons; | |
| CREATE TRIGGER update_addons_updated_at | |
| BEFORE UPDATE ON public.addons | |
| FOR EACH ROW | |
| EXECUTE FUNCTION update_updated_at_column(); | |
| -- تفعيل Row Level Security (RLS) | |
| ALTER TABLE public.addons ENABLE ROW LEVEL SECURITY; | |
| -- سياسة القراءة للجمهور (عرض الإضافات المنشورة فقط) | |
| DROP POLICY IF EXISTS "public_read_published_addons" ON public.addons; | |
| CREATE POLICY "public_read_published_addons" ON public.addons | |
| FOR SELECT USING (upload_status = 'published'); | |
| -- سياسة الإدراج للـ service_role (للباك إند فقط) | |
| -- ملاحظة: service_role يتجاوز RLS افتراضياً، لكن السياسة للتوثيق والأمان الإضافي | |
| DROP POLICY IF EXISTS "service_insert_addons" ON public.addons; | |
| CREATE POLICY "service_insert_addons" ON public.addons | |
| FOR INSERT WITH CHECK (true); | |
| -- سياسة التحديث للـ service_role | |
| DROP POLICY IF EXISTS "service_update_addons" ON public.addons; | |
| CREATE POLICY "service_update_addons" ON public.addons | |
| FOR UPDATE USING (true); | |