# rubocop:disable Style/SignalException ANY_MIGRATIONS_REGEX = %r{\A(ee/)?(db/(geo/)?(post_)?migrate)/} SCHEMA_NOT_UPDATED_MESSAGE = <<~MSG **New %s added but %s wasn't updated.** Usually, when adding new %s, %s should be updated too (unless the migration isn't changing the DB schema and isn't the most recent one). MSG non_geo_db_schema_updated = !git.modified_files.grep(%r{\Adb/schema\.rb/}).empty? geo_db_schema_updated = !git.modified_files.grep(%r{\Aee/db/geo/schema\.rb/}).empty? any_migration_created = !git.added_files.grep(ANY_MIGRATIONS_REGEX).empty? any_migration_updated = !git.modified_files.grep(ANY_MIGRATIONS_REGEX).empty? non_geo_migration_created = !git.added_files.grep(%r{\A(db/(post_)?migrate)/}).empty? geo_migration_created = !git.added_files.grep(%r{\Aee/db/geo/(post_)?migrate/}).empty? if any_migration_created || any_migration_updated || non_geo_db_schema_updated || geo_db_schema_updated message "Please make sure to ask a Database engineer for a review." end if non_geo_migration_created && !non_geo_db_schema_updated warn format(SCHEMA_NOT_UPDATED_MESSAGE, migrations: 'migrations', schema: gitlab.html_link("db/schema.rb")) end if geo_migration_created && !geo_db_schema_updated warn format(SCHEMA_NOT_UPDATED_MESSAGE, migrations: 'Geo migrations', schema: gitlab.html_link("ee/db/geo/schema.rb")) end