CoolFace
Apppublic

soar-11/number-masking

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
supabase_schema.sql46 linesDownload Raw Back to root
1-- ============================================================2-- Supabase ダッシュボード > SQL Editor に貼り付けて実行3-- ============================================================4 5-- ユーザーテーブル6CREATE TABLE IF NOT EXISTS users (7    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),8    email TEXT UNIQUE NOT NULL,9    stripe_customer_id TEXT,10    created_at TIMESTAMPTZ DEFAULT NOW()11);12 13-- サブスクリプションテーブル14CREATE TABLE IF NOT EXISTS subscriptions (15    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),16    user_id UUID REFERENCES users(id) ON DELETE CASCADE,17    stripe_subscription_id TEXT UNIQUE NOT NULL,18    status TEXT NOT NULL,19    current_period_end TIMESTAMPTZ,20    created_at TIMESTAMPTZ DEFAULT NOW(),21    updated_at TIMESTAMPTZ DEFAULT NOW()22);23 24-- 無料枠使用数テーブル(未サブスクユーザー用・月次リセット)25CREATE TABLE IF NOT EXISTS free_usage (26    email TEXT NOT NULL,27    month TEXT NOT NULL,28    used INTEGER DEFAULT 0,29    PRIMARY KEY (email, month)30);31 32-- マスキング実行履歴テーブル33CREATE TABLE IF NOT EXISTS masking_history (34    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),35    email TEXT NOT NULL,36    success_count INTEGER DEFAULT 0,37    fail_count INTEGER DEFAULT 0,38    is_subscribed BOOLEAN DEFAULT FALSE,39    processed_at TIMESTAMPTZ DEFAULT NOW()40);41 42-- インデックス43CREATE INDEX IF NOT EXISTS idx_subscriptions_user_id ON subscriptions(user_id);44CREATE INDEX IF NOT EXISTS idx_masking_history_email ON masking_history(email);45CREATE INDEX IF NOT EXISTS idx_masking_history_processed_at ON masking_history(processed_at DESC);46