diff --git a/config/database.yml b/config/database.yml index a9be456195a..c8f44946d92 100644 --- a/config/database.yml +++ b/config/database.yml @@ -16,10 +16,23 @@ development: # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. + +<% + test_db = ENV["RAILS_DB"] + if !test_db.present? + test_db = "discourse_test" + + if num = ENV["TEST_ENV_NUMBER"] + num = num.presence || "1" + test_db += "_#{num}" + end + end +%> + test: prepared_statements: false adapter: postgresql - database: <%= ENV["RAILS_DB"] ? ENV["RAILS_DB"] : "discourse_test" %> + database: <%= test_db %> min_messages: warning pool: 5 timeout: 5000 diff --git a/lefthook.yml b/lefthook.yml index 1ac4f9c87f0..df4a83f4e78 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -9,6 +9,8 @@ pre-commit: run: yarn eslint --ext .es6 -f compact {staged_files} yaml-syntax: glob: "*.{yaml,yml}" + # database.yml is an erb file not a yaml file + exclude: "database.yml" run: bundle exec yaml-lint {staged_files} commands: &commands diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 05cf2bd3433..626acd57602 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -68,20 +68,23 @@ end # we need to run seed_fu every time we run rake db:migrate task 'db:migrate' => ['load_config', 'environment', 'set_locale'] do |_, args| + ActiveRecord::Tasks::DatabaseTasks.migrate - Rake::Task['db:_dump'].invoke + if !Discourse.is_parallel_test? + Rake::Task['db:_dump'].invoke + end SeedFu.seed(DiscoursePluginRegistry.seed_paths) - unless Discourse.skip_post_deployment_migrations? + if !Discourse.skip_post_deployment_migrations? puts print "Optimizing site icons... " SiteIconManager.ensure_optimized! puts "Done" end - if MultisiteTestHelpers.load_multisite? + if !Discourse.is_parallel_test? && MultisiteTestHelpers.load_multisite? system("RAILS_DB=discourse_test_multisite rake db:migrate") end end