database-operations

Design PostgreSQL schemas and manage Alembic migrations with SQLAlchemy.

Updated Nov 22, 2025
One-click install
npx skills add https://github.com/usermaum/Themoon --skill database-operations-usermaum
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-operations
Source: https://github.com/usermaum/Themoon/tree/main/.claude/plugins/mas-agents/skills/database-operations
Command: npx skills add https://github.com/usermaum/Themoon --skill database-operations-usermaum

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and scripts (resource) components.

What problem does it solve?

This Skill streamlines the complex and error-prone tasks of designing database schemas, managing migrations, and optimizing query performance for the TheMoon project.

Core Features & Use Cases

  • Schema Design: Provides best practices and templates for creating robust and scalable PostgreSQL schemas using SQLAlchemy.
  • Migration Management: Guides users through Alembic workflows for creating, applying, and rolling back database schema changes.
  • Query Optimization: Offers strategies and examples for improving database performance through indexing, query tuning, and avoiding common pitfalls like the N+1 problem.
  • Use Case: A developer needs to add a new roast_level column to the beans table. This Skill can guide them through creating the SQLAlchemy model, generating the Alembic migration, and applying it to the database.

Quick Start

Use the database-operations skill to create a new Alembic migration for adding a 'roast_level' column to the 'beans' table.

Frequently Asked Questions about database-operations

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

FAQPage Schema
How do I create an Alembic migration to add a new column to a PostgreSQL table?

To create an Alembic migration for adding a column, you define the SQLAlchemy model changes and generate the migration script to apply the schema update to the PostgreSQL database. This ensures version-controlled schema changes.

What is the best way to avoid the N+1 query problem in SQLAlchemy?

Avoiding the N+1 query problem in SQLAlchemy involves using eager loading strategies and batch operations to optimize query performance. This reduces redundant database calls and improves application speed.

How do I design a scalable PostgreSQL schema using SQLAlchemy?

Designing a scalable PostgreSQL schema using SQLAlchemy requires following schema design principles, standard naming conventions, and adding standard columns. This provides a robust foundation for database operations.

Can I use this to generate and roll back database migrations with Alembic?

Yes, you can use Alembic workflows to create, apply, and roll back database schema changes. This manages the migration lifecycle effectively within the PostgreSQL database environment.

What index strategies should I use for PostgreSQL query optimization?

PostgreSQL query optimization uses targeted index strategies and query tuning to improve database performance. Proper indexing reduces query execution time and prevents common performance bottlenecks.