lib/legion/data/migration.rb in legion-data-0.1.1 vs lib/legion/data/migration.rb in legion-data-0.2.0

- old
+ new

@@ -1,28 +1,15 @@ require 'sequel/extensions/migration' module Legion module Data - class Migration - def initialize(connection, options = {}) - options.merge!(default_options) { |_key, v1, _v2| v1 } - migrate(options[:migration_path], connection) if options[:auto_migrate] - end - - def default_options - { auto_migrate: true, migration_path: __dir__ + '/migrations' } - end - - def migrate(path, connection) - Legion::Logging.debug("Running Legion::Data.migrate with path: #{path}") - Sequel::Migrator.run(connection, path) - Legion::Logging.info('Legion::Data finished migrations') - rescue Sequel::Migrator::Error => e - Legion::Logging.error(e.message) - raise e - rescue StandardError => e - Legion::Logging.error(e.message) - raise e unless Legion::Settings[:data][:migrations][:continue_on_fail] + module Migration + class << self + def migrate(connection = Legion::Data.connection, path = __dir__ + '/migrations') + Legion::Settings[:data][:migrations][:version] = Sequel::Migrator.run(connection, path) + Legion::Logging.info 'Legion::Data::Migration ran successfully to version ' + Legion::Settings[:data][:migrations][:version].to_s # rubocop:disable Layout/LineLength + Legion::Settings[:data][:migrations][:ran] = true + end end end end end