-- create-test-api-db.sql
-- Creates test databases for integration tests (idempotent).
-- Run once per environment on TECNICA3 before executing integration tests.
--
-- SIGCM2_Test_App  -> used by SIGCM2.Application.Tests
-- SIGCM2_Test_Api  -> used by SIGCM2.Api.Tests
-- SIGCM2_Test      -> legacy (kept for old branches e.g. pre-merge CAT-001)
--
-- After creating the DBs, apply V010 to both new DBs:
--   See database/README.md > "Test DBs" section for the PowerShell runbook.

IF DB_ID(N'SIGCM2_Test_App') IS NULL
BEGIN
    CREATE DATABASE [SIGCM2_Test_App]
        COLLATE Modern_Spanish_CI_AS;
    PRINT 'Database SIGCM2_Test_App created.';
END
ELSE
    PRINT 'Database SIGCM2_Test_App already exists -- skip.';
GO

IF DB_ID(N'SIGCM2_Test_Api') IS NULL
BEGIN
    CREATE DATABASE [SIGCM2_Test_Api]
        COLLATE Modern_Spanish_CI_AS;
    PRINT 'Database SIGCM2_Test_Api created.';
END
ELSE
    PRINT 'Database SIGCM2_Test_Api already exists -- skip.';
GO
