postgresql-operations

star 228

Manage PostgreSQL: schema migrations, performance tuning, backups, monitoring per README-SCHEMA-MAINTENANCE.md

Hack23 By Hack23 schedule Updated 2/1/2026

name: postgresql-operations description: Manage PostgreSQL: schema migrations, performance tuning, backups, monitoring per README-SCHEMA-MAINTENANCE.md license: Apache-2.0

PostgreSQL Operations Skill

Purpose

Manage PostgreSQL database operations including migrations, performance tuning, and backups.

When to Use

  • ✅ Schema migrations with Liquibase
  • ✅ Performance optimization
  • ✅ Backup and recovery
  • ✅ Monitoring and alerting

Liquibase Migrations

<changeSet id="1" author="developer">
    <createTable tableName="politician">
        <column name="id" type="VARCHAR(12)">
            <constraints primaryKey="true"/>
        </column>
        <column name="first_name" type="VARCHAR(50)">
            <constraints nullable="false"/>
        </column>
        <column name="last_name" type="VARCHAR(50)">
            <constraints nullable="false"/>
        </column>
    </createTable>
</changeSet>

Performance Tuning

-- Add indexes for frequently queried columns
CREATE INDEX idx_politician_party ON politician(party);
CREATE INDEX idx_voting_record_date ON voting_record(vote_date);

-- Analyze query performance
EXPLAIN ANALYZE 
SELECT * FROM politician WHERE party = 'S' AND district = 'Stockholm';

-- Update statistics
ANALYZE politician;

Backup Strategy

# Daily backups
pg_dump -h localhost -U cia_user -d cia_production > backup_$(date +%Y%m%d).sql

# Point-in-time recovery setup
wal_level = replica
archive_mode = on
archive_command = 'cp %p /backup/archive/%f'

Monitoring

-- Check connection count
SELECT count(*) FROM pg_stat_activity;

-- Check slow queries
SELECT query, calls, total_time, mean_time 
FROM pg_stat_statements 
ORDER BY mean_time DESC LIMIT 10;

References

Install via CLI
npx skills add https://github.com/Hack23/cia --skill postgresql-operations
Repository Details
star Stars 228
call_split Forks 55
navigation Branch main
article Path SKILL.md
More from Creator