Auto migrate clickhouse migrations when running db:migrate
Issue Description
Summary
Automatically run ClickHouse migrations when db:migrate is executed.
Background
ClickHouse migrations are now available, but they are not being run automatically as part of the standard database migration process. This creates a gap in our deployment workflow where ClickHouse schema changes must be applied manually.
Previous Attempts
- Initial Implementation: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/13923
- Reverted: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/14004
- Reason for Revert: Pipeline failure in Ansible deployment
Trace
TASK [ansistrano.deploy : Running pending migrations] **************************
fatal: [instance]: FAILED! => {"changed": true, "cmd": "/home/gitlab-customers/.rbenv/shims/bundle exec rake db:migrate", "delta": "0:00:04.058894", "end": "2025-11-07 05:45:33.748593", "msg": "non-zero return code", "rc": 1, "start": "2025-11-07 05:45:29.689699", "stderr": "rake aborted!\nNoMethodError: undefined method `query_values=' for nil (NoMethodError)\n\n parsed.query_values = @variables.merge(extra_variables)\n ^^^^^^^^^^^^^^^\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/click_house-client-0.3.5/lib/click_house/client/database.rb:25:in `build_custom_uri'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/click_house-client-0.3.5/lib/click_house/client/database.rb:20:in `uri'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/click_house-client-0.3.5/lib/click_house/client.rb:126:in `block in instrumented_execute'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/activesupport-7.1.5.2/lib/active_support/notifications.rb:206:in `block in instrument'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/activesupport-7.1.5.2/lib/active_support/notifications/instrumenter.rb:58:in `instrument'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/sentry-rails-5.19.0/lib/sentry/rails/tracing.rb:54:in `instrument'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/activesupport-7.1.5.2/lib/active_support/notifications.rb:206:in `instrument'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/click_house-client-0.3.5/lib/click_house/client.rb:119:in `instrumented_execute'\n/home/gitlab-customers/CustomersDot/shared/vendor/bundle/ruby/3.3.0/gems/click_house-client-0.3.5/lib/click_house/client.rb:47:in `select'\n/home/gitlab-customers/CustomersDot/releases/20251107054156Z/lib/click_house/server.rb:11:in `block in alive?'
Expected Behavior
When db:migrate is run, both PostgreSQL and ClickHouse migrations should be executed automatically.
Description was generated using AI
Edited by Tarun Vellishetty