diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2018-10-09 14:34:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-09 14:34:26 -0400 |
commit | 1ddfee9d110025348648320cf098efe8f803f814 (patch) | |
tree | 70c28aba790285b2ebb211b9cdc6fdc496b75b3f /activerecord/lib/active_record/tasks | |
parent | 88813a98b95fda56232270e6754f553986036e57 (diff) | |
parent | 0d435c17b743ae4ae10cff08acd7e7589e60ce4d (diff) | |
download | rails-1ddfee9d110025348648320cf098efe8f803f814.tar.gz rails-1ddfee9d110025348648320cf098efe8f803f814.tar.bz2 rails-1ddfee9d110025348648320cf098efe8f803f814.zip |
Merge pull request #34081 from gmcgibbon/db_migrate_status_move
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']}`" |