Skip to content

Conversation

@Hamms
Copy link
Contributor

@Hamms Hamms commented Jan 30, 2026

We override table_exists for our temporary mock dashboard database, but this also ends up overriding the check for tables that we don't consider temporary; most notably, the schema migrations table. This has worked up until now because Rails in versions earlier than 7.0 has a small bug in that it actually checks for the presence of the schema migrations table in the schema cache rather than checking for the actual table.

This was fixed in Rails 7.0, which caused our tests to start failing with:

Minitest::UnexpectedError:         ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '20260120193121' for key 'schema_migrations.PRIMARY'

As they attempted to recreate a table which already exists.

The simple fix is to update our override logic to return the correct result when checking for the existence of these tables.

We override `table_exists` for our temporary mock dashboard database,
but this also ends up overriding the check for tables that we don't
consider temporary; most notably, the schema migrations table. This has
worked up until now because Rails in versions earlier than 7.0 has a
small bug in that it actually checks for the presence of the schema
migrations table in the schema cache rather than checking for the actual
table.

This [was fixed in Rails 7.0](rails/rails#43877),
which caused our tests to start failing with:

    Minitest::UnexpectedError:         ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '20260120193121' for key 'schema_migrations.PRIMARY'

As they attempted to recreate a table which already exists.

The simple fix is to update our override logic to return the correct result
when checking for the existence of these tables.
@Hamms Hamms marked this pull request as ready for review January 30, 2026 17:57
@Hamms Hamms added the Rails Upgrade All work related to upgrading the version of Ruby on Rails we use. label Jan 30, 2026
@Hamms Hamms requested a review from a team January 30, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rails Upgrade All work related to upgrading the version of Ruby on Rails we use.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants