diff options
author | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-10-04 16:34:43 -0400 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@gmail.com> | 2018-10-08 13:46:01 -0400 |
commit | 0d435c17b743ae4ae10cff08acd7e7589e60ce4d (patch) | |
tree | 548cb5c123504b686021a22e6bbd8f1ef66f2285 /activerecord/lib/active_record/tasks | |
parent | 3882a4d0d475f1347a7dc3774e9285c80b1c8fe2 (diff) | |
download | rails-0d435c17b743ae4ae10cff08acd7e7589e60ce4d.tar.gz rails-0d435c17b743ae4ae10cff08acd7e7589e60ce4d.tar.bz2 rails-0d435c17b743ae4ae10cff08acd7e7589e60ce4d.zip |
Move db:migrate:status to DatabaseTasks method
Diffstat (limited to 'activerecord/lib/active_record/tasks')
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 5e29085aff..974d7a1c0a 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -197,6 +197,21 @@ module ActiveRecord Migration.verbose = verbose_was end + def migrate_status + unless ActiveRecord::SchemaMigration.table_exists? + Kernel.abort "Schema migrations table does not exist yet." + end + + # output + puts "\ndatabase: #{ActiveRecord::Base.connection_config[:database]}\n\n" + puts "#{'Status'.center(8)} #{'Migration ID'.ljust(14)} Migration Name" + puts "-" * 50 + ActiveRecord::Base.connection.migration_context.migrations_status.each do |status, version, name| + puts "#{status.center(8)} #{version.ljust(14)} #{name}" + end + puts + end + def check_target_version if target_version && !(Migration::MigrationFilenameRegexp.match?(ENV["VERSION"]) || /\A\d+\z/.match?(ENV["VERSION"])) raise "Invalid format of target version: `VERSION=#{ENV['VERSION']}`" |