-- Seed Karunaratne Lawyers tenant and admin user
WITH tenant_ins AS (
    INSERT INTO tenants (name, dashboard_name, product_name)
    SELECT 'Karunaratne Lawyers', 'Karunatane Lawyers MyCase', 'Karunatane Lawyers MyCase'
    WHERE NOT EXISTS (
        SELECT 1 FROM tenants WHERE name = 'Karunaratne Lawyers'
    )
    RETURNING id
),
user_ins AS (
    INSERT INTO users (tenant_id, full_name, is_admin, password)
    SELECT id, 'Jagath Karunaratne', 1, '$2y$12$fLuD9uy1GPJo.SOUMC6PjeT9kp2xz1Z0QjvEETGwwZuO3tqsml7zq'
    FROM tenant_ins
    RETURNING id
)
INSERT INTO user_emails (user_id, email)
SELECT id, 'jagath@karunaratnelawyers.com.fj' FROM user_ins;

