Sha256: 52b3ed29f3563d622271459f065ecd9ac2afebb1cf1c9ee521698e03fbecd5d3
Contents?: true
Size: 1.52 KB
Versions: 4
Compression:
Stored size: 1.52 KB
Contents
# shamelessly copied & adjusted from Apartment # @see https://github.com/influitive/apartment/blob/development/lib/apartment/migrator.rb module Penthouse module Migrator extend self # Migrate to latest version # @param tenant_identifier [String, Symbol] the identifier for the tenant to switch to # @return [void] def migrate(tenant_identifier) Penthouse.switch(tenant_identifier) do version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, version) do |migration| ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope) end end end # Migrate up/down to a specific version # @param tenant_identifier [String, Symbol] the identifier for the tenant to switch to # @param version [Integer] the version number to migrate up or down to # @return [void] def run(direction, tenant_identifier, version) Penthouse.switch(tenant_identifier) do ActiveRecord::Migrator.run(direction, ActiveRecord::Migrator.migrations_paths, version) end end # rollback latest migration `step` number of times # @param tenant_identifier [String, Symbol] the identifier for the tenant to switch to # @param step [Integer] how many migrations to rollback by # @return [void] def rollback(tenant_identifier, step = 1) Penthouse.switch(tenant_identifier) do ActiveRecord::Migrator.rollback(ActiveRecord::Migrator.migrations_paths, step) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
penthouse-0.5.0 | lib/penthouse/migrator.rb |
penthouse-0.4.2 | lib/penthouse/migrator.rb |
penthouse-0.4.1 | lib/penthouse/migrator.rb |
penthouse-0.4.0 | lib/penthouse/migrator.rb |