Migration Execution Guide

Learn how to apply migrations directly from the DevSync.AI dashboard with safety checks and validation.

Quick Start

Step 1: Generate a Migration

  1. Go to your project in the dashboard
  2. Navigate to a scan report with mismatches
  3. Click "Generate Migration"
  4. Review the generated SQL migration

Step 2: Validate the Migration (Dry Run)

  1. In the migration preview, click "Validate (Dry Run)"
  2. The system will validate the SQL syntax without executing
  3. Check the validation result for any errors or warnings

Important: Always validate migrations before applying them to production databases.

Step 3: Apply the Migration

  1. Click "Apply Migration"
  2. Confirm the action in the dialog
  3. Wait for execution to complete
  4. View the execution result and history

Features

Dry Run Validation

Validate migrations without executing. Catches syntax errors and connection issues before changes are made.

One-Click Execution

Apply migrations with a single click after validation. All migrations run in transactions for safety.

Execution History

Track all migration executions with detailed logs, timestamps, and error messages.

Safety Checks

Prevents duplicate execution, validates permissions, and checks database connections before execution.

Validation (Dry Run)

Dry run validation allows you to check migration SQL syntax and verify database connectivity without making any changes to your database.

What Dry Run Does

  • Validates SQL syntax using PostgreSQL's EXPLAIN
  • Checks for syntax errors and invalid SQL statements
  • Verifies database connection is available
  • Does NOT modify the database in any way

When to Use Dry Run

  • Before applying any migration to production
  • After generating a new migration
  • When testing migrations in development
  • After modifying migration SQL manually

Applying Migrations

Applying a migration executes the SQL on your database. All migrations run in transactions to ensure atomicity—either all changes succeed or none are applied.

Safety Checks

  • Requires explicit confirmation before execution
  • Prevents duplicate execution of the same migration
  • Validates user permissions and database access
  • Checks database connection before attempting execution

Execution Process

  1. Migration status is set to "running"
  2. Database connection is established
  3. SQL is executed in a transaction
  4. Results are recorded in migration history
  5. Status is updated to "success" or "failed"

Warning: Always backup your database before applying migrations in production. While migrations run in transactions, some operations may require manual intervention if they fail.

Best Practices

  • Always validate first - Run dry-run validation before applying any migration
  • Review SQL carefully - Understand what the migration will do before executing
  • Test in development first - Apply migrations to dev/staging environments before production
  • Keep database backups - Always backup before applying migrations to production
  • Monitor execution - Watch migration execution and check results in the history
  • Don't close the page - Keep the dashboard open while migrations are running