Add rm -f db/structure.sql to reset the test database

When `db/structure.sql` exists, it's used when doing `rails db:migrate`
instead of running the migrations. When switching to a branch with less
migrations, the test database will be created with the
`db/structure.sql` file which contains the migrations of the previous
branch. They should not be there.

To have the correct database structure for tests, the `db/structure.sql`
file must be removed before running `db:migrate`.
This commit is contained in:
Christophe Bliard
2025-11-13 11:35:03 +01:00
parent bf316761e9
commit 8b25e16864
+1 -1
View File
@@ -672,7 +672,7 @@ class Formatter
end
def reset_test_database_command
"bin/rails db:drop db:create db:migrate RAILS_ENV=test"
"rm -f db/structure.sql; bin/rails db:drop db:create db:migrate RAILS_ENV=test"
end
def precompile_assets_command