database-engineering

Guides relational modeling, query optimization, transactions, and safe database migrations.

1|Updated Sep 10, 2026
One-click install
npx skills add https://github.com/thienty1207/Hotel_Staff --skill database-engineering-thienty1207
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-engineering
Source: https://github.com/thienty1207/Hotel_Staff/tree/main/.baron/core/skills/database-engineering
Command: npx skills add https://github.com/thienty1207/Hotel_Staff --skill database-engineering-thienty1207

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database changes often introduce broken constraints, slow queries, race conditions, or irreversible migrations. This Skill provides structured engineering guidance for schema design, query planning, transaction boundaries, and rollback-safe migrations so persistence changes stay correct and recoverable. ## Core Features & Use Cases - Relational Modeling: Defines entities, keys, foreign keys, nullability, and uniqueness constraints so invariants are enforced by the database rather than application code. - Query and Transaction Design: Selects indexes from real predicates, inspects query plans, prevents N+1 patterns, and sets isolation levels and lock ordering to avoid deadlocks and lost updates. - Migration and Backfill Safety: Plans expand/contract migrations, bounded resumable backfills, rollback paths, and validation queries before destructive changes. - Use Case: When adding a new table with foreign keys to a PostgreSQL schema, use this Skill to design the constraints, choose indexes, and write a reversible migration with a validation query. ## Quick Start Ask the AI to review your schema change or migration plan using the database-engineering skill, including constraints, indexes, transaction behavior, and rollback steps.

Frequently Asked Questions about database-engineering

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

FAQPage Schema
How do I design a safe database migration with rollback?

Prefer additive, compatible changes first and use an expand/contract window when old and new application versions overlap. Separate schema migration from data backfill, define the rollback or forward-fix behavior, and write a validation query before execution.

How do I choose the right database indexes for a query?

Choose indexes from selectivity, ordering, filter combinations, and write cost, and validate composite-index column order against real predicates. Inspect the execution plan for slow paths and record the evidence rather than guessing.

How do I prevent deadlocks and race conditions in transactions?

Keep lock ordering consistent, select isolation levels for the specific anomaly being prevented, and define bounded idempotent retries for transient conflicts. Test concurrent behavior directly, since unit tests alone cannot prove concurrency safety.

When should I use raw SQL instead of an ORM?

Use raw SQL when it makes a critical query or lock behavior explicit, and cover it with contract or integration tests. Keep ORM models, repositories, and transaction ownership aligned with the declared domain boundary.

What precautions are needed before destructive schema changes?

Treat destructive changes as high-risk: require confirmation, a recovery path, and proof that protected data is not silently lost. Use dry-runs or bounded previews where supported and record backup expectations without inventing backup success.