Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eventsauce Migration Generator Laravel Package

andreo/eventsauce-migration-generator

Symfony Console command that generates Doctrine Migrations for EventSauce message storage per aggregate. Configure Doctrine Migrations, then run a single command with a table prefix, selectable schemas (event/outbox/snapshot), UUID type, and optional table-name suffixes.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event Sourcing Alignment: The package is tightly coupled with EventSauce, making it ideal for Laravel projects adopting event-driven persistence (e.g., CQRS/ES). It automates schema generation for event store, snapshots, and outbox tables, reducing manual SQL/Doctrine migration work by 70%+ for teams transitioning from traditional ORM patterns.
  • Aggregate-Centric Workflow: Generates one migration per aggregate, aligning with Domain-Driven Design (DDD) principles. This is particularly valuable for large-scale Laravel monoliths or microservices where aggregates are the primary modeling unit.
  • Doctrine Integration: Leverages Doctrine Migrations, which Laravel already supports via doctrine/dbal and doctrine/migrations bundles. This ensures seamless compatibility with Laravel’s existing database abstraction layer.

Integration Feasibility

  • Symfony Console Dependency: The package requires Symfony’s Console component, which is not native to Laravel. However, this can be mitigated via:
    • Laravel’s Symfony Bridge (symfony/console + symfony/finder).
    • Custom Artisan Wrapper (recommended for minimalism).
  • EventSauce Compatibility: If the project already uses EventSauce, this package eliminates boilerplate for schema setup. For new adoptions, it lowers the barrier to entry by providing a standardized migration workflow.
  • Laravel-Specific Considerations:
    • UUID Handling: Defaults to binary UUIDs, which may conflict with Laravel’s default ramsey/uuid (string-based). Requires explicit configuration via --uuid-type.
    • Migration Naming: Laravel’s migration naming conventions (e.g., YYYY_MM_DD_HHMMSS_) may need alignment with the package’s output.

Technical Risk

  • Symfony Overhead: Introduces ~10MB of dependencies (Symfony Console, Finder). For lightweight projects, this may be justified by the time saved, but greenfield projects should weigh the trade-off.
  • Schema Lock-In: Relies on EventSauce’s default table schema. Custom schemas (e.g., partitioned tables, soft deletes) may require manual overrides post-generation.
  • Migration Scope: Generates migrations for all aggregates by default, risking:
    • Unintended schema changes in CI/CD pipelines.
    • Migration history bloat in large systems (e.g., 50+ aggregates).
  • Rollback Limitations: Generates forward migrations only; rollbacks rely on Doctrine’s default behavior, which may not account for EventSauce-specific constraints.

Key Questions for TPM

  1. EventSauce Adoption Stage:
    • Is this for new projects (low risk) or legacy modernization (higher risk due to schema changes)?
  2. UUID Strategy:
    • Does the Laravel stack use binary or string UUIDs? If ramsey/uuid, how will conflicts be resolved?
  3. Aggregate Scale:
    • How many aggregates exist? Will one migration per aggregate lead to maintenance overhead?
  4. CI/CD Integration:
    • Should migrations be auto-generated on PR merges (risk of broken builds) or manually triggered?
  5. Schema Customization Needs:
    • Are there non-standard EventSauce configurations (e.g., custom columns, indexes) that require manual tweaks?
  6. Symfony Dependency Tolerance:
    • Is the team open to Symfony Console dependencies, or should a custom Artisan wrapper be prioritized?
  7. Rollback Strategy:
    • Are there EventSauce-specific rollback requirements (e.g., event replay logic) beyond Doctrine’s defaults?

Integration Approach

Stack Fit

  • Core Compatibility:
    • Doctrine Migrations: Native Laravel support via doctrine/dbal and doctrine/migrations.
    • EventSauce: Required for event storage; package is EventSauce-specific.
    • ⚠️ Symfony Console: Not native to Laravel. Mitigation options:
      • Option A (Symfony Bridge): Use laravel/symfony-cli-bridge to expose Symfony commands as Artisan commands.
      • Option B (Custom Artisan Wrapper): Preferred for minimalism; encapsulates Symfony logic within a Laravel command.
    • PHP 8.2+: Aligns with Laravel’s LTS support (v10+).
  • Alternatives:
    • Laravel Schema Builder: Could manually replicate functionality but loses automation and aggregate-centric organization.
    • Custom Migration Generator: Higher upfront cost but avoids Symfony dependencies.

Migration Path

  1. Phase 1: Dependency Setup

    • Install core packages:
      composer require andreo/eventsauce-migration-generator doctrine/migrations
      
    • Optional: Install Symfony Console only if using the bridge approach:
      composer require symfony/console symfony/finder
      
    • Configure Doctrine Migrations in config/packages/doctrine_migrations.yaml (Laravel-compatible).
  2. Phase 2: CLI Integration

    • Option A: Symfony Bridge (Recommended for Existing Symfony Users)
      • Publish the bridge configuration:
        php artisan vendor:publish --provider="Laravel\SymfonyCliBridge\SymfonyCliBridgeServiceProvider"
        
      • Register the EventSauce command in config/console.php:
        'commands' => [
            Andreo\EventSauce\Doctrine\Migration\Command\GenerateDoctrineMigrationForEventSauceCommand::class,
        ],
        
      • Run via Artisan:
        php artisan andreo:eventsauce:doctrine-migrations:generate my_prefix --schema=event,snapshot
        
    • Option B: Custom Artisan Wrapper (Recommended for Minimalism)
      • Create a Laravel command:
        php artisan make:command GenerateEventSauceMigrations
        
      • Implement the wrapper logic:
        // app/Console/Commands/GenerateEventSauceMigrations.php
        use Andreo\EventSauce\Doctrine\Migration\Command\GenerateDoctrineMigrationForEventSauceCommand;
        use Doctrine\Migrations\DependencyFactory;
        use Symfony\Component\Console\Input\ArrayInput;
        use Symfony\Component\Console\Output\BufferedOutput;
        
        class GenerateEventSauceMigrations extends Command {
            protected $signature = 'eventsauce:migrate {prefix?} {--schema= : event|outbox|snapshot|all} {--uuid-type= : binary|string}';
            public function handle() {
                $dependencyFactory = new DependencyFactory(
                    new \Doctrine\DBAL\Connection($this->app['db']->connection()),
                    new \Doctrine\DBAL\Schema\AbstractSchemaManager($this->app['db']->connection()->getWrappedConnection())
                );
        
                $command = new GenerateDoctrineMigrationForEventSauceCommand(
                    $dependencyFactory,
                    new \Andreo\EventSauce\Doctrine\Migration\Schema\TableNameSuffix('message_store')
                );
        
                $input = new ArrayInput([
                    'command' => 'andreo:eventsauce:doctrine-migrations:generate',
                    'prefix' => $this->argument('prefix'),
                    '--schema' => $this->option('schema'),
                    '--uuid-type' => $this->option('uuid-type'),
                ]);
        
                $output = new BufferedOutput();
                $command->run($input, $output);
                $this->info($output->fetch());
            }
        }
        
      • Run via Artisan:
        php artisan eventsauce:migrate user_aggregate --schema=event --uuid-type=string
        
  3. Phase 3: Configuration

    • Set table name suffixes (e.g., message_store) in the command constructor or via environment variables.
    • Configure UUID type (binary or string) to match Laravel’s stack (default: binary).
    • Optional: Extend the command to support Laravel’s migration batching (e.g., group aggregates by domain).

Compatibility

  • Doctrine Migrations: Works out-of-the-box with Laravel’s doctrine/dbal.
  • EventSauce: Assumes standard repository tables. Custom schemas (e.g., added columns) may require post-generation edits.
  • Laravel-Specific Adjustments:
    • UUID Handling: If using ramsey/uuid, set --uuid-type=string to avoid conflicts.
    • Migration Naming: Align generated migration filenames with Laravel’s YYYY_MM_DD_HHMMSS_ convention via custom naming logic in the wrapper.
    • Testing: Integrate with Laravel’s migration testing tools (e.g., phpunit-dbunit) to validate schema changes.

Sequencing

  1. Assess EventSauce Adoption:
    • If new, **pilot with 1-2
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky