spree_shared icon indicating copy to clipboard operation
spree_shared copied to clipboard

Use `Apartment::Tenant.drop` instead of raw SQL

Open zavan opened this issue 4 years ago • 0 comments

This PR changes the TenantInitializer to use Apartment::Tenant.drop instead of the raw DROP SCHEMA IF EXISTS #{db_name} CASCADE SQL, which only works for PostgreSQL.

This allows the task to be used with MySQL (which has no CASCADE option), SQLite3 (which "drops databases" by deleting the DB file), and other adapters supported by apartment, besides PostgreSQL.

Fixes #13.

I also think that the task shouldn't drop existing tenants by default, but only if the user passes a "force" flag. But this is a separate issue.

zavan avatar Feb 17 '21 15:02 zavan