-- S001__seed_admin.sql
-- Seeds the default admin user for SIG-CM2
-- BCrypt hash of '@Diego550@' at cost 12
-- Generated: 2026-04-13

SET QUOTED_IDENTIFIER ON;
SET ANSI_NULLS ON;
SET NOCOUNT ON;
GO

IF NOT EXISTS (SELECT 1 FROM dbo.Usuario WHERE Username = 'admin')
BEGIN
    INSERT INTO dbo.Usuario (Username, PasswordHash, Nombre, Apellido, Email, Rol, PermisosJson, Activo)
    VALUES (
        'admin',
        '$2a$12$rmq6tlSAQ8WXhR2CwLCSeuwCJKz/.8Eab95UQCUNfwe4dokeOqMcW',
        'Administrador',
        'Sistema',
        NULL,
        'admin',
        '["*"]',
        1
    );
    PRINT 'Admin user seeded successfully.';
END
ELSE
BEGIN
    PRINT 'Admin user already exists — skipping.';
END
GO
