Skip to content

feat(cli): Add CLI support for connection-targeted migrations #326

@usernane

Description

@usernane

Summary

Add CLI-level support for connection-targeted migrations and seeders, building on DatabaseChange::getTargetConnections() being added in WebFiori/database#149.

Context

The webfiori/database package is adding a getTargetConnections(): array method to DatabaseChange that allows migrations/seeders to declare which named connections they apply to. The filtering logic lives in SchemaRunner. This issue covers the framework-level integration needed to make the feature usable and safe.

Required Work

1. CLI flags

  • Add --connection=<name> flag to migration/seeder commands
  • Pass the connection name to SchemaRunner so filtering works

2. Connection name validation

  • When a migration declares target connections, validate those names against the framework connection registry
  • Warn (or error) if a declared target connection name does not exist in the registry
  • Warn if the SchemaRunner connection has the default name (New_Connection) and target-connection filtering is in use

3. Multi-connection orchestration

  • Consider a --all-connections flag that runs migrations against each registered connection in sequence
  • Each run filters to migrations targeting that connection (or targeting all)

4. CLI output

  • Show skipped migrations with reason: Skipped: Connection mismatch (targets: reporting-db)
  • Consistent with existing environment mismatch output

5. fresh / reset command behavior

  • migrations:fresh should only drop/re-apply migrations that target the current connection
  • Migrations targeting other connections should not be touched
  • Document edge case: if targeting was changed after initial apply

6. Typo detection (nice-to-have)

  • After discovery, compare all declared getTargetConnections() values against registered connection names
  • Emit warnings for unrecognized connection names (likely typos)

Related

Breaking Changes

None — additive CLI flags only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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