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

Arthur R. wrote:
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

Why not just do the migration and let rails figure out what needs to be done. You are duplicating what rake db:migrate does.Â

Norm

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---