Skip to content

Add `scripts/decomposition/generate-loose-foreign-key` script

What does this MR do and why?

This is internal tooling as referenced in &7249 (comment 816243722).

This adds a helper script to automate loose foreign key swap. Script does:

  • create branch
  • creates templated migration
  • runs migrations to commit db/structure.sql
  • updates YMLs for LFK
  • updates specs for LFK
  • generates LFK spec in a model
  • commits
  • pushes
  • provides MR template
Usage: ./generate-loose-foreign-key.rb [options] <filters...>

    -c, --cross-schema               Show only cross-schema foreign keys
    -n, --dry-run                    Do not execute any commands (dry run)
    -b, --[no-]branch                Create or not a new branch
    -r, --[no-]rspec                 Create or not a rspecs automatically
    -m, --milestone                  Specify custom milestone (current: 14.7)
    -h, --help                       Prints this help

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

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 Kamil Trzciński

Merge request reports