lib/legion/extensions/data/migrator.rb in legionio-0.4.3 vs lib/legion/extensions/data/migrator.rb in legionio-1.2.0

- old
+ new

@@ -2,11 +2,12 @@ module Legion module Extensions module Data class Migrator < Sequel::IntegerMigrator - def initialize(path, extension, **) + def initialize(path, extension, _lex_name, **) + Legion::Logging.fatal @extension @path = path @extension = extension super(Legion::Data::Connection.sequel, path) end @@ -17,9 +18,13 @@ 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