managarten/services/mana-auth/sql/001_add_access_tier.sql
Till JS 0d6005dbcc fix(inventar): import FeedbackPage from @manacore/feedback, not shared-ui
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 21:56:19 +02:00

22 lines
889 B
SQL

-- Migration: Add access_tier to users table
-- Run this on production before deploying the new mana-auth version.
-- After this migration, run `drizzle-kit push` or redeploy mana-auth.
--
-- Alternatively, just run `pnpm db:push` from services/mana-auth/ which
-- will apply the schema change automatically via Drizzle Kit.
-- Step 1: Create the enum type (if not exists)
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'access_tier') THEN
CREATE TYPE public.access_tier AS ENUM ('guest', 'public', 'beta', 'alpha', 'founder');
END IF;
END
$$;
-- Step 2: Add the column with default 'public'
ALTER TABLE auth.users
ADD COLUMN IF NOT EXISTS access_tier public.access_tier NOT NULL DEFAULT 'public';
-- Step 3: Set yourself (founder) — replace with your actual email
-- UPDATE auth.users SET access_tier = 'founder' WHERE email = 'your@email.com';