You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid purging the test database when loading a schema:
- Fixrails#50672
- Closesrails#50946
- ### Problem
In adb64db, we added a change to purge the test database whenever
the `load:schema:<name>` was run.
This change meant that in order for the schema to load, 1) the test
database configuration needs to be setup and 2) can be connected
to.
This creates some issues for users if either of both conditions
aren't met. (For 1. it can be argued that it's a user error, but
for 2., it's likely that a production environment can't connect
to the test database).
### Details
I dug to understand why loading a specific schema requires purging
the test database (whereas loading all schema doesn't), but couldn't
really see anything obvious, so I concluded that it may just be some
overly defensive code.
### Solution
Whenever we run a test, Rails maintains all test databases schema,
and if a schema changes, the equivalent of a purge will be executed
on all test databases.
https://github.com/rails/rails/blob/b132744e22de64eb530d6ac407fa4b6b4a926143/railties/lib/rails/testing/maintain_test_schema.rb#L5
I couldn't really think of a negative behaviour difference between
purging the test database eagerly when we load the schema and lazily
when we run the tests, so I simply removed the `purge` rake task
dependency on `schema:load:<name>`.
0 commit comments