Sha256: 946fa5795583d846da8449bfe5f85389901689d5beccd863a8b4407bea84e7e9

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 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
      def migrate(db_schema_file: Penthouse.configuration.db_schema_file)
        if File.exist?(db_schema_file)
          # turn off logging schemas
          ActiveRecord::Schema.verbose = false
          # run the migrations within this schema
          call do
            puts ActiveRecord::Base.connection.schema_search_path
            load(db_schema_file)
          end
        else
          raise ArgumentError, "#{db_schema_file} does not exist"
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
penthouse-0.3.0 lib/penthouse/tenants/migratable.rb