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 and fractaledmind committed May 13, 2024
1 parent 4a20aa5 commit ad06b38
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 ad06b38

Please sign in to comment.