Sha256: feab6096c62fdf007a0d23456129cc48e695c46fee10fbbd91c8824d8f5d4eea

Contents?: true

Size: 851 Bytes

Versions: 7

Compression:

Stored size: 851 Bytes

Contents

class MigrationHelper
  class << self
    def migrate(path)
      if ActiveRecord.version >= Gem::Version.new('6.0.0')
        ActiveRecord::MigrationContext.new(path, schema_migration).migrate
      elsif ActiveRecord.version >= Gem::Version.new('5.2.0')
        ActiveRecord::MigrationContext.new(path).migrate
      else
        ActiveRecord::Migrator.migrate(path)
      end
    end

    def rollback(path)
      if ActiveRecord.version >= Gem::Version.new('6.0.0')
        ActiveRecord::MigrationContext.new(path, schema_migration).rollback
      elsif ActiveRecord.version >= Gem::Version.new('5.2.0')
        ActiveRecord::MigrationContext.new(path).rollback
      else
        ActiveRecord::Migrator.rollback(path)
      end
    end

    private

    def schema_migration
      ActiveRecord::Base.connection.schema_migration
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sorcery-0.17.0 spec/support/migration_helper.rb
sorcery-0.16.5 spec/support/migration_helper.rb
sorcery-0.16.4 spec/support/migration_helper.rb
sorcery-0.16.3 spec/support/migration_helper.rb
sorcery-0.16.2 spec/support/migration_helper.rb
sorcery-0.16.1 spec/support/migration_helper.rb
sorcery-0.16.0 spec/support/migration_helper.rb