database-migration

Implement safe additive SQLite/GRDB database migrations for iOS/macOS apps.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill database-migration-charleswiltgen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migration
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/plugins/axiom/skills/database-migration
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill database-migration-charleswiltgen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents catastrophic data loss and app crashes when evolving database schemas in production iOS/macOS apps. It addresses common pitfalls like NOT NULL column errors, foreign key failures, and the dangers of modifying shipped migrations.

Core Features & Use Cases

  • Safe Migration Patterns: Guides for additive-only, idempotent, and transactional schema changes, ensuring data integrity.
  • Comprehensive Testing Workflow: Mandatory tests for fresh installs, migration paths from previous versions, and idempotency to guarantee robustness.
  • Framework-Specific Guidance: Includes safe patterns and best practices for SQLite, GRDB, and SwiftData migrations.
  • Use Case: When you need to add a new nullable column to a live app's database without losing existing user data, use this skill to follow the safe additive pattern and ensure thorough testing across all scenarios.

Quick Start

To add a new nullable column newColumn to tableName, ensure idempotency by checking for its existence first, then execute ALTER TABLE tableName ADD COLUMN newColumn TEXT.

Frequently Asked Questions about database-migration

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

FAQPage Schema
How do I safely add a column to a live iOS database without losing user data?

Safe database migrations use additive-only, idempotent ALTER TABLE statements. Add nullable columns first, check for column existence to ensure idempotency, wrap changes in transactions, and test both fresh installs and migration paths from previous versions to prevent data loss and app crashes.

What causes 'FOREIGN KEY constraint failed' errors during iOS database migrations?

Foreign key constraint failures occur when migrations create or modify relationships without respecting existing data or transaction boundaries. Use transactional migrations, validate foreign key references exist before constraints are applied, and test migrations against real production data scenarios.

Can I modify a database migration after releasing an iOS app?

No. Once released, migrations must remain immutable. Create new additive migrations instead. Modifying shipped migrations breaks consistency across installed versions and causes unpredictable migration failures. Always add new migration files for subsequent schema changes.

How do I handle 'no such column' and 'cannot add NOT NULL column' errors in SQLite migrations?

These errors indicate unsafe schema changes. Add columns as nullable first, then backfill data in separate migrations if needed. Use idempotent checks (ALTER TABLE IF NOT EXISTS patterns) and test against both fresh databases and upgraded instances to catch these errors early.

What's the difference between schema migrations for SQLite, GRDB, and SwiftData?

SQLite requires raw ALTER TABLE statements; GRDB wraps these in type-safe Swift patterns; SwiftData uses declarative schema versioning. All three require additive, transactional, idempotent changes and comprehensive testing to prevent data loss, but implementation syntax and migration execution differ.

Why do I need to test migrations separately for fresh installs and upgrades?

Fresh installs apply all migrations sequentially, while upgrades apply only new migrations to existing schemas. Testing both paths ensures migrations work idempotently, handle existing data correctly, and don't introduce version-specific state corruption that only appears during real user upgrades.