diff --git a/lib/spree_shared/tenant_initializer.rb b/lib/spree_shared/tenant_initializer.rb index dbb8ebb..17b6aae 100644 --- a/lib/spree_shared/tenant_initializer.rb +++ b/lib/spree_shared/tenant_initializer.rb @@ -9,10 +9,15 @@ def initialize(db_name) def create_database ActiveRecord::Base.establish_connection #make sure we're talkin' to db - ActiveRecord::Base.connection.execute("DROP SCHEMA IF EXISTS #{db_name} CASCADE") + drop_tenant_if_exists Apartment::Tenant.create db_name end + def drop_tenant_if_exists + Apartment::Tenant.drop db_name + rescue Apartment::TenantNotFound + end + def load_seeds Apartment::Tenant.switch(db_name) do Rails.application.load_seed @@ -42,4 +47,4 @@ def create_admin end end -end \ No newline at end of file +end