mcpField
P
postgres

postgres

github.com/digitalocean-labsData & databases3888 installsUpdated 6d ago
Repository

About postgres

A skill for configuring DigitalOcean Managed Postgres with security isolation and deployment-oriented defaults. It guides application developers through bindable database variables or schema isolation, with scripts and references for setup and maintenance.

Key features

  1. 01Bindable database variables
  2. 02Schema-level tenant isolation
  3. 03Automated setup scripts
  4. 04Schema and user auditing
  5. 05ORM and migration guidance

Use cases

  1. 01Configuring a database for a single application
  2. 02Isolating tenants across shared clusters
  3. 03Granting database permissions
  4. 04Generating connection strings

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/digitalocean-labs/do-app-platform-skills --skill postgres

After installing, type/postgresin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

README.md
reference/
bundled-scripts.md
database-migrations.md
doctl-reference.md
orm-configurations.md
path-a-bindable-vars.md
path-b-schema-isolation.md
troubleshooting.md
scripts/
add_client.py
cleanup_client.py
create_schema_user.py
generate_connection_string.py
get_admin_conn.sh
list_schemas_users.py
secure_setup.py
secure_setup.sh
templates/migrations/
alembic.template.py
templates/orm/
drizzle.template.ts
prisma.template.prisma
sqlalchemy.template.py

Details

From the project README

Postgres Skill

Configure DigitalOcean Managed Postgres databases with proper security isolation and production-ready defaults.

Quick Decision

Need multiple isolated schemas in one database?
├── YES → Path B (Schema Isolation)
└── NO  → Path A (Bindable Variables) ✅ RECOMMENDED

Path A: Bindable Variables (Recommended)

Use when: Single app per database, standard CRUD applications.

Quick Start
# 1. Create cluster + user via doctl (DO stores password internally)
doctl databases create my-app-db --engine pg --region nyc3 --size db-s-1vcpu-2gb
CLUSTER_ID=$(doctl databases list --format ID,Name --no-header | grep my-app-db | awk '{print $1}')
doctl databases db create $CLUSTER_ID myappdb
doctl databases user create $CLUSTER_ID myappuser

# 2. Grant permissions (REQUIRED - users have no access by default!)
# Run: scripts/grant_permissions.sql as doadmin

# 3. Reference in app spec
# .do/app.yaml
databases:
  - name: db
    engine: PG
    production: true
    cluster_name: my-app-db
    db_name: myappdb
    db_user: myappuser

services:
  - name: api
    envs:
      - key: DATABASE_URL
        scope: RUN_TIME
        value: ${db.DATABASE_URL}

Full guide: See path-a-bindable-vars.md


Path B: Schema Isolation

Use when: Multi-tenant SaaS, multiple apps sharing one cluster, schema-level isolation needed.

Quick Start
# Hands-free setup (requires gh CLI)
./scripts/secure_setup.sh \
  --admin-url "$ADMIN_URL" \
  --app-name myapp \
  --schema myapp \
  --repo owner/repo

Password flows directly to GitHub Secrets — never displayed.

Full guide: See path-b-schema-isolation.md


Available Bindable Variables

VariableExample
${db.DATABASE_URL}postgresql://user:pass@host:25060/db?sslmode=require
${db.HOSTNAME}my-db-do-user-123.db.ondigitalocean.com
${db.PORT}25060
${db.USERNAME}myappuser
${db.PASSWORD}(auto-populated)
${db.DATABASE}myappdb
${db.CA_CERT}(certificate content)

Scripts

ScriptPurpose
scripts/secure_setup.shHands-free Path B setup with GitHub Secrets
scripts/create_schema_user.pyCreate isolated schema + user
scripts/list_schemas_users.pyAudit existing schemas/users
scripts/generate_connection_string.pyBuild connection strings

Reference Files


Common Issues (Quick Fixes)

ErrorFix
"permission denied for schema"Run permission SQL as doadmin
"relation does not exist"Check search_path or use schema-qualified names
"too many connections"Create connection pool via doctl
"SSL connection required"Add ?sslmode=require to connection string
Bindable vars not populatedVerify production: true and names match exactly

Full troubleshooting: See troubleshooting.md


Integration with Other Skills

  • → designer: Add database block to app spec
  • → deployment: GitHub Actions workflow with DATABASE_URL secret
  • → devcontainers: Local Postgres with prod parity
  • → troubleshooting: Debug container for connectivity testing

Comments

Markdown supported