Drop all tenant schemas before running db:dev_seed
When running this task we truncate all tables; however, doing so doesn't execute the `after_destroy` callback which drops the generated schema. That meant we could run into a situation where there are schemas in the database with no associated tenant, leading to data inconsistencies. So we're now destroying the tenants (alongside their schemas) before truncating the rest of the database tables.
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
ActiveRecord::Tasks::DatabaseTasks.truncate_all unless Rails.env.test?
|
||||
unless Rails.env.test?
|
||||
Tenant.destroy_all
|
||||
ActiveRecord::Tasks::DatabaseTasks.truncate_all
|
||||
end
|
||||
|
||||
@logger = Logger.new(STDOUT)
|
||||
@logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
||||
msg unless @avoid_log
|
||||
|
||||
Reference in New Issue
Block a user