lib/hanami/model/migrator/adapter.rb in hanami-model-1.3.2 vs lib/hanami/model/migrator/adapter.rb in hanami-model-1.3.3

- old
+ new

@@ -1,9 +1,11 @@ -require 'uri' -require 'shellwords' -require 'open3' +# frozen_string_literal: true +require "uri" +require "shellwords" +require "open3" + module Hanami module Model class Migrator # Migrator base adapter # @@ -24,22 +26,22 @@ # Loads and returns a specific adapter for the given connection. # # @since 0.4.0 # @api private - def self.for(configuration) # rubocop:disable Metrics/MethodLength + def self.for(configuration) connection = Connection.new(configuration) case connection.database_type when :sqlite - require 'hanami/model/migrator/sqlite_adapter' + require "hanami/model/migrator/sqlite_adapter" SQLiteAdapter when :postgres - require 'hanami/model/migrator/postgres_adapter' + require "hanami/model/migrator/postgres_adapter" PostgresAdapter when :mysql - require 'hanami/model/migrator/mysql_adapter' + require "hanami/model/migrator/mysql_adapter" MySQLAdapter else self end.new(connection) end @@ -78,22 +80,22 @@ # @api private def migrate(migrations, version) version = Integer(version) unless version.nil? Sequel::Migrator.run(connection.raw, migrations, target: version, allow_missing_migration_files: true) - rescue Sequel::Migrator::Error => e - raise MigrationError.new(e.message) + rescue Sequel::Migrator::Error => exception + raise MigrationError.new(exception.message) end # @since 1.1.0 # @api private def rollback(migrations, steps) table = migrations_table_dataset version = version_to_rollback(table, steps) Sequel::Migrator.run(connection.raw, migrations, target: version, allow_missing_migration_files: true) - rescue Sequel::Migrator::Error => e - raise MigrationError.new(e.message) + rescue Sequel::Migrator::Error => exception + raise MigrationError.new(exception.message) end # Load database schema. # It must be implemented by subclasses. #