Skip to content

henriqueatila/golang-gin-best-practices / skills/golang-gin-psql-dba

golang-gin-psql-dba

Flagged

PostgreSQL DBA for Go Gin APIs. Use when designing schemas, analyzing migrations, choosing indexes, optimizing queries, or selecting extensions (pgvector, PostGIS, TimescaleDB).

FileKindSize
SKILL.mdskill md9.9 KB
metadata.jsonconfig668 B
references/backup-and-recovery-managed-and-schedules.mdmarkdown4.3 KB
references/backup-and-recovery-strategies.mdmarkdown4.8 KB
references/backup-and-recovery-wal-and-validation.mdmarkdown2.7 KB
references/extensions-toolkit-crypto-and-uuid.mdmarkdown4.1 KB
references/extensions-toolkit-partman-and-trgm.mdmarkdown4.5 KB
references/extensions-toolkit-pgaudit-and-stats.mdmarkdown4.3 KB
references/extensions-toolkit-setup-and-cron.mdmarkdown3.8 KB
references/index-strategy-maintenance-and-explain.mdmarkdown4.4 KB
references/index-strategy-types-and-variants.mdmarkdown3.8 KB
references/migration-impact-backfill-and-lock-timeout.mdmarkdown3.5 KB
references/migration-impact-lock-timeout.mdmarkdown4.6 KB
references/migration-impact-locks-and-operations.mdmarkdown6.4 KB
references/paradedb-advanced-search-and-hybrid.mdmarkdown4.7 KB
references/paradedb-go-integration-and-tips.mdmarkdown4.9 KB
references/paradedb-setup-and-basic-search.mdmarkdown4.5 KB
references/pgvector-capacity-and-performance.mdmarkdown4.3 KB
references/pgvector-queries-and-go-integration.mdmarkdown4.4 KB
references/pgvector-setup-and-schema.mdmarkdown4.9 KB
references/postgis-go-integration-and-performance.mdmarkdown3.8 KB
references/postgis-setup-types-and-indexes.mdmarkdown4.3 KB
references/query-performance-pool-and-replicas.mdmarkdown4.6 KB
references/query-performance-stats-and-vacuum.mdmarkdown4.2 KB
references/replication-and-ha-clusters.mdmarkdown3.4 KB
references/replication-and-ha-go-readwrite.mdmarkdown4.0 KB
references/replication-and-ha-go-resilience.mdmarkdown4.8 KB
references/replication-and-ha-lag-monitoring.mdmarkdown3.3 KB
references/replication-and-ha-logical.mdmarkdown2.2 KB
references/replication-and-ha-managed-services.mdmarkdown2.0 KB
references/replication-and-ha-overview.mdmarkdown3.1 KB
references/replication-and-ha-streaming-setup.mdmarkdown3.6 KB
references/row-level-security-go-integration-and-pitfalls.mdmarkdown5.5 KB
references/row-level-security-setup-and-policies.mdmarkdown5.8 KB
references/schema-design-complete-example.mdmarkdown6.9 KB
references/schema-design-constraints-and-normalization.mdmarkdown4.2 KB
references/schema-design-naming-and-types.mdmarkdown3.9 KB
references/schema-design-soft-delete-and-tenancy.mdmarkdown5.1 KB
references/timescaledb-aggregates-compression-retention.mdmarkdown5.7 KB
references/timescaledb-go-integration.mdmarkdown3.5 KB
references/timescaledb-setup-and-hypertables.mdmarkdown4.8 KB

references/replication-and-ha-streaming-setup.md

View on GitHub
# Replication and HA — Streaming Replication Setup

## Primary: postgresql.conf

```ini
# postgresql.conf on primary
wal_level            = replica        # minimum for streaming; use 'logical' if logical replication also needed
max_wal_senders      = 5              # max concurrent standby connections (include headroom for pg_basebackup)
wal_keep_size        = 512MB          # WAL retained on primary; protects against slow standbys
hot_standby          = on             # allows standbys to serve read-only queries (default on since PG 14)

# For synchronous replication (optional)
# synchronous_standby_names = 'standby1'
# synchronous_commit = on
```

Reload with `SELECT pg_reload_conf();` — no restart needed for most of these except `wal_level` and `max_wal_senders`.

## Replication User

```sql
-- Run on primary
CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD 'strong_password_here';
```

In `pg_hba.conf` on primary, allow the standby to connect:

```
# pg_hba.conf — allow standby IP to connect for replication
host  replication  replicator  10.0.0.11/32  scram-sha-256
```

## Standby: Initial Base Backup

```bash
# Run on the standby host — copies primary data directory
pg_basebackup \
  --host=10.0.0.10 \
  --username=replicator \
  --pgdata=/var/lib/postgresql/data \
  --wal-method=stream \
  --checkpoint=fast \
  --progress \
  --verbose
```

## Standby: postgresql.conf + standby.signal (PG 12+)

```ini
# postgresql.conf on standby
primary_conninfo = 'host=10.0.0.10 port=5432 user=replicator password=strong_password_here application_name=standby1'
hot_standby      = on
```

```bash
# Create empty file to signal standby mode (replaces recovery.conf from PG 11 and earlier)
touch /var/lib/postgresql/data/standby.signal
```

Start the standby. Monitor replication on the primary:

```sql
SELECT application_name, state, sync_state, replay_lag
FROM pg_stat_replication;
```

## Docker Compose: Primary + Replica

```yaml
# docker-compose.yml
version: "3.9"

services:
  primary:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: mydb
    volumes:
      - primary_data:/var/lib/postgresql/data
      - ./pg-init/primary.sh:/docker-entrypoint-initdb.d/01-replication.sh
    ports:
      - "5432:5432"

  replica:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: secret
      PGPASSWORD: strong_password_here
    volumes:
      - replica_data:/var/lib/postgresql/data
      - ./pg-init/replica-entrypoint.sh:/entrypoint.sh
    entrypoint: ["/entrypoint.sh"]
    depends_on:
      - primary
    ports:
      - "5433:5432"

volumes:
  primary_data:
  replica_data:
```

```bash
# pg-init/primary.sh — runs inside primary container on first start
psql -U app -c "CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD 'strong_password_here';"
echo "host replication replicator all scram-sha-256" >> /var/lib/postgresql/data/pg_hba.conf
psql -U app -c "SELECT pg_reload_conf();"
```

```bash
# pg-init/replica-entrypoint.sh
#!/bin/bash
set -e

# Wait for primary to be ready
until pg_isready -h primary -p 5432 -U app; do
  echo "waiting for primary..." && sleep 2
done

# Base backup if data directory is empty
if [ ! -f /var/lib/postgresql/data/PG_VERSION ]; then
  pg_basebackup -h primary -U replicator -D /var/lib/postgresql/data \
    --wal-method=stream --checkpoint=fast
  cat >> /var/lib/postgresql/data/postgresql.conf <<EOF
primary_conninfo = 'host=primary port=5432 user=replicator password=strong_password_here'
hot_standby = on
EOF
  touch /var/lib/postgresql/data/standby.signal
fi

exec docker-entrypoint.sh postgres
```
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall