On 4 March 2010 19:51, Hassan Schroeder <[email protected]> wrote:
> So do I -- but migrating down multiple levels and back up has never
> entered the picture.
Good for you. So you never need to migrate; so you never have
migration troubles. However, those people that do migrate (and not
everyone does *exactly* the same thing as you), might occasion some
problems if they put data access in their migrations. You've asked for
examples, and then dismiss them when they're given rather than
understanding that different situations exist for different people.
> What circumstances require that?
Yesterday I had to work on a project I had never worked on before on
this computer; after cloning from the repository, I had to run
migrations up.
> And yet I still fail to see the evidence supporting this as a "convention",
> especially given that the API includes examples of using migrations to
> *change data*, *not* just structure.
Just because it's possible doesn't mean it's good. There's lots of
things the documentation describes; it tells me all about how I can
use different table names and primary keys for models... but these are
generally *bad* as they risk causing unexpected results as development
goes on, especially if not all the developers that come to the code
during its live realise you've deviated from the conventional
practices (but are there for when you *have* to use them - that pesky
legacy table that needs to be integrated, but can't be refactored).
To me, using models in migrations is the same; and emergency tool;
even the example you linked to shows it as being used to alter
existing data, not seed the DB. If a migration I wrote caused me to
*have* to alter existing data, then I'd do the minimum I had to - as
Rob's example showed - to get it working, but I *wouldn't* use my
normal models, as as stated before, I couldn't guarantee that in six
months time that model would validate correctly for the data in my
migration at that point - or even whether the model existed!
>Just because. Sweet ${DEITY} I give up.
No, not "just because" - not like a parent forbidding behaviour for
the sake of it; but the general acknowledgement that when most people
have to complete a task, they try to do it in a way that makes it
easiest for them, and for the people that come after them. If someone
else chooses to do it differently (either to be awkward; because
they're curious; or even that they don't know better), that's fine, if
a little annoying/frustrating :-)
To be honest, I give up too. Because I answered your queries
patiently, yet you don't seem to acknowledge that there might be
things that work for you that might be seen as bad practice in the
broader community. If you want to continue the discussion, then drop
me a line offlist.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.