`lib/gitlab/database/partitioning/` should work with many databases
Currently our partitioning is a hand written generation of different SQL queries executed on top of ActiveRecord::Base.connection
. We should adapt that to properly support many databases,
and make it to use a connection of an associated model for which partitions are to be created.
Ref.:
- https://gitlab.com/gitlab-org/gitlab/-/blob/a9c318847faad3b6db4e5d51440c009cff578dff/lib/gitlab/database/partitioning/monthly_strategy.rb
- https://gitlab.com/gitlab-org/gitlab/-/blob/a9c318847faad3b6db4e5d51440c009cff578dff/lib/gitlab/database/partitioning/partition_manager.rb
- https://gitlab.com/gitlab-org/gitlab/-/blob/a9c318847faad3b6db4e5d51440c009cff578dff/lib/gitlab/database/partitioning/replace_table.rb
- https://gitlab.com/gitlab-org/gitlab/-/blob/a9c318847faad3b6db4e5d51440c009cff578dff/lib/gitlab/database/partitioning/time_partition.rb
- The first issue is that partitioned tables fail to create on the
ci:
database (config/initializers/postgres_partitioning.rb). This is tricky because only theaudit_event
structure exists on theci:
database but the AuditEvent model don't ever have a connection to thatci:
database.- Note: Partitioning creation/sync seems to work locally for some reason. We should investigate why
Edited by Thong Kuah