Fix state leak from language ID constraint migration specs

What does this MR do and why?

Removes the add_constraint call from the after hook in spec/migrations/20260811122029_add_programming_languages_language_id_not_null_constraint_spec.rb and spec/migrations/20260811122031_add_repository_languages_language_id_not_null_constraint_spec.rb. The hooks now only drop the constraint.

Since 2026-09-22, spec/migrations/20260807142854_remove_programming_languages_without_language_id_spec.rb fails on master with PG::CheckViolation: new row for relation "programming_languages" violates check constraint "check_4e6f0ff707".

check_4e6f0ff707 is only added when Gitlab.com_except_jh? is true and is not in db/structure.sql, so it does not exist in the test database unless a spec adds it. The after hook re-added it after each example. When that spec runs before the removal spec in the same process, the constraint is still present. The removal spec's schema_migrate_down! runs before its before block stubs Gitlab.com_except_jh?, so the constraint migration's down is a no-op and the constraint stays. Inserting a row with language_id: nil then fails.

RSpec test balancing runs files longest expected duration first. In job logs from 2026-09-22 the constraint spec's expected duration went from 63 s to 70 s while the removal spec's went from 68 s to 60 s, so the constraint spec now runs first when both land on the same node.

The repository_languages spec has the same hook and gets the same change. No current spec is affected by it.

References

Screenshots or screen recordings

Not applicable, spec-only change.

How to set up and validate locally

On master, run:

bin/rspec spec/migrations/20260811122029_add_programming_languages_language_id_not_null_constraint_spec.rb spec/migrations/20260807142854_remove_programming_languages_without_language_id_spec.rb

Three examples fail. On this branch the same command passes. Reversing the file order on master also passes.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

🤖 Generated with Claude Code

Edited by Marcel van Remmerden

Merge request reports

Loading
Loading