sql-database-migration

Write and review forward-only relational schema migrations for Spring Boot with Flyway or Liquibase.

39|3|Updated Jul 28, 2025
One-click install
npx skills add https://github.com/mzivkovicdev/spring-crud-generator --skill sql-database-migration-mzivkovicdev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sql-database-migration
Source: https://github.com/mzivkovicdev/spring-crud-generator/tree/main/.agents/skills/sql-database-migration
Command: npx skills add https://github.com/mzivkovicdev/spring-crud-generator --skill sql-database-migration-mzivkovicdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Schema changes in Spring Boot projects often drift from the migration history, break on deployment, or fail silently when wiring is wrong. This Skill enforces a disciplined, forward-only migration workflow so every relational schema change is versioned, reviewed, and reproducible in every environment. ## Core Features & Use Cases - Tool decision and wiring: Reads the recorded Flyway or Liquibase choice from the project profile, asks the user when nothing is recorded, and enforces the Spring Boot 4 starter requirement that prevents migrations from silently never running. - Immutable, ordered history: Enforces never editing applied migrations, resolving branch version conflicts by renumbering the later branch, and one migration per logical change. - Expand-and-contract for breaking changes: Splits renames, type narrowing, NOT NULL additions, and drops into expand, migrate, and contract phases, with separate batched, resumable backfills and business-keyed seed data. - Use Case: A developer adds a status column to a populated users table. The Skill guides them to add it nullable (expand), backfill in a separate batched migration (migrate), and add the NOT NULL constraint in a later release (contract), then verify with a clean install from an empty database. ## Quick Start Ask the assistant to write a Flyway migration that adds a new table with named constraints and indexes, then verify it with a clean run from an empty database.

Frequently Asked Questions about sql-database-migration

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

FAQPage Schema
How do I write a database migration in Spring Boot with Flyway?▼

Write explicit SQL in a versioned file under src/main/resources/db/migration, naming every constraint and index and stating nullability, defaults, and precision explicitly. Commit the migration together with the entity mapping change, and verify it with a clean run from an empty database.

Flyway vs Liquibase for Spring Boot migrations?▼

Both are correct choices and the project profile records which one the project uses. Flyway favors versioned SQL files with checksums; Liquibase uses ordered change sets in a master changelog. Never run both tools against one schema, since each keeps its own history table.

Why do Flyway migrations not run on Spring Boot 4?▼

On Spring Boot 4, auto-configuration was split into per-technology modules, so the raw flyway-core library leaves nothing wiring it. The spring-boot-starter-flyway dependency is mandatory; without it the application starts and tests pass but no migration ever runs.

Can I edit a migration that was already applied?▼

No. An applied migration is frozen because the tool stores a checksum, and editing it fails startup in every environment that already ran it. Correct mistakes with a new forward migration; editing is only allowed on an unmerged feature branch.

How do I rename a column without downtime?▼

A rename is a drop plus an add, so split it into expand, migrate, and contract phases across releases: add the new column, write to both and backfill, then stop reading the old column and drop it in a later release. Never rename in one step on a live system.

Does this approach work for MongoDB or other NoSQL stores?▼

No. These rules cover relational databases only, because NoSQL stores have no linear version history, no checksum over applied scripts, and a different expand-and-contract shape. Do not apply Flyway or Liquibase migration discipline to NoSQL data stores.