You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for partitionBy() + update() on existing tables (#989)
* Fix multiple partition SQL syntax for MySQL
When adding multiple partitions to an existing table, MySQL requires:
ALTER TABLE foo ADD PARTITION (PARTITION p1 ..., PARTITION p2 ...)
Previously, each AddPartition action generated its own ADD PARTITION clause,
which when joined with commas resulted in invalid SQL:
ALTER TABLE foo ADD PARTITION (...), ADD PARTITION (...)
This fix:
- Batches AddPartition actions together in executeActions()
- Adds new getAddPartitionsInstructions() method to AbstractAdapter with
a default implementation that calls the single partition method
- Overrides getAddPartitionsInstructions() in MysqlAdapter to generate
correct batched SQL: ADD PARTITION (PARTITION p1, PARTITION p2)
- Similarly batches DropPartition actions for efficiency
- Adds gatherPartitions() to Plan.php to properly gather partition actions
- Includes extensive tests for single/multiple partition add/drop scenarios
Refs #986
* Fix coding standard - use single quotes
* Trigger CI re-run
* Add test for combined partition and column operations
* Add SetPartitioning action for partitionBy() + update()
Enables adding partitioning to existing non-partitioned tables using:
$table->partitionBy(Partition::TYPE_RANGE_COLUMNS, 'created')
->addPartition('p2023', '2024-01-01')
->update();
Previously this generated no SQL. Now it properly generates:
ALTER TABLE `table` PARTITION BY RANGE COLUMNS (created) (...)
Changes:
- Add SetPartitioning action class
- Update Plan to handle SetPartitioning in gatherPartitions()
- Add getSetPartitioningInstructions() to AbstractAdapter/MysqlAdapter
- Create SetPartitioning action in Table::executeActions() when updating
* Add test for composite partition keys
* Each adapter now only needs to implement the collection methods
* Remove unused import
---------
Co-authored-by: mscherer <dereuromark@web.de>
Co-authored-by: Jamison Bryant <jbryant@ticketsauce.com>
0 commit comments