Migrations / Storage
Ecotone provides comprehensive migration commands to manage your storage infrastructure, giving you full control over when and how storage resources are created or removed.
Automatic Initialization (Default)
By default, Ecotone automatically creates required database tables and message channels on demand (first use). This means you can start using Ecotone right away without needing to set up any infrastructure yourself - tables are created when you first store a document, queues are declared when you first send a message, and so on.
This approach works great in most scenarios, especially during development and in applications where initialization state can be cached between requests.
When to Use Migration Commands
In some scenarios, you may want to take over the initialization process however:
Performance-sensitive HTTP applications - If we send messages to a broker with each HTTP request, then as each request is clear state, automatic initialization will continuesly re-try to create the resource
Strict deployment processes - Some applications follow a process where all migrations must be completed before starting the application
Visibility and control - You want to see what storage resources exist and their initialization state
Resource cleanup - You need to delete storage resources when features are no longer needed
Integration with existing tools - You want to generate SQL statements for use with Doctrine Migrations, Laravel Migrations, or similar tools
For these cases, Ecotone provides migration commands to take over the process.
Overview
Ecotone offers two types of migration commands:
Database Migrations - Manage database tables for features like deduplication, dead letter, document store, database message queues, event sourcing, and projections
Channel Migrations - Manage message channel infrastructure (queues, exchanges, topics) for brokers like RabbitMQ, SQS
Disabling Automatic Initialization
Before using migration commands, disable automatic initialization. This way we disable automatic creation of tables and channels.
Database Tables
Message Channels
Database Migration Commands
Viewing Status
Output displays three columns: Feature name, whether it's used, and whether it's initialized:
Initializing Tables
Getting SQL Statements
If you want to integrate with existing database migration tools (like Doctrine Migrations or Laravel Migrations), you can get the raw SQL statements:
Deleting Tables
The --force flag is required to actually delete tables. Without it, the command only shows what would be deleted.
Available Database Features
dead_letter
Failed message storage for error recovery
deduplication
Message deduplication tracking
document_store
Document store persistence
message_queue
DBAL-backed message queue
event_streams
Event sourcing stream storage
projection_state
Projection state tracking
projections_v1
Legacy projection tables
Channel Migration Commands
Message channels for brokers like RabbitMQ, SQS, and Kafka can be managed via migration commands.
Viewing Status
Output displays two columns: Channel name and whether it's initialized:
Initializing Channels
Deleting Channels
Command Reference
Database Commands
ecotone:migration:database:setup
--features, --initialize, --sql, --onlyUsed
View status, initialize tables, or get SQL
ecotone:migration:database:delete
--features, --force, --onlyUsed
Delete database tables
Channel Commands
ecotone:migration:channel:setup
--channel, --initialize
View status or initialize channels
ecotone:migration:channel:delete
--channel, --force
Delete message channels
Testing
For testing purposes, you can use the same migration commands with Ecotone Lite:
Last updated
Was this helpful?