Arthur Rats
2009-Oct-15 07:31 UTC
Check what migrations need to be done inside ruby script
Hi all I have a feature in a small app that creates the migration files needed from a small GUI it executes the rake task command to generate the migration files from inside a ruby script so I need to get a simple way to know what files havent been processed in the current migration compared to the db schema e.g. inside the db/migrate I count the files with something like Dir.glob("db/migrate/*").size then I get the current db version info with %x{rake.bat db:version}.split('' '').last.to_i then I compare the two values so that I can automatically execute from a controller %x{rake.bat db:migrate} #windows fix to add the .bat Is there an easier way to do this? Thanks Art -- Posted via http://www.ruby-forum.com/.
Norm Scherer
2009-Oct-15 16:28 UTC
Re: Check what migrations need to be done inside ruby script
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Arthur Rats wrote: <blockquote cite="mid:88b992f64dbd437d23b5458f2f3e0cc4-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org" type="cite"> <pre wrap="">Hi all I have a feature in a small app that creates the migration files needed from a small GUI it executes the rake task command to generate the migration files from inside a ruby script so I need to get a simple way to know what files havent been processed in the current migration compared to the db schema e.g. inside the db/migrate I count the files with something like Dir.glob("db/migrate/*").size then I get the current db version info with %x{rake.bat db:version}.split('' '').last.to_i then I compare the two values so that I can automatically execute from a controller %x{rake.bat db:migrate} #windows fix to add the .bat Is there an easier way to do this? Thanks Art </pre> </blockquote> <font size="-1"><font face="Helvetica, Arial, sans-serif">Why not just do the migration and let rails figure out what needs to be done. You are duplicating what rake db:migrate does. <br> <br> Norm<br> </font></font> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. <br> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en<br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>