Sha256: 36d136bcdbc0981463acc3fefbea88c7285fba543ba086134303c5a8770232fb

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

#
# This class provides an abstract for the tenant interface. Whilst any Proc
# could be used, it's safest for people to sub-class to ensure that any future
# interface changes are catered for.
#
# A tenant class's responsibility is to receive a block, around which it should
# handle switching to the given tenant's configuration, ensuring that if an
# exception occurs, the configuration is reset back to the global configuration.
#
module Penthouse
  module Tenants
    module Migratable

      # @param db_schema_file [String] a path to the DB schema file to load, defaults to Penthouse.configuration.db_schema_file
      # @return [void]
      def migrate(db_schema_file: Penthouse.configuration.db_schema_file)
        if File.exist?(db_schema_file)
          # run the migrations within this schema
          call do
            # don't output all the log messages
            ActiveRecord::Schema.verbose = false
            # run the schema file to migrate this tenant
            load(db_schema_file)
          end
        else
          raise ArgumentError, "#{db_schema_file} does not exist"
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
penthouse-0.12.2 lib/penthouse/tenants/migratable.rb
penthouse-0.12.1 lib/penthouse/tenants/migratable.rb
penthouse-0.12.0 lib/penthouse/tenants/migratable.rb
penthouse-0.11.0 lib/penthouse/tenants/migratable.rb
penthouse-0.10.1 lib/penthouse/tenants/migratable.rb