Sha256: ac538530509971dbe5309dc96e5a48d6d56385f2328484d2e65eac74a6f8bded
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 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_sym].new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_tenant-0.0.3 | lib/active_tenant/base.rb |