# Scripts Directory This directory contains database initialization scripts and other utility scripts for the Paper Dynasty web app. ## Files ### `init-db.sql` PostgreSQL initialization script that runs when the Docker container is first created: - **Creates test database**: `paper_dynasty_test` for integration testing - **Grants permissions**: Ensures `paper_dynasty_user` has access to both databases - **Runs automatically**: Executed by Docker Compose on first container startup ## Database Setup The `init-db.sql` script is automatically executed when the PostgreSQL container starts for the first time via Docker's `docker-entrypoint-initdb.d` mechanism. ### What it creates: ```sql -- Main development database (created by POSTGRES_DB env var) -- paper_dynasty -- Test database for integration tests CREATE DATABASE paper_dynasty_test; -- User permissions GRANT ALL PRIVILEGES ON DATABASE paper_dynasty TO paper_dynasty_user; GRANT ALL PRIVILEGES ON DATABASE paper_dynasty_test TO paper_dynasty_user; ``` ### Container Integration The script is mounted into the PostgreSQL container via `docker-compose.yml`: ```yaml volumes: - ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql ``` ## Future Scripts This directory can be extended with additional utility scripts: - **Migration scripts**: Database schema migrations - **Data seeding**: Sample data for development - **Backup scripts**: Database backup utilities - **Development helpers**: Setup and maintenance scripts