Sha256: ad25b9d0232f548a1e97e73112cf9700ce0c1b8f8f8ec7965b73da7b526e156c
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module ActiveTenant class Base ADAPTERS = { sqlite3: SQLiteAdapter, postgresql: PostgresAdapter } delegate :all, :create, :remove, :with, :connection_settings, :name, :global, :global?, to: :adapter def migrate(name, version=nil) ::ActiveRecord::Base.logger.info "[ActiveTenant] Migrating tenant: #{name}" with name do ::ActiveRecord::Migrator.migrate(::ActiveRecord::Migrator.migrations_path, version) do |migration_proxy| [:all, ::ActiveRecord::Base.tenant_name.to_sym].include? migration_proxy.send(:migration).class.tenant end end end def migrate_all(version=nil) all.each do |tenant| migrate tenant, version end end def migrate_global(version=nil) ::ActiveRecord::Base.logger.info '[ActiveTenant] Migrating global db' with global do ::ActiveRecord::Migrator.migrate(::ActiveRecord::Migrator.migrations_path, version) do |migration_proxy| migration_proxy.send(:migration).class.tenant.nil? end end end private def adapter @adapter ||= ADAPTERS[::ActiveRecord::Base.connection_config[:adapter].to_s.gsub('jdbc', '').to_sym].new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_tenant-0.0.4 | lib/active_tenant/base.rb |