Files
sure/db/migrate
Jeff 1e818e5c6d fix(migrations): scope admin-backfill to a MigrationUser model (#1716) (#1871)
* fix(migrations): scope admin-backfill to a MigrationUser model (#1716)

`bin/rails db:migrate` on an empty database aborts at
`20240520074309_add_admin_role_to_current_users.rb` because
`User.update_all` loads the production User class, which declares
`enum :ui_layout` for a column added by a much later migration
(`20251030140000_add_ui_layout_to_users`). The enum macro then raises
`Undeclared attribute type for enum 'ui_layout' in User` and every
subsequent migration is skipped, leaving the DB in a partial state.

Apply the same MigrationUser pattern already used by
`AddUiLayoutToUsers` — a migration-scoped subclass of
`ApplicationRecord` with only the table name set, so it doesn't load
the production enum declarations.

Closes #1716

* fix(migrations): inherit MigrationUser from ActiveRecord::Base, not ApplicationRecord (#1716)

@jjmata + @JSONbored both flagged that the nested MigrationUser inherited
from ApplicationRecord, which can pull in concerns / callbacks / default
scopes added to ApplicationRecord in the future and re-introduce the
exact loading problem this migration is meant to avoid. Switch to
ActiveRecord::Base — the idiomatic Rails pattern for migration-only
models — and extend the inline comment to record the rationale.

---------

Co-authored-by: jeffrey701 <jeffrey701@users.noreply.github.com>
2026-06-02 15:55:05 +02:00
..
2024-02-02 09:05:04 -06:00
2024-02-02 09:05:04 -06:00