Stop pinning new migrations to a Rails version the app left behind

Merged
JA
3mo ago
+1-1

What this fixes

.cursor/rules/general-rules.mdc:14 has said, since the Rails 7.2 days:

ActiveRecord migrations must inherit from ActiveRecord::Migration[7.2]. Do not use version 8.0 yet.

The app runs 8.1 — Gemfile.lock has rails (8.1.3.1), db/schema.rb declares ActiveRecord::Schema[8.1]. So the rule bans a version that stopped being the question and pins every new migration a major behind the framework it runs on.

Why now

It has started costing review time instead of saving it. CodeRabbit reads .cursor/rules, and on #170 it flagged a correct [8.1] migration as violating "the repository migration contract", citing this line. The tree does not back the rule either. On this branch's base — the fork's main — 424 migrations carry 2 on [8.1] (20260628171409_add_amount_to_transfers.rb and 20260628171431_add_transfer_id_to_transactions.rb), with the rest on [7.2]. So the pin is not universally obeyed even here, and the two that break it are the ones that match the app.

(Correcting an earlier version of this line, which cited 20260911165424_create_fio_items_and_accounts as a recent [8.1] migration. That file is on mirror/upstream-main, not on this PR's base, so it was the wrong tree to cite — thank you to the Gatekeeper pass for catching it. It is real and it is [8.1], and it is the evidence used in the upstream PR, where main does carry it: 7 of 427 migrations there are [8.1].)

Upstream's AGENTS.md already says the right thing: "New migrations use the current Rails migration version; leave historical migration versions intact." This rule now says the same, and names only where to look — the ActiveRecord::Schema[...] header in db/schema.rb — so it carries no version literal of its own and has nothing left to go stale.

That last part changed during review: the rule first read [8.1] and named db/schema.rb, which Codacy flagged as a second source of truth and the Gatekeeper pass asked me to adopt or decline explicitly. Adopted, in 662e4c568, and slightly further than the suggested wording — that kept an e.g. ActiveRecord::Schema[8.1], and a weaker copy of the number is still a copy.

The provider-generator doc's example migration moves too, since it is a template people copy verbatim — an example that declares [7.2] reintroduces the rule the rule line just removed, one generated provider at a time.

Worth being honest that this leaves the version number written down in two places, and the example is the one that will go stale again at the next Rails upgrade. The difference is that it is now the only one: the rule line names db/schema.rb as the source of truth rather than a number, so after an upgrade there is exactly one file to re-read and the drift is detectable by reading it. Deriving the example from the schema is not worth doing to a doc snippet.

Scope

Docs and rules only. No code, no schema, no behaviour, nothing for CI to exercise beyond lint.