Hi all I have to execute some code always after the up methods of my migrations. I wondered if there is a before_up/after_up hook that I can override? Or how could I achieve that? Thanks a lot Josh -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan
2007-Apr-02 19:39 UTC
Re: Migrations: something like before_up/after_up hook?
Joshua Muheim wrote:> Hi all > > I have to execute some code always after the up methods of my > migrations. I wondered if there is a before_up/after_up hook that I can > override? Or how could I achieve that? > > Thanks a lot > JoshUse method call in the end of up method? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2007-Apr-02 19:44 UTC
Re: Migrations: something like before_up/after_up hook?
Jamal Soueidan wrote:> Joshua Muheim wrote: >> Hi all >> >> I have to execute some code always after the up methods of my >> migrations. I wondered if there is a before_up/after_up hook that I can >> override? Or how could I achieve that? >> >> Thanks a lot >> Josh > > Use method call in the end of up method?No, I want it to execute automatically, because it''s always the same action and I don''t want it in every migration... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan
2007-Apr-02 19:47 UTC
Re: Migrations: something like before_up/after_up hook?
Joshua Muheim wrote:> Jamal Soueidan wrote: >> Joshua Muheim wrote: >>> Hi all >>> >>> I have to execute some code always after the up methods of my >>> migrations. I wondered if there is a before_up/after_up hook that I can >>> override? Or how could I achieve that? >>> >>> Thanks a lot >>> Josh >> >> Use method call in the end of up method? > > No, I want it to execute automatically, because it''s always the same > action and I don''t want it in every migration...What do you exactly need to do before or after every migration? create_table, maybe have something before and after ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2007-Apr-02 19:51 UTC
Re: Migrations: something like before_up/after_up hook?
> What do you exactly need to do before or after every migration? > > create_table, maybe have something before and after ?I''m working on a plugin that automatically loads some fixtures according to every migration, something like db/migrate/fixtures/001/countries.yml db/migrate/fixtures/002/users.yml db/migrate/fixtures/003/bla.yml db/migrate/fixtures/003/users.yml So I just want the up method of a migration to check if there''s a directory with the corresponding migration number and any fixtures in it, and if so, to load them. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan
2007-Apr-02 20:09 UTC
Re: Migrations: something like before_up/after_up hook?
Joshua Muheim wrote:>> What do you exactly need to do before or after every migration? >> >> create_table, maybe have something before and after ? > > I''m working on a plugin that automatically loads some fixtures according > to every migration, something like > > db/migrate/fixtures/001/countries.yml > db/migrate/fixtures/002/users.yml > db/migrate/fixtures/003/bla.yml > db/migrate/fixtures/003/users.yml > > So I just want the up method of a migration to check if there''s a > directory with the corresponding migration number and any fixtures in > it, and if so, to load them.This might give you a idea how to do it :) class A # ActiveRecord::Migration def self.create_table puts "create users" end end class Invoke < A # Your own class which inherent ActiveRecord::Migration def self.create_table puts "-> Before" super self.after_table end def self.after_table puts "-> After" end end class CreateUsers < Invoke # This is your new class you would use to create migration, which will inherent Invoke def self.up create_table #create your stuff normal :) end end CreateUsers.up -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jamal Soueidan
2007-Apr-02 20:10 UTC
Re: Migrations: something like before_up/after_up hook?
output: -> Before create users -> After -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2007-Apr-09 10:15 UTC
Re: Migrations: something like before_up/after_up hook?
Thank you for your answer! I remarked that your code only works when calling create_table in the self.up method. But I need it to work in any case, not depending on what I call in the self.up method. As soon as self.up is called, it should execute before_up... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---