rails/rails — pull request #4157 by cbarton (2011-12-24 01:51:23+00:00)
Title: Fixing a schema:load when using a prefix and suffix on the tables

In the cases where one wants to work with schemas in their databases, they would want to load the schema file on each schema to keep it up to date. Since the ConnectionAdapter#table_exists? method disregards the schema_search_path, we must alter ActiveRecord::Base#table_name_prefix to include the proper scoping. Doing this works up until the point of updating the schema_migrations table when assuming the new version.

This bug occurs because when assume_migration_upto_version goes through Migration's method_missing, it appends the table_name_prefix to the version number. Eg, when arriving at the assume_migration_upto_version, the version number is "schema.#####". The next step in the line is to turn that number into an integer, which is always 0 since it is a string. This makes the version in the schema_migrations table on that schema equal to 0 and not the correct value in the schema file.

This fix patches that in the method missing so that we do not munge the number.

cbarton