using Microsoft.EntityFrameworkCore;

public static class DbResetHelper
{
    // Truncate all data between tests — faster than dropping and re-creating
    // the database, and preserves the schema (migrations do not re-run).
    public static async Task ResetAsync(AppDbContext db)
    {
        await db.Database.ExecuteSqlRawAsync(@"
            TRUNCATE TABLE live_observations, live_encounters,
                    clinical.clinical_alerts, clinical.alert_thresholds,
                    clinical.outbox_events, clinical.observations,
                    clinical.encounters, clinical.patients,
                    idempotency_records, promotion_attempts,
                    digitization_events, draft_observations,
                    draft_encounters, draft_patients,
                    scanned_documents, digitization_batches, users
            RESTART IDENTITY CASCADE;
        ");
    }
}