-- Setup script for APRS database on PostgreSQL VM (10.0.19.5)
-- Run this as the postgres superuser

-- Create the aprs user with the password from the Kubernetes secret
CREATE USER aprs WITH PASSWORD 'xK9mP2vQ7sR3nL5w';

-- Create the aprs database owned by the aprs user
CREATE DATABASE aprs OWNER aprs;

-- Connect to the aprs database
\c aprs

-- Grant all privileges on the aprs database to the aprs user
GRANT ALL PRIVILEGES ON DATABASE aprs TO aprs;

-- Create schema and grant privileges
GRANT ALL ON SCHEMA public TO aprs;

-- If you need PostGIS extensions (for APRS location data), uncomment:
-- CREATE EXTENSION IF NOT EXISTS postgis;
-- CREATE EXTENSION IF NOT EXISTS postgis_topology;

-- Verify the setup
\du aprs
\l aprs