Expand the caveat about models in migrations in the rails guide. #7050

Merged
merged 1 commit into from Oct 11, 2012

Conversation

Projects
None yet
4 participants
@kytrinyx
Contributor

kytrinyx commented Jul 13, 2012

This is an attempt to address issue #6939, where an earlier migration
added a column to the database, and a later migration uses a model and
references that column.

When both migrations were run together with rake db:migrate the column
information in memory still referenced the old table structure.

Running the migrations separately fixed this, as a new connection was
then established before referencing the model. Explicitly calling
reset_column_information is a more reliable workaround.

@kytrinyx

This comment has been minimized.

Show comment
Hide comment
@kytrinyx

kytrinyx Jul 13, 2012

Contributor

I'm not sure if this documentation change is enough to address the issue in #6939. Do you think it would be helpful to be more explicit?

Contributor

kytrinyx commented Jul 13, 2012

I'm not sure if this documentation change is enough to address the issue in #6939. Do you think it would be helpful to be more explicit?

@dmathieu

This comment has been minimized.

Show comment
Hide comment
@dmathieu

dmathieu Jul 14, 2012

Contributor

This is not informative enough. It might make people think there is some latency for new database fields to be considered, when it's only a simple in memory cache.
You could also mention the use of reset_column_information.

Contributor

dmathieu commented Jul 14, 2012

This is not informative enough. It might make people think there is some latency for new database fields to be considered, when it's only a simple in memory cache.
You could also mention the use of reset_column_information.

@kytrinyx

This comment has been minimized.

Show comment
Hide comment
@kytrinyx

kytrinyx Jul 14, 2012

Contributor

Good point. Ok, I've tried to expand it at the bottom of the existing section. I initially went overboard with code examples, but I think that it's not important enough to warrant a huge section for itself, I just want to make the point that using models is iffy and can lead to subtle and complicated problems, and that this should be handled with care.

I'd be happy to tweak further if you have any good ideas.

Contributor

kytrinyx commented Jul 14, 2012

Good point. Ok, I've tried to expand it at the bottom of the existing section. I initially went overboard with code examples, but I think that it's not important enough to warrant a huge section for itself, I just want to make the point that using models is iffy and can lead to subtle and complicated problems, and that this should be handled with care.

I'd be happy to tweak further if you have any good ideas.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
Member

rafaelfranca commented Aug 1, 2012

@vijaydev

This comment has been minimized.

Show comment
Hide comment
@vijaydev

vijaydev Oct 10, 2012

Member

I feel this is a bit too verbose, but I'm ok to merge. Please either rebase & squash the commits into one, Or make these changes in docrails. Thanks.

Member

vijaydev commented Oct 10, 2012

I feel this is a bit too verbose, but I'm ok to merge. Please either rebase & squash the commits into one, Or make these changes in docrails. Thanks.

Expand caveat about models in migrations (rails guide)
This is an attempt to address issue #6939, where an earlier migration
added a column to the database, and a later migration uses a model and
references that column.

When both migrations were run together with `rake db:migrate` the column
information in memory still referenced the old table structure.

Running the migrations separately fixed this, as a new connection was
then established before referencing the model. Explicitly calling
`reset_column_information` is a more reliable workaround.
@kytrinyx

This comment has been minimized.

Show comment
Hide comment
@kytrinyx

kytrinyx Oct 10, 2012

Contributor

Thank you. I've rebased and squashed the commits.

Contributor

kytrinyx commented Oct 10, 2012

Thank you. I've rebased and squashed the commits.

vijaydev added a commit that referenced this pull request Oct 11, 2012

Merge pull request #7050 from kytrinyx/documentation-reset-column-info
Expand the caveat about models in migrations in the rails guide.

@vijaydev vijaydev merged commit cd98c25 into rails:master Oct 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment