Skip to content

feat(cli): Add migrations:skip command for baselining existing databases #320

@usernane

Description

@usernane

Problem Statement

When migrating an existing application to use WebFiori's migration system, developers need a way to mark migrations as "applied" without executing them. The typical scenario:

  • Production has 50+ tables already created manually
  • Migrations are written so staging/testing can be built from scratch
  • Running those migrations on production would fail (tables already exist)
  • There's currently no CLI command to baseline/skip migrations

Proposed Solution

Add a migrations:skip CLI command that marks migrations as applied without executing them:

# Skip a single migration
php webfiori migrations:skip --name=App\\Database\\Migrations\\CreateUsersTable --connection=prod

# Skip ALL discovered migrations (baseline the whole DB)
php webfiori migrations:skip --all --connection=prod

# Skip everything up to a specific migration (inclusive)
php webfiori migrations:skip --up-to=CreateProductsTable --connection=prod

Command Arguments:

  • --name — Fully qualified class name (or short name) of a single migration to skip
  • --all — Skip all discovered migrations and seeders
  • --up-to — Skip all migrations up to and including the named one
  • --connection — Database connection name
  • --env — Environment (dev, staging, production)

Expected Output:

Skipped: App\Database\Migrations\CreateUsersTable
Skipped: App\Database\Migrations\CreateOrdersTable
Info: Total skipped: 2

Alternatives Considered

  1. Writing idempotent migrations — tedious for 50+ tables, doesn't cover all cases
  2. --skip-failed flag on migrations:run — masks real errors alongside expected failures
  3. Interactive prompts on failure — breaks CI/CD pipelines

Breaking Change

No

Additional Context

Depends on: WebFiori/database#136 (adds skip()/skipAll()/skipUpTo() to SchemaRunner)

This follows the standard pattern from other frameworks:

  • Flyway: flyway baseline
  • Django: manage.py migrate --fake
  • Liquibase: changelogSync

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIRelated to command line interface functionality.databaseRelated to database.enhancementImprove performace or existing feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions