-- Migration: allow 'admin' in profiles role CHECK constraint
-- Created: 2026-07-13
-- SQLite cannot ALTER a CHECK constraint; rewrite the schema SQL directly
-- via writable_schema. The table layout is unchanged, only the constraint
-- expression gains 'admin'.

PRAGMA writable_schema = ON;
UPDATE sqlite_master
SET sql = REPLACE(sql,
    "role IN ('super_admin', 'partner', 'user')",
    "role IN ('super_admin', 'admin', 'partner', 'user')")
WHERE type = 'table' AND name = 'profiles';
PRAGMA writable_schema = OFF;
