Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
yonatangross avatar

Database Patterns

  • 189 installs
  • 213 repo stars
  • Updated August 4, 2026
  • yonatangross/orchestkit

Design schemas, migrations, indexing, and query patterns when implementing persistence for SaaS APIs, ecommerce catalogs, or multi-tenant backends in OrchestKit projects.

About

OrchestKit database-patterns skill encodes proven relational and application-level data patterns for backends: schema design, migrations, indexes, transactions, and safe query shapes so agents implement durable storage without reinventing conventions.

  • Schema and migration patterns
  • Indexing and query optimization
  • Transactional consistency guidance
  • Multi-tenant data modeling
  • Repository and ORM conventions

Database Patterns by the numbers

  • 189 all-time installs (skills.sh)
  • +1 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #234 of 911 Databases skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/yonatangross/orchestkit --skill database-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs189
repo stars213
Last updatedAugust 4, 2026
Repositoryyonatangross/orchestkit

What it does

Design schemas, migrations, indexing, and query patterns when implementing persistence for SaaS APIs, ecommerce catalogs, or multi-tenant backends in OrchestKit projects.

Files

SKILL.mdMarkdownGitHub ↗

<!-- directive-density: intentional (teaches migration anti-patterns; NEVER markers describe real production-break conditions, not aspirational guidance) -->

Database Patterns

Comprehensive patterns for database migrations, schema design, and version management. Each category has individual rule files in rules/ loaded on-demand.

Quick Reference

CategoryRulesImpactWhen to Use
Alembic Migrations3CRITICALAutogenerate, data migrations, branch management
Schema Design3HIGHNormalization, indexing strategies, NoSQL patterns
Versioning3HIGHChangelogs, rollback plans, schema drift detection
Zero-Downtime Migration2CRITICALExpand-contract, pgroll, rollback monitoring

| Database Selection | 1 | HIGH | Choosing the right database, PostgreSQL vs MongoDB, cost analysis |

Total: 12 rules across 5 categories

Quick Start

# Alembic: Auto-generate migration from model changes
# alembic revision --autogenerate -m "add user preferences"

def upgrade() -> None:
    op.add_column('users', sa.Column('org_id', UUID(as_uuid=True), nullable=True))
    op.execute("UPDATE users SET org_id = 'default-org-uuid' WHERE org_id IS NULL")

def downgrade() -> None:
    op.drop_column('users', 'org_id')
-- Schema: Normalization to 3NF with proper indexing
-- PG18: prefer uuidv7() (time-ordered, better B-tree locality) over gen_random_uuid() (random v4)
CREATE TABLE orders (
    id UUID PRIMARY KEY DEFAULT uuidv7(),
    customer_id UUID NOT NULL REFERENCES customers(id),
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_orders_customer_id ON orders(customer_id);

Alembic Migrations

Migration management with Alembic for SQLAlchemy 2.0 async applications.

RuleFileKey Pattern
Autogenerate${CLAUDE_SKILL_DIR}/rules/alembic-autogenerate.mdAuto-generate from models, async env.py, review workflow
Data Migration${CLAUDE_SKILL_DIR}/rules/alembic-data-migration.mdBatch backfill, two-phase NOT NULL, zero-downtime
Branching${CLAUDE_SKILL_DIR}/rules/alembic-branching.mdFeature branches, merge migrations, conflict resolution

Schema Design

SQL and NoSQL schema design with normalization, indexing, and constraint patterns.

RuleFileKey Pattern
Normalization${CLAUDE_SKILL_DIR}/rules/schema-normalization.md1NF-3NF, when to denormalize, JSON vs normalized
Indexing${CLAUDE_SKILL_DIR}/rules/schema-indexing.mdB-tree, GIN, HNSW, partial/covering indexes
NoSQL Patterns${CLAUDE_SKILL_DIR}/rules/schema-nosql.mdEmbed vs reference, document design, sharding

Versioning

Database version control and change management across environments.

RuleFileKey Pattern
Changelog${CLAUDE_SKILL_DIR}/rules/versioning-changelog.mdSchema version table, semantic versioning, audit trails
Rollback${CLAUDE_SKILL_DIR}/rules/versioning-rollback.mdRollback testing, destructive rollback docs, CI verification
Drift Detection${CLAUDE_SKILL_DIR}/rules/versioning-drift.mdEnvironment sync, checksum verification, migration locks

Database Selection

Decision frameworks for choosing the right database. Default: PostgreSQL.

RuleFileKey Pattern
Selection Guide${CLAUDE_SKILL_DIR}/rules/db-selection.mdPostgreSQL-first, tier-based matrix, anti-patterns

Key Decisions

DecisionRecommendationRationale
Async dialectpostgresql+asyncpgNative async support for SQLAlchemy 2.0
NOT NULL columnTwo-phase: nullable first, then alterAvoids locking, backward compatible
Large table indexCREATE INDEX CONCURRENTLYZero-downtime, no table locks
Normalization target3NF for OLTPReduces redundancy while maintaining query performance
Primary key strategyUUID for distributed, INT for single-DBContext-appropriate key generation
Soft deletesdeleted_at timestamp columnPreserves audit trail, enables recovery
Migration granularityOne logical change per fileEasier rollback and debugging
Production deploymentGenerate SQL, review, then applyNever auto-run in production

Anti-Patterns (FORBIDDEN)

# NEVER: Add NOT NULL without default or two-phase approach
op.add_column('users', sa.Column('org_id', UUID, nullable=False))  # LOCKS TABLE!

# NEVER: Use blocking index creation on large tables
op.create_index('idx_large', 'big_table', ['col'])  # Use CONCURRENTLY

# NEVER: Skip downgrade implementation
def downgrade():
    pass  # WRONG - implement proper rollback

# NEVER: Modify migration after deployment - create new migration instead

# NEVER: Run migrations automatically in production
# Use: alembic upgrade head --sql > review.sql

# NEVER: Run CONCURRENTLY inside transaction
op.execute("BEGIN; CREATE INDEX CONCURRENTLY ...; COMMIT;")  # FAILS

# NEVER: Delete migration history
command.stamp(alembic_config, "head")  # Loses history

# NEVER: Skip environments (Always: local -> CI -> staging -> production)

Detailed Documentation

ResourceDescription
${CLAUDE_SKILL_DIR}/references/Advanced patterns: Alembic, normalization, migration, audit, environment, versioning
${CLAUDE_SKILL_DIR}/checklists/Migration deployment and schema design checklists
${CLAUDE_SKILL_DIR}/examples/Complete migration examples, schema examples
${CLAUDE_SKILL_DIR}/scripts/Migration templates, model change detector

Zero-Downtime Migration

Safe database schema changes without downtime using expand-contract pattern and online schema changes.

RuleFileKey Pattern
Expand-Contract${CLAUDE_SKILL_DIR}/rules/migration-zero-downtime.mdExpand phase, backfill, contract phase, pgroll automation
Rollback & Monitoring${CLAUDE_SKILL_DIR}/rules/migration-rollback.mdpgroll rollback, lock monitoring, replication lag, backfill progress

Related Skills

  • sqlalchemy-2-async - Async SQLAlchemy session patterns
  • ork:testing-integration - Integration testing patterns including migration testing
  • caching - Cache layer design to complement database performance
  • ork:performance - Performance optimization patterns

Related skills

Databasesdatabases

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.