-- =============================================================================
-- Migration: public.users + first super_admin (no separate "admin" table)
-- =============================================================================
-- This app stores admins in `public.users` with role = 'super_admin'.
-- Run once in Supabase SQL Editor (or psql) against your live DB.
--
-- Default seeded login (CHANGE EMAIL + PASSWORD IN PRODUCTION):
--   Email:    superadmin@example.com
--   Password: ChangeMe123!
--
-- To use your own password, generate a bcrypt hash (12 rounds) from backend:
--   node -e "const b=require('bcryptjs'); b.hash('YourPassword',12).then(console.log)"
-- Then replace the hash in the INSERT below.
-- =============================================================================

create extension if not exists "pgcrypto";

-- updated_at trigger
create or replace function public.set_updated_at()
returns trigger
language plpgsql
as $$
begin
  new.updated_at = now();
  return new;
end;
$$;

drop trigger if exists trg_users_set_updated_at on public.users;
