Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Schema migrations not loaded by test:prepare using table_name_prefix #10411
A bug surfaced in RC1 that makes
Expected: Status of migration, "Create products" should be "up".
referenced this issue
May 2, 2013
A more detailed explanation:
When the rake task runs, it fails saying there are pending migrations. If I look in the test database's nep_schema_migrations table, there is only a single record with value 0 (prefix=nep_). Although the schema has been successfully loaded.
After digging into the problem, I discovered the reason for the bug was that in ActiveRecord::Migration, the call to assume_migrated_upto_version was picked up by method_missing which than forwarded the request to connection. But before it forwarded the request, it "fixed" the method arguments by calling Migrator.proper_table_name on it. This turned a regular version such as 20130322190237 into nep_20130322190237. Then, assume_migrated_upto_version was calling to_i on the argument which resulted in the 0 I saw in the schema_migrations table. Additionally, later in the method it only inserts versions that are less than the current version. Since none of them will be less than 0, the 0 is the only version that was inserted.
The solution is to simply send assume_migrated_upto_version directly to the proper receiver.
This problem has been around for a while, but only with Rails 4.0.0.rc1 did it start to matter as test:prepare now does a check to make sure the test database does not have any pending migrations.