pgdb-docker-orm

Configure PostgreSQL Docker Compose services and manage ORM migrations for local development databases.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/jason23452/my-skill --skill pgdb-docker-orm-jason23452
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: pgdb-docker-orm
Source: https://github.com/jason23452/my-skill/tree/main/devops/pgdb-docker-orm
Command: npx skills add https://github.com/jason23452/my-skill --skill pgdb-docker-orm-jason23452

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Setting up a local PostgreSQL database with Docker and keeping schema changes safe through ORM migrations involves many error-prone details: port conflicts, host versus container connection strings, volume initialization behavior, and destructive migration risks. This Skill standardizes that workflow so database setup and schema changes stay consistent and data-safe. ## Core Features & Use Cases - Docker Compose PostgreSQL setup: Adds or updates a db service with image, environment variables, healthcheck, postgres_data volume, and an automatically allocated host port mapped to container port 5432. - ORM migration workflows: Provides guided flows for Alembic (SQLAlchemy/SQLModel), Prisma, TypeORM, and Django migrations, including review of generated migration files before applying them. - Data safety guardrails: Requires explicit user consent before deleting volumes, resetting schemas, or running destructive migrations, and distinguishes host (localhost:<port>) from container (db:5432) connection strings. - Use Case: A FastAPI project needs a local Postgres instance and new users and orders tables. The Skill bootstraps the Compose db service with a free host port, then walks through Alembic autogenerate, review, upgrade, and verification with psql \dt. ## Quick Start Ask the assistant to set up a local PostgreSQL database with Docker Compose and create the required tables through ORM migrations for your backend project.

Frequently Asked Questions about pgdb-docker-orm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up PostgreSQL with Docker Compose for local development?▼

Define a db service using the postgres:17-alpine image with POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB environment variables, a named volume for data persistence, and a pg_isready healthcheck. Map an available host port to container port 5432 rather than hardcoding 5432:5432.

How do I run Alembic migrations against a Dockerized Postgres database?▼

Update your SQLAlchemy or SQLModel models, ensure the Alembic env.py imports model metadata, then run alembic revision --autogenerate and review the generated file before alembic upgrade head. If the backend runs in Compose, execute the command inside the backend container with docker compose exec.

Should my app connect to localhost or db for a Docker Compose Postgres?▼

Containers inside the same Compose network connect to the service name, such as db:5432. Applications running on the host machine use localhost with the published host port, for example localhost:5433 if that port was allocated.

Why does changing POSTGRES_DB not create the new database?▼

The Postgres image only runs initialization scripts and creates the initial database when the data volume is first created. An existing volume retains the original database, roles, and passwords, so you must create the new database manually or, with explicit consent, recreate the volume.

How do I add a table with Prisma against a Docker Postgres service?▼

Add the model to prisma/schema.prisma with the required fields and constraints, then run npx prisma migrate dev with a descriptive name followed by npx prisma generate. Review the generated SQL in prisma/migrations before treating the schema change as complete.

When should I avoid deleting a Postgres Docker volume?▼

Never delete or recreate a volume without explicit user approval, since it permanently destroys all stored data. Prefer inspecting existing databases with psql, checking Compose logs, and verifying DATABASE_URL settings before considering any volume reset.