Skip to content

Instantly share code, notes, and snippets.

@furaji
Created September 11, 2019 04:41
Show Gist options
  • Save furaji/c02737cb62a660ee17533b0000510187 to your computer and use it in GitHub Desktop.
Save furaji/c02737cb62a660ee17533b0000510187 to your computer and use it in GitHub Desktop.
ridgepole_migrate
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
system! 'ridgepole -c config/database.yml --apply --dry-run -f Schemafile'
puts '------------'
puts 'apply? [y/n]'
puts '------------'
case gets.chomp
when 'yes', 'YES', 'y'
system! 'ridgepole -c config/database.yml --apply -f Schemafile'
system! 'ridgepole -c config/database.yml --apply -f Schemafile -E test'
system! 'ridgepole -c config/database.yml --export -o Schemafile'
system! 'bundle exec annotate'
when 'no', 'NO', 'n'
exit 1
else
exit 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment