-- Enable pgcrypto extension for hashing
CREATE EXTENSION IF NOT EXISTS "pgcrypto";

-- Add master_code_hash column to profiles
ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS master_code_hash TEXT;

-- Set a default master code for Kenan Karaer (or all admins)
-- The hash below is for '123456' using bcrypt
-- You can generate new hashes using: select crypt('YOUR_CODE', gen_salt('bf'));
UPDATE public.profiles
SET master_code_hash = crypt('271210220792', gen_salt('bf'))
WHERE role = 'admin';
