Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/railties/databases.rake
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ db_namespace = namespace :db do
end

# desc 'Resets your database using your migrations for the current environment'
task reset: ["db:drop", "db:create", "db:migrate"]
task reset: ["db:drop", "db:create", "db:schema:dump", "db:migrate"]

desc 'Run the "up" for a given migration VERSION.'
task up: :load_config do
Expand Down
18 changes: 18 additions & 0 deletions railties/test/application/rake/dbs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,24 @@ def db_migrate_and_status(expected_database)
assert_equal "[\"ar_internal_metadata\", \"comments\", \"schema_migrations\"]", list_tables[]
end

test "db:migrate:reset regenerates the schema from migrations" do
app_file "db/migrate/01_a_migration.rb", <<-MIGRATION
class AMigration < ActiveRecord::Migration::Current
create_table(:comments) {}
end
MIGRATION
rails("db:migrate")
app_file "db/migrate/01_a_migration.rb", <<-MIGRATION
class AMigration < ActiveRecord::Migration::Current
create_table(:comments) { |t| t.string :title }
end
MIGRATION

rails("db:migrate:reset")

assert File.read("#{app_path}/db/schema.rb").include?("title")
end

def db_schema_dump
Dir.chdir(app_path) do
args = ["generate", "model", "book", "title:string"]
Expand Down