-- Seed opcional para ampliar a base de testes do modulo de contatos
INSERT INTO contatos (
    cliente_id,
    nome,
    email,
    telefone,
    cargo,
    principal,
    status
)
SELECT * FROM (
    SELECT
        c.id,
        'Luciana Costa',
        'luciana.costa@mineradorahorizonte.com',
        '(77) 98888-3333',
        'Analista de Sistemas',
        0,
        'ativo'
    FROM clientes c
    WHERE c.documento = '12.345.678/0001-90'
    LIMIT 1
) AS origem
WHERE NOT EXISTS (
    SELECT 1
    FROM contatos
    WHERE email = 'luciana.costa@mineradorahorizonte.com'
);

INSERT INTO contatos (
    cliente_id,
    nome,
    email,
    telefone,
    cargo,
    principal,
    status
)
SELECT * FROM (
    SELECT
        c.id,
        'Ricardo Lima',
        'ricardo.lima@serraazul.com',
        '(77) 98888-4444',
        'Supervisor de Contratos',
        0,
        'ativo'
    FROM clientes c
    WHERE c.documento = '98.765.432/0001-11'
    LIMIT 1
) AS origem
WHERE NOT EXISTS (
    SELECT 1
    FROM contatos
    WHERE email = 'ricardo.lima@serraazul.com'
);
