-- ============================================================================
-- TEST DATABASE TEARDOWN SCRIPT
-- ============================================================================
-- Purpose:
-- This script cleans up the temporary database and user created for testing.
-- It should be run after the test suite has completed.

-- Terminate any active connections to the test database to allow it to be dropped.
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'flyer-crawler-test';

DROP DATABASE IF EXISTS "flyer-crawler-test";
DROP ROLE IF EXISTS test_runner;