Skip to main content

Overview

Zeus uses SQLx CLI for database migrations. Migrations are version-controlled and applied in order.

Creating Migrations

This creates:

Migration File Format

Running Migrations

Apply All

Check Status

Output:

Revert Last

Migration Best Practices

  1. Never modify existing migrations - Create new ones instead
  2. Make migrations reversible - Always provide down.sql
  3. Test migrations - Run on a copy of production data
  4. Keep migrations small - One logical change per file
  5. Use transactions - Wrap in BEGIN/COMMIT for safety

Example Migration

Adding a new column:

Migration Checklist

  • Test on development database
  • Ensure down migration works
  • Check for data loss
  • Update application code
  • Document changes
  • Backup production database