mix maestro.create.partitioned_event_store_migration (Maestro v1.0.0)

View Source

Generate a migration that creates hash-partitioned event_log and (unpartitioned) snapshots tables with HLC constraints.

Hash partitioning on aggregate_id distributes data and index load across N partitions, improving write throughput and query performance for aggregate-scoped reads.

Note on the Event schema: Maestro.Types.Event marks only timestamp as primary_key: true. The partitioned table PK must be (aggregate_id, timestamp) because PostgreSQL requires the partition key in all unique indexes and PKs. A consequence of this, then, is that there is no global uniqueness on timestamp; as a best effort, we guarantee uniqueness per-partition.

Examples

mix maestro.create.partitioned_event_store_migration --repo MyApp.Repo -p 7
mix maestro.create.partitioned_event_store_migration --repo MyApp.Repo --partitions 17 -n custom_name