Posted here as it''s a somewhat opinionated patch. http://dev.rubyonrails.org/ticket/9625 why have: class DoSomethingNastyToTheDatabase > ActiveRecord::Migration def self.up execute "some nasty database call" end def self.down raise ActiveRecord::IrreversibleMigration end end when you could simply do: class DoSomethingNastyToTheDatabase > ActiveRecord::Migration def self.up execute "some nasty database call" end end Attached to the ticket is a patch to implement this, keep backwards compatibility, improve docs and improve test coverage. -- tim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Mislav Marohnić
2007-Sep-22 14:04 UTC
Re: Migrations w/o down methods irreversible by default
On 9/22/07, Tim Lucas <t.lucas@toolmantim.com> wrote:> > > Posted here as it''s a somewhat opinionated patch.I support this, makes it behave just as I would expect. BTW, syntax highlighting in Trac? Never knew about that! http://dev.rubyonrails.org/wiki/WikiProcessors --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
> Posted here as it''s a somewhat opinionated patch.This doesn''t match my usage pattern. Usually my migrations that just go up are about fixing data or something else, like populating a counter cache. I still want to be able to go 3 versions back, but if there''s an irreversible mixed in there it''ll halt. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Lance Carlson
2007-Sep-22 16:28 UTC
Re: Migrations w/o down methods irreversible by default
So then what is the point of the IrreversibleMigration exception? If you are going to force people to create a rollback then that exception should not exist. On 9/22/07, DHH <david.heinemeier@gmail.com> wrote:> > > Posted here as it''s a somewhat opinionated patch. > > This doesn''t match my usage pattern. Usually my migrations that just > go up are about fixing data or something else, like populating a > counter cache. I still want to be able to go 3 versions back, but if > there''s an irreversible mixed in there it''ll halt. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Lance Carlson
2007-Sep-22 16:30 UTC
Re: Migrations w/o down methods irreversible by default
IMO if we''re going to have an IrreversibleMigration exception, we should allow one to omit the down method. Sorry for not specifying :) On 9/22/07, Lance Carlson <lancecarlson@gmail.com> wrote:> So then what is the point of the IrreversibleMigration exception? If > you are going to force people to create a rollback then that exception > should not exist. > > On 9/22/07, DHH <david.heinemeier@gmail.com> wrote: > > > > > Posted here as it''s a somewhat opinionated patch. > > > > This doesn''t match my usage pattern. Usually my migrations that just > > go up are about fixing data or something else, like populating a > > counter cache. I still want to be able to go 3 versions back, but if > > there''s an irreversible mixed in there it''ll halt. > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Sat, 22 Sep 2007 12:30:08 -0400, Lance Carlson wrote:> IMO if we''re going to have an IrreversibleMigration exception, we > should allow one to omit the down method. Sorry for not specifying :)It seems safer to assume that a missing down is equivalent to "either there''s no way to reverse this, or I didn''t think about how to reverse this", which this patch would do. An empty down would signify "reversing this is a no-op", and it seems like that would still work with this patch... -- Jay Levitt | Boston, MA | My character doesn''t like it when they Faster: jay at jay dot fm | cry or shout or hit. http://www.jay.fm | - Kristoffer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Lance Carlson
2007-Sep-22 18:15 UTC
Re: Migrations w/o down methods irreversible by default
Agreed. There should also be an exception IDidntThinkAboutTheReverse :) On 9/22/07, Jay Levitt <jay+news@jay.fm> wrote:> > On Sat, 22 Sep 2007 12:30:08 -0400, Lance Carlson wrote: > > > IMO if we''re going to have an IrreversibleMigration exception, we > > should allow one to omit the down method. Sorry for not specifying :) > > It seems safer to assume that a missing down is equivalent to "either > there''s no way to reverse this, or I didn''t think about how to reverse > this", which this patch would do. > > An empty down would signify "reversing this is a no-op", and it seems like > that would still work with this patch... > > -- > Jay Levitt | > Boston, MA | My character doesn''t like it when they > Faster: jay at jay dot fm | cry or shout or hit. > http://www.jay.fm | - Kristoffer > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Steven A Bristol
2007-Sep-22 18:23 UTC
Re: Migrations w/o down methods irreversible by default
-1 I don''t see that there is anything that needs fixing here. This seems like a perfect fit for a plugin. -- Thank you, Steven A Bristol steve@lesseverything.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 23/09/2007, at 2:20 AM, DHH wrote:>> Posted here as it''s a somewhat opinionated patch. > > This doesn''t match my usage pattern. Usually my migrations that just > go up are about fixing data or something else, like populating a > counter cache. I still want to be able to go 3 versions back, but if > there''s an irreversible mixed in there it''ll halt.Yeah I actually have your workflow too. I''m not talking about changing behaviour and removing the self.down from the default template, just improving the use case of creating an IrreversibleMigration. I guess really there''s 3 categories of migrations: (1) Up + down, reversible (2) Up only, reversible (3) Up only, irreversible At the moment things are set up so (1) and (2) are easy peasy (from the generator template), but (3) is harder than it should be. Why not just remove self.down? At the moment (3) requires looking up the (currently incorrect) API instructions and writing a message why you''re raising. As an aside: it seems odd/useless to me that the IrreversibleMigration class is defined and then only referenced in the documentation.... it''s not actually handled anywhere. You could raise any old error. -- tim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 23/09/2007, at 4:23 AM, Steven A Bristol wrote:> -1 > > I don''t see that there is anything that needs fixing here. This seems > like a perfect fit for a plugin.pfft I wouldn''t even bother with a plugin. A quick suggestion that I thought might ring a note. If it doesn''t, then let it die a quick death. Its a small thing, but it''s the small things yakyakyak -- tim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
I like the idea of a migration without a down method being irreversible, and sympathise with some of the feelings of inelegance when raising an exception. On 9/22/07, Tim Lucas <t.lucas@toolmantim.com> wrote:> > On 23/09/2007, at 2:20 AM, DHH wrote: > > This doesn''t match my usage pattern. Usually my migrations that just > > go up are about fixing data or something else, like populating a > > counter cache. I still want to be able to go 3 versions back, but if > > there''s an irreversible mixed in there it''ll halt.Since the migration generator creates blank down methods, most people won''t be affected at all. Migrations that do raise exceptions will still halt; migrations that are lacking down methods but which ARE reversible can simply have them added and any stalled migration can continue thereafter.> As an aside: it seems odd/useless to me that the > IrreversibleMigration class is defined and then only referenced in > the documentation.... it''s not actually handled anywhere. You could > raise any old error.For me, this is as good a reason as any to reconsider how migrations handle reversibility. Who else has scratched their head trying to remember what exception we ought to throw to prevent migrations down from the current point? And it doesn''t even matter! We could just as easily call exit(-1) (and output something to stderr if we''re feeling generous). -- * J * ~ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2007-Sep-22 22:28 UTC
Re: Migrations w/o down methods irreversible by default
> For me, this is as good a reason as any to reconsider how migrations > handle reversibility. Who else has scratched their head trying to > remember what exception we ought to throw to prevent migrations down > from the current point? And it doesn''t even matter! We could just as > easily call exit(-1) (and output something to stderr if we''re feeling > generous).I''ll confess to having more than one migration with nil.asdf in the down method simply because I don''t remember how to correctly mark them as irreversible... However I think I would prefer to encourage users to explain WHY something isn''t reversible, if just for the other users. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
lancecarlson@gmail.com
2007-Sep-22 22:43 UTC
Re: Migrations w/o down methods irreversible by default
It would beinteresting if the irreversible migration accepted a reason attribute and printed that reason when the exception is raised in console. Perhaps this would be a way to make self down useful in situations where all you are doing is raising the exception. Sent via BlackBerry from T-Mobile -----Original Message----- From: "Michael Koziarski" <michael@koziarski.com> Date: Sat, 22 Sep 2007 15:28:35 To:rubyonrails-core@googlegroups.com Subject: [Rails-core] Re: Migrations w/o down methods irreversible by default> For me, this is as good a reason as any to reconsider how migrations > handle reversibility. Who else has scratched their head trying to > remember what exception we ought to throw to prevent migrations down > from the current point? And it doesn't even matter! We could just as > easily call exit(-1) (and output something to stderr if we're feeling > generous).I'll confess to having more than one migration with nil.asdf in the down method simply because I don't remember how to correctly mark them as irreversible... However I think I would prefer to encourage users to explain WHY something isn't reversible, if just for the other users. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Koziarski
2007-Sep-23 00:51 UTC
Re: Migrations w/o down methods irreversible by default
On 9/22/07, lancecarlson@gmail.com <lancecarlson@gmail.com> wrote:> It would beinteresting if the irreversible migration accepted a reason attribute and printed that reason when the exception is raised in console. Perhaps this would be a way to make self down useful in situations where all you are doing is raising the exception. > Sent via BlackBerry from T-MobilePerhaps we could get most of that by just having a specific rescue block for IrreversibleMigration which printed out a nice error message? Anyone care to take a stab at it? -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Manfred Stienstra
2007-Sep-23 09:49 UTC
Re: Migrations w/o down methods irreversible by default
On Sep 23, 2007, at 2:51 AM, Michael Koziarski wrote:> > Perhaps we could get most of that by just having a specific rescue > block for IrreversibleMigration which printed out a nice error > message? Anyone care to take a stab at it?Sure, here''s a stab: http://dev.rubyonrails.org/ticket/9634 Manfred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---