Skip to content

Add gitlab:db:dictionary:write_missing rake task

Matt Kasa requested to merge mattkasa-data-dictionary-rake-only-new into master

What does this MR do and why?

Adds the gitlab:db:dictionary:write_missing rake task and enhancement of db:migrate, that used to be gitlab:db:dictionary:generate (!85760 (merged)) that was temporarily removed (!90658 (merged)) due to generating unwanted updates to db docs YAML files.

The task has been modified in this MR to only write db docs YAML files for new tables, and not to update existing files, which should resolve the issues that we were seeing in the original version.

How to set up and validate locally

  1. Run the rake task with no new table
    $ bin/rake db:migrate
    $ git status
    nothing to commit, working tree clean
  2. Run the rake task with a new table
    $ bin/rails g active_record:model dictionary_test_model
    $ git status
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
        app/models/dictionary_test_model.rb
        db/migrate/20220622010051_create_dictionary_test_models.rb
        spec/models/dictionary_test_model_spec.rb
    $ bin/rake db:migrate
    $ git status
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
        app/models/dictionary_test_model.rb
        db/docs/dictionary_test_models.yml
        db/migrate/20220622010051_create_dictionary_test_models.rb
        db/schema_migrations/20220622010051
        spec/models/dictionary_test_model_spec.rb

Related to: #322122 (closed)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Matt Kasa

Merge request reports