未验证 提交 33671d30 编写于 作者: E Eileen M. Uchitelle 提交者: GitHub

Merge pull request #36824 from eileencodes/fix-db-seed

Fix db:seed
......@@ -265,6 +265,8 @@ db_namespace = namespace :db do
end
abort %{Run `rails db:migrate` to update your database then try again.}
end
ensure
ActiveRecord::Base.establish_connection(ActiveRecord::Tasks::DatabaseTasks.env.to_sym)
end
namespace :abort_if_pending_migrations do
......
......@@ -349,6 +349,25 @@ class TwoMigration < ActiveRecord::Migration::Current
rails "db:drop" rescue nil
end
end
test "db:seed uses primary database connection" do
@old_rails_env = ENV["RAILS_ENV"]
@old_rack_env = ENV["RACK_ENV"]
ENV.delete "RAILS_ENV"
ENV.delete "RACK_ENV"
db_migrate_and_schema_dump_and_load "schema"
app_file "db/seeds.rb", <<-RUBY
print Book.connection.pool.spec.config[:database]
RUBY
output = rails("db:seed")
assert_equal output, "db/development.sqlite3"
ensure
ENV["RAILS_ENV"] = @old_rails_env
ENV["RACK_ENV"] = @old_rack_env
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册