ck:databases

Design and optimize MongoDB and PostgreSQL schemas, queries, and migrations.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/hidonguyen/trade-ops --skill ck-databases-hidonguyen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ck:databases
Source: https://github.com/hidonguyen/trade-ops/tree/main/.opencode/skills/databases
Command: npx skills add https://github.com/hidonguyen/trade-ops --skill ck-databases-hidonguyen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pymongo, psycopg2, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Designing reliable schemas, writing efficient queries, and operating production-grade MongoDB and PostgreSQL databases is complex and error-prone; this Skill streamlines schema design, migrations, indexing, query optimization, backups, and performance troubleshooting so teams can ship data-driven features faster and with fewer regressions.

Core Features & Use Cases

  • Schema Design: OLTP and OLAP guidance, naming conventions, surrogate keys, SCD strategies, and fact/dimension modeling for analytics.
  • Query & Pipeline Authoring: PostgreSQL SQL (joins, CTEs, window functions, EXPLAIN analysis) and MongoDB aggregation pipelines, lookups, and array handling.
  • Migrations & Rollback: Generate, apply, and rollback migrations for both PostgreSQL and MongoDB with safe recording of applied migrations.
  • Indexing & Performance: Recommend indexes, detect sequential scans, analyze pg_stat_statements, and advise on index/GIN/BRIN/GiST strategies and MongoDB index patterns.
  • Backups & Restore: Create and verify backups, restore workflows, and retention/cleanup strategies for both databases.
  • Administration: User/role management, replication (streaming/logical), WAL/PITR guidance, and psql/mongosh CLI usage.
  • Use Case: Convert an ad-hoc reporting workload into a star-schema fact table, add the necessary indexes, and provide migration and ETL watermarks so dashboards run within SLA.

Quick Start

Use this skill to design a PostgreSQL OLTP schema for orders, propose indexes, and produce migration SQL plus a rollback plan.

Frequently Asked Questions about ck:databases

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

FAQPage Schema
How do I optimize PostgreSQL queries using EXPLAIN analysis and indexing?

To optimize PostgreSQL queries, you analyze execution plans using EXPLAIN, detect sequential scans, and resolve bottlenecks by recommending targeted indexes like GIN, BRIN, or GiST based on query patterns and pg_stat_statements data.

What is the best way to design MongoDB aggregation pipelines and queries?

Designing MongoDB aggregation pipelines involves structuring lookups, array handling, and stage operations efficiently. You apply specific MongoDB index patterns to support pipeline operations and ensure queries avoid collection scans for optimal performance.

How do I generate and rollback database migrations for PostgreSQL and MongoDB?

Generating database migrations involves producing DDL or migration files for schema changes. You apply these migrations safely while recording applied states, allowing you to execute rollback procedures to revert schema changes for both PostgreSQL and MongoDB.

How do I create and verify PostgreSQL backups and restore workflows?

Creating PostgreSQL backups involves generating backup files and defining restore workflows. You establish retention and cleanup strategies, verify backup integrity, and configure Point-in-Time Recovery using WAL to ensure reliable data restoration.

Can I convert an ad-hoc reporting workload into a star-schema fact table?

Yes, you can convert ad-hoc reporting workloads into star-schema fact tables by applying OLAP schema design. This process models fact and dimension tables, adds necessary indexes, and provides ETL watermarks to ensure dashboards meet SLA.

Does this database design skill handle both OLTP and OLAP schema modeling?

Yes, it handles both OLTP and OLAP schema modeling. For OLTP, it focuses on naming conventions and surrogate keys, while OLAP modeling involves fact and dimension table design with Slowly Changing Dimension strategies for analytics.