legion-data 1.4.16 → 1.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5bd9e4445c0af956871ee6127cae3555e357a8ec03178151b44c2479ce2e7921
4
- data.tar.gz: 95267b3b7e289cc4348b50b205464d6e777387a465c615c278e274a8c5286042
3
+ metadata.gz: 4b72221cdf5567d6602fa63754684e02cd690ece98810eddc539061b9f4ae19c
4
+ data.tar.gz: 9865f85a9281f562bc9d6160198193f1b0c7b00c8c9132dc7c72b70160dace9d
5
5
  SHA512:
6
- metadata.gz: 191e560fb2575d4e31069a3cad534fbdc7e4826aea7e3601d99583797a405c7fc6467764c166da95366492a82fa178dfd54fa0ff55b2354e2759aa42aaf12165
7
- data.tar.gz: c7ab4e6b845346d7662d23c0d993779fbbbd56dc4bff5fdbd6fd65d168d51ecb9a5249ec488299586b5d0bbe798ae4f68a40ecd75b1c41cd1196346b1886cc13
6
+ metadata.gz: '049288bc4a3b94d1430b992bb78d693517757fafadac4b65535b873eb8d3d0e3bbb4765d635388badf6df48ec302d06dfc6b04de9f54a85ec8acd805b0e90dda'
7
+ data.tar.gz: 32bb5d25decd349a5dc85c08400c3e2364fca356c62d185a103ec68e47989f0ada735f5d28f1c8405ed3e41172deb8ad590b56b4b4d391ef49b14723335a9adc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Legion::Data Changelog
2
2
 
3
+ ## [1.4.18] - 2026-03-23
4
+
5
+ ### Fixed
6
+ - Fix extension migration timing: late `register_migrations` calls now run immediately if DB is connected
7
+ - Fix cross-extension schema_migrations conflicts with per-extension migration tables
8
+
9
+ ## [1.4.17] - 2026-03-22
10
+
11
+ ### Added
12
+ - `Legion::Data::Helper` mixin module with data convenience methods for LEX extensions (data_path, data_class, models_class, data_connected?, data_connection, local_data_connected?, local_data_connection, local_data_model)
13
+
14
+ ### Fixed
15
+ - Add missing `require 'spec_helper'` in `helper_spec.rb` that caused `NameError: uninitialized constant Legion::Data::Helper`
16
+
3
17
  ## [1.4.16] - 2026-03-22
4
18
 
5
19
  ### Changed
data/CLAUDE.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Manages persistent database storage for the LegionIO framework. Supports SQLite (default), MySQL, and PostgreSQL via Sequel ORM. Provides automatic schema migrations and data models for extensions, functions, runners, nodes, tasks, settings, digital workers, task relationships, Apollo shared knowledge tables (PostgreSQL only), tenants, webhooks, audit log, and archive tables. Also provides a parallel local SQLite database (`Legion::Data::Local`) for agentic cognitive state persistence.
9
9
 
10
10
  **GitHub**: https://github.com/LegionIO/legion-data
11
- **Version**: 1.4.4
11
+ **Version**: 1.4.12
12
12
  **License**: Apache-2.0
13
13
 
14
14
  ## Supported Databases
@@ -46,7 +46,7 @@ Legion::Data (singleton module)
46
46
  │ ├── .shutdown # Close local connection
47
47
  │ └── .reset! # Clear all state (testing)
48
48
 
49
- ├── Migration # Auto-migration system (25 migrations, Sequel DSL)
49
+ ├── Migration # Auto-migration system (26 migrations, Sequel DSL)
50
50
  │ └── migrations/
51
51
  │ ├── 001_add_schema_columns
52
52
  │ ├── 002_add_nodes
@@ -182,7 +182,7 @@ Per-adapter credential defaults are defined in `Settings::CREDS`:
182
182
  | `lib/legion/data.rb` | Module entry, setup/shutdown lifecycle |
183
183
  | `lib/legion/data/connection.rb` | Sequel database connection (adapter selection) |
184
184
  | `lib/legion/data/migration.rb` | Migration runner |
185
- | `lib/legion/data/migrations/` | 25 numbered migration files (Sequel DSL) |
185
+ | `lib/legion/data/migrations/` | 26 numbered migration files (Sequel DSL) |
186
186
  | `lib/legion/data/model.rb` | Model autoloader |
187
187
  | `lib/legion/data/local.rb` | Local SQLite module for agentic cognitive state |
188
188
  | `lib/legion/data/models/` | Sequel models (Extension, Function, Runner, Node, Task, TaskLog, Setting, DigitalWorker, Relationship, ApolloEntry, ApolloRelation, ApolloExpertise, ApolloAccessLog, AuditLog, RbacRoleAssignment, RbacRunnerGrant, RbacCrossTeamGrant) |
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Persistent database storage for the [LegionIO](https://github.com/LegionIO/LegionIO) framework. Provides database connectivity via Sequel ORM, automatic schema migrations, and data models for extensions, functions, runners, nodes, tasks, settings, digital workers, task relationships, and Apollo shared knowledge tables.
4
4
 
5
- **Version**: 1.4.4
5
+ **Version**: 1.4.12
6
6
 
7
7
  ## Supported Databases
8
8
 
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Data
5
+ module Helper
6
+ def data_path
7
+ @data_path ||= "#{full_path}/data"
8
+ end
9
+
10
+ def data_class
11
+ @data_class ||= lex_class::Data
12
+ end
13
+
14
+ def models_class
15
+ @models_class ||= data_class::Model
16
+ end
17
+
18
+ def data_connected?
19
+ defined?(Legion::Settings) && Legion::Settings[:data][:connected]
20
+ end
21
+
22
+ def data_connection
23
+ Legion::Data::Connection.sequel
24
+ end
25
+
26
+ def local_data_connected?
27
+ Legion::Data::Local.connected?
28
+ end
29
+
30
+ def local_data_connection
31
+ Legion::Data::Local.connection
32
+ end
33
+
34
+ def local_data_model(table_name)
35
+ Legion::Data::Local.model(table_name)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -33,6 +33,7 @@ module Legion
33
33
  def register_migrations(name:, path:)
34
34
  @registered_migrations ||= {}
35
35
  @registered_migrations[name] = path
36
+ run_single_migration(name, path) if connected?
36
37
  end
37
38
 
38
39
  def registered_migrations
@@ -57,15 +58,21 @@ module Legion
57
58
  def run_migrations
58
59
  return unless local_settings.dig(:migrations, :auto_migrate) != false
59
60
 
60
- registered_migrations.each_value do |path|
61
- next unless File.directory?(path)
62
-
63
- ::Sequel::TimestampMigrator.new(@connection, path).run
64
- rescue StandardError => e
65
- Legion::Logging.warn "Local migration failed for #{path}: #{e.message}" if defined?(Legion::Logging)
61
+ registered_migrations.each do |name, path|
62
+ run_single_migration(name, path)
66
63
  end
67
64
  end
68
65
 
66
+ def run_single_migration(name, path)
67
+ return unless local_settings.dig(:migrations, :auto_migrate) != false
68
+ return unless File.directory?(path)
69
+
70
+ table = :"schema_migrations_#{name}"
71
+ ::Sequel::TimestampMigrator.new(@connection, path, table: table).run
72
+ rescue StandardError => e
73
+ Legion::Logging.warn "Local migration failed for #{path}: #{e.message}" if defined?(Legion::Logging)
74
+ end
75
+
69
76
  def local_settings
70
77
  return {} unless defined?(Legion::Settings)
71
78
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Data
5
- VERSION = '1.4.16'
5
+ VERSION = '1.4.18'
6
6
  end
7
7
  end
data/lib/legion/data.rb CHANGED
@@ -11,6 +11,7 @@ require_relative 'data/local'
11
11
  require_relative 'data/spool'
12
12
  require_relative 'data/partition_manager'
13
13
  require_relative 'data/archiver'
14
+ require_relative 'data/helper'
14
15
 
15
16
  module Legion
16
17
  module Data
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.16
4
+ version: 1.4.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -96,6 +96,7 @@ files:
96
96
  - lib/legion/data/encryption/sequel_plugin.rb
97
97
  - lib/legion/data/event_store.rb
98
98
  - lib/legion/data/event_store/projection.rb
99
+ - lib/legion/data/helper.rb
99
100
  - lib/legion/data/local.rb
100
101
  - lib/legion/data/migration.rb
101
102
  - lib/legion/data/migrations/001_add_schema_columns.rb