Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9436 (closed defect: untested)

Opened 1 year ago

Last modified 11 months ago

[PATCH] reset_column_information problem in migrations

Reported by: sur Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: migration, reset_column_information
Cc:

Description

Whenever we change the table's schema from the migration using add_column, remove_column, change_column or anything else, the related model's column information doesn't get updated automatically and it becomes a stale object and gives errors on communicating with DB. The migrations are not properly documented for this... The migration doc looks like...

# Sometimes you'll want to add a column in a migration and populate it immediately after. In that case, you'll need
# to make a call to Base#reset_column_information in order to ensure that the model has the latest column data from
# after the new column was added. Example:

which is only specifying that you should call the method "reset_column_information" if the same model is immediately needed to populate the db... whereas the model remains stale even in the successive migrations without calling that method.

So, either the doc should be improved or the migrations should automatically call that method on all the models loaded on that time at the end of each migration.

Attachments

reset_column_information_in_migration_fixed.diff (1.1 kB) - added by sur on 08/30/07 02:37:49.
patch for automated call to reset_column_information for all the loaded model classes.
reset_column_information_in_migration_fixed_doc.diff (1.1 kB) - added by sur on 08/30/07 02:38:43.
updated doc for migrations on reset_column_information

Change History

08/30/07 02:37:49 changed by sur

  • attachment reset_column_information_in_migration_fixed.diff added.

patch for automated call to reset_column_information for all the loaded model classes.

08/30/07 02:38:43 changed by sur

  • attachment reset_column_information_in_migration_fixed_doc.diff added.

updated doc for migrations on reset_column_information

08/30/07 02:39:18 changed by sur

  • summary changed from reset_column_information problem in migrations to [PATCH] reset_column_information problem in migrations.

adding both the possible patches...

10/26/07 03:22:05 changed by marcel

  • status changed from new to closed.
  • resolution set to untested.