Sha256: 9308e91069b1ebb4126cd96815f43f536a9ec29674425ec50f455a7698d96baa
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 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 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 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 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
penthouse-0.3.0 | lib/penthouse/migrator.rb |
penthouse-0.2.0 | lib/penthouse/migrator.rb |