Skip to content

Instantly share code, notes, and snippets.

@eamonn-webster
Last active December 18, 2015 04:19
Show Gist options
  • Save eamonn-webster/5724995 to your computer and use it in GitHub Desktop.
Save eamonn-webster/5724995 to your computer and use it in GitHub Desktop.
find and execute trove migrations
# load all migrations
Dir[Rails.root.join('db/migrate/*.rb')].each { |f| require f }
#find the trove migrations classes
# and the corresponding file
# sort by file
# instantiate
# and invoke change
# rescuing from any exception.
trove_migrations = Trove::BaseMigration.subclasses.collect { |c|
[c] + Dir[Rails.root.join("db/migrate/*#{c.name.tableize.singularize.gsub('trofe','trove')}*.rb")]
}.sort{ |a, b| a[1] <=> b[1] }.collect{ |pair| pair[0] }
trove_migrations.each { |c|
begin
mig = c.new
if mig.respond_to? :change
mig.change
else
mig.up
end
rescue
end
}
# TODO dump schema to trove_schema.rb
@eamonn-webster
Copy link
Author

Next step would be to dump the schema,
then at start of tests create the trove schema from trove_schema.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment