Skip to content

Commit

Permalink
Add ENV["SKIP_TEST_DATABASE_TRUNCATE"] flag to speed up multi-process…
Browse files Browse the repository at this point in the history
… test runs (rails#51686)
  • Loading branch information
dhh authored May 7, 2024
1 parent 9ad3685 commit e8e077d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Add ENV["SKIP_TEST_DATABASE_TRUNCATE"] flag to speed up multi-process test runs on large DBs when all tests run within default txn. (This cuts ~10s from the test run of HEY when run by 24 processes against the 178 tables, since ~4,000 table truncates can then be skipped.)

*DHH*

* Added support for recursive common table expressions.

```ruby
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/tasks/database_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def reconstruct_from_schema(db_config, format = ActiveRecord.schema_format, file

with_temporary_pool(db_config, clobber: true) do
if schema_up_to_date?(db_config, format, file)
truncate_tables(db_config)
truncate_tables(db_config) unless ENV["SKIP_TEST_DATABASE_TRUNCATE"]
else
purge(db_config)
load_schema(db_config, format, file)
Expand Down

0 comments on commit e8e077d

Please sign in to comment.