Match gitlab:db:sos schema dump file extension to its content

What does this MR do and why?

gitlab:db:sos writes a schema dump named <db>_schema_dump.sql, but the content is Rails' Ruby schema dump (ActiveRecord::Schema[...].define) from connection.create_schema_dumper, not SQL. This renames the emitted file to <db>_schema_dump.rb so the extension matches the content.

Resolves #595282 (closed).

How to set up and validate locally

  1. bin/rake gitlab:db:sos
  2. Each database directory in the resulting zip contains <db>_schema_dump.rb with the Ruby schema dump instead of the misnamed .sql file.
Supporting evidence
  • The old filename appeared in exactly two places: the class and its spec. The admin docs for the rake task don't list bundle filenames, so nothing else needed updating.
  • Note for Support: this renames an entry inside the sos zip. Anything externally parsing the old name should update — though anything parsing that file as SQL was already broken, since the content was never SQL.
  • Considered writing real SQL instead, but that would mean shelling out to pg_dump on customer instances, a disproportionate behavior change for a naming papercut.
  • bin/rspec spec/lib/gitlab/database/sos/ar_schema_dump_spec.rb spec/lib/gitlab/database/sos_spec.rb spec/lib/gitlab/database/sos/output_spec.rb → 9 examples, 0 failures, including a new example that writes a real dump and asserts the .rb file contains ActiveRecord::Schema.
  • End-to-end check on a local GDK (real Output in zip mode, driven exactly as the rake task does, across main/ci/sec databases): the zip contains main/main_schema_dump.rb, ci/ci_schema_dump.rb, sec/sec_schema_dump.rb, each starting with the auto-generated ActiveRecord schema header.
  • RuboCop clean on both changed files.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Merge request reports

Loading
Loading