Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Use Apartment::Tenant.drop instead of raw SQL #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/spree_shared/tenant_initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,4 +47,4 @@ def create_admin
end
end

end
end