Class: Apartment::Adapters::Sqlite3Adapter

Inherits:
AbstractAdapter show all
Defined in:
lib/apartment/adapters/sqlite3_adapter.rb

Overview

v4 SQLite3 adapter using file-per-tenant isolation.

Resolves tenant-specific connection configs by constructing a database file path from the base config’s directory and the environmentified tenant name. SQLite creates the file on first connection, so create_tenant only ensures the directory exists.

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#connection_config

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#create, #default_tenant, #drop, #environmentify, #initialize, #migrate, #process_excluded_models, #process_pinned_model, #process_pinned_models, #seed, #validated_connection_config

Constructor Details

This class inherits a constructor from Apartment::Adapters::AbstractAdapter

Instance Method Details

#resolve_connection_config(tenant, base_config: nil) ⇒ Object



15
16
17
18
19
# File 'lib/apartment/adapters/sqlite3_adapter.rb', line 15

def resolve_connection_config(tenant, base_config: nil)
  config = base_config || send(:base_config)
  db_dir = config['database'] ? File.dirname(config['database']) : 'db'
  config.merge('database' => File.join(db_dir, "#{environmentify(tenant)}.sqlite3"))
end