db-apply-migration

Apply SQL database migrations with advisory locks and schema snapshots.

3|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/GDSDN/kord-aios --skill db-apply-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: db-apply-migration
Source: https://github.com/GDSDN/kord-aios/tree/main/src/features/builtin-skills/kord-aios/database/db-apply-migration
Command: npx skills add https://github.com/GDSDN/kord-aios --skill db-apply-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill automates the process of applying database migrations, ensuring data integrity and preventing concurrent modifications through advisory locks and pre/post snapshots.

Core Features & Use Cases

  • Safe Migration Application: Applies SQL migrations with pre- and post-migration snapshots for rollback and auditing.
  • Concurrency Control: Uses PostgreSQL advisory locks to prevent multiple migrations from running simultaneously.
  • Error Handling & Rollback: Provides robust error handling, automatic transaction rollback, and clear rollback instructions.
  • Use Case: Apply a schema change to a production database with confidence, knowing that you can easily revert if issues arise and that no other migration is running at the same time.

Quick Start

Use the db-apply-migration skill to apply the migration file located at migrations/001_create_users_table.sql.

Frequently Asked Questions about db-apply-migration

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

FAQPage Schema
How do I safely apply a database migration to a production PostgreSQL database?

To safely apply a database migration, this process acquires a PostgreSQL advisory lock, creates pre- and post-migration schema snapshots, and executes the SQL script within a transaction to ensure data integrity and prevent concurrent modifications.

How does an advisory lock prevent concurrent database migrations?

An advisory lock prevents concurrent database migrations by blocking other migration processes from executing simultaneously. This ensures only one migration script runs at a time, protecting the PostgreSQL schema from race conditions and conflicting modifications.

Can I automatically rollback a failed SQL migration script?

Yes, you can automatically rollback a failed SQL migration script. The process executes the migration within a transaction, automatically rolling back changes if query syntax errors or connection failures occur, while providing clear manual rollback instructions.

What happens if my database migration encounters a connection failure or syntax error?

If a database migration encounters a connection failure or query syntax error, the transaction is automatically rolled back. The process then utilizes a retry strategy to attempt the migration again, ensuring transient issues do not corrupt your PostgreSQL schema.

Do I need pre- and post-migration schema snapshots for database rollback?

Yes, pre- and post-migration schema snapshots are created to facilitate safe database rollback. These snapshots generate a diff of the schema changes, allowing you to audit what was modified and easily revert the database if issues arise.