braintree / pg_ha_migrations

Enforces DDL/migration safety in Ruby on Rails project with an emphasis on explicitly choosing trade-offs and avoiding unnecessary magic.
MIT License
220 stars 23 forks source link

Support to recursively create partitioned index #86

Closed rkrage closed 9 months ago

rkrage commented 1 year ago

Recurse through sub-partitions when creating a partitioned index

Relies on https://github.com/braintree/pg_ha_migrations/pull/94

rkrage commented 1 year ago

I rewrote this to just always recurse because it makes the code infinitely cleaner. I still think there are some edge cases to consider, though. Like currently, we CREATE INDEX ... ON ONLY upfront before recursing through sub-partitions, which I think is safer because it accounts for a situation where child partitions are added while the operation is running, but it also opens us up to a situation where the parent index gets created, the index name on a sub-partition is invalid due to exceeding the 63 byte limit, an error is raised and we're left with an invalid parent index.

I'm still working through these edge cases and writing tests, so this PR can be considered a draft for now.

Update: I think these concerns are resolved by https://github.com/braintree/pg_ha_migrations/pull/94