Sha256: 35b1478cc9d2c38ce18fc6c95946ae58c9a1bb784c04f40afedca820037f74d7

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

require 'sequel/extensions/migration'

module Legion
  module Extensions
    module Data
      class Migrator < Sequel::IntegerMigrator
        def initialize(path, extension, _lex_name, **)
          Legion::Logging.fatal @extension
          @path = path
          @extension = extension
          super(Legion::Data::Connection.sequel, path)
        end

        def default_schema_column
          :schema_version
        end

        def default_schema_table
          :extensions
        end

        def schema_dataset
          dataset = Legion::Data::Connection.sequel.from(default_schema_table).where(namespace: @extension)
          return dataset unless dataset.count.positive?

          Legion::Logging.unknown Legion::Data::Model::Extension.insert(active: 1, namespace: @extension, extension: lex_name)
          Legion::Data::Connection.sequel.from(default_schema_table).where(namespace: @extension)
        end
        alias ds schema_dataset
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legionio-1.2.0 lib/legion/extensions/data/migrator.rb