Is there any difference in using up/down vs change/reversible methods in Rails migrations? -
in rails migration, make difference, if this:
def foo end def down bar end or this:
def change reversible |direction| direction.up { foo } direction.down { bar } end end ?
i think it's better use change method if part of migration includes reversible methods, such create_table, add_column etc.. other that, there difference?
as show it, there no advantage. main advantage lot of time don't need write down method / block @ all, eg
class somemigration < activerecord::migration def change create_table :articles |t| ... end end end the reversible method used when there small part of migration activerecord doesn't know how reverse (eg raw sql statement)
Comments
Post a Comment