Skip to content

v1.0.4 - Story 2.3 - Database schema migration setup

Choose a tag to compare

@danielvm-git danielvm-git released this 09 Nov 04:15
· 24 commits to main since this release

🎉 What's New in v1.0.4

This release introduces a comprehensive database migration system for managing schema changes across all environments (dev, staging, production). The custom Node.js CLI provides full control over migrations with robust safety features and detailed documentation.


✨ Features

Database Migration System

  • Custom Migration CLI (scripts/migrate.js): 496-line CLI with four commands
    • migrate:create - Generate timestamped migration files (up/down)
    • migrate:up - Apply pending migrations in order
    • migrate:down - Rollback last migration safely
    • migrate:status - View applied and pending migrations
  • Migration Tracking: Automatic schema_migrations table creation and maintenance
  • Idempotent Design: Uses IF NOT EXISTS patterns for safe re-runs
  • Timestamp-Based Ordering: Ensures consistent migration order across environments
  • Sample Migration: Periodic table example with Neon sample data included

Safety Features

  • ✅ DATABASE_URL validation (required for all operations)
  • ✅ Production environment warnings
  • ✅ Password masking in logs
  • ✅ File format validation
  • ✅ Duplicate migration detection
  • ✅ Fail-fast on errors (stops immediately on failure)
  • ✅ One-at-a-time rollback (prevents cascading failures)

📚 Documentation

Added

  • Database Migrations Guide (docs/guides/database-migrations.md) - 615 lines
    • Complete quick start guide
    • All commands with examples
    • Workflow by environment (dev, staging, production)
    • Best practices and naming conventions
    • Comprehensive troubleshooting section
  • Versioning Guide (docs/guides/versioning.md)
  • Traceability Matrix (docs/traceability-matrix-story-2.3.md)

Updated

  • README.md - Migration setup section and updated examples
  • Neon Auth Setup Guide - Updated query examples

🧪 Testing

  • 28 unit tests added for migration system (100% passing)
  • Test Coverage: All acceptance criteria validated
  • BDD-Style Tests: Clear naming with [2.3-UNIT-XXX] prefixes

Full Changelog: v1.0.3...v1.0.4