SHARE
TWEET

Untitled

a guest Mar 20th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env ruby
  2. require "./config/environment"
  3. require "active_record/migration"
  4. require "tty-prompt"
  5. migration = TTY::Prompt.new(interrupt: :exit)
  6.  
  7. migration_version = migration.select("Select Migration", filter: true) do |menu|
  8.   ActiveRecord::Base.connection.migration_context.migrations_status.reverse.each do |status, version, name|
  9.     menu.choice "#{status.center(8)}  #{version.ljust(14)}  #{name}", version
  10.   end
  11. end
  12.  
  13. migration_action = migration.select("Version: #{ActiveRecord}", filter: true) do |menu|
  14.   menu.choice "migrate", "db:rollback"
  15.   menu.choice "rollback", "db:rollback"
  16.   menu.choice "redo", "db:migrate:redo"
  17. end
  18.  
  19. system("VERSION=#{migration_version} rails #{migration_action}")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top