legion-data 1.6.15 → 1.6.16

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: a7482bef7a948d0666c146430112e789f3f47cf41c8a4955d4464ec2ed46c297
4
- data.tar.gz: 78495d83350dfd60bdac99ec0e4b03deb5d3a6b51070e158e784e0a3e9e7083a
3
+ metadata.gz: 458456d016a717f8ee9397f29f01b118ecb7e8a103142defe337788d72762176
4
+ data.tar.gz: cac5a1f8a0bb86ec3087da754d2432ae97ebdc65b003c4ee1aa5e9c9570cc03a
5
5
  SHA512:
6
- metadata.gz: 224c494f220a6d57e2ad00dae338007a7266f3126b51487bd429f709b7f6417267ee40b0d8453a6817bd32ff35bfc8ac79c072ca4f0d978c586bed35656f68f5
7
- data.tar.gz: 6550fe8cbf470a7b7ad8f5639d425e55536357a55ecc5832e5956b4bf8e32b1079cdde47367c52d45c4fa7cdf7e01604b87eed5017b8f5d8e7f00155aea71801
6
+ metadata.gz: 2303a3358441efcea756d106d92a102858eb3534109df30b294925213ae8cba7559969e7f2d01b6ec7ad5bbe1bdca9bf1c5af7d92e1d9fc647eeb8230c8c9269
7
+ data.tar.gz: e50d02ec9745f7dc178bb53ca222c104e822505190b5bacf7ed404e9a61480b4a3361817b220a399b1cd95d323503d66046050e6acabacca2fce493b842e3500
@@ -10,6 +10,40 @@ jobs:
10
10
  ci:
11
11
  uses: LegionIO/.github/.github/workflows/ci.yml@main
12
12
 
13
+ ci-postgres:
14
+ name: "RSpec (PostgreSQL)"
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-latest
17
+ services:
18
+ postgres:
19
+ image: postgres:16-alpine
20
+ env:
21
+ POSTGRES_USER: legion
22
+ POSTGRES_PASSWORD: legion
23
+ POSTGRES_DB: legionio
24
+ ports:
25
+ - 5432:5432
26
+ options: >-
27
+ --health-cmd pg_isready
28
+ --health-interval 10s
29
+ --health-timeout 5s
30
+ --health-retries 5
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: '3.4'
36
+ bundler-cache: true
37
+ - name: Run RSpec (PostgreSQL adapter)
38
+ env:
39
+ LEGION_DATA_ADAPTER: postgres
40
+ LEGION_DATA_HOST: 127.0.0.1
41
+ LEGION_DATA_PORT: 5432
42
+ LEGION_DATA_USER: legion
43
+ LEGION_DATA_PASSWORD: legion
44
+ LEGION_DATA_DATABASE: legionio
45
+ run: bundle exec rspec
46
+
13
47
  lint:
14
48
  uses: LegionIO/.github/.github/workflows/lint-patterns.yml@main
15
49
 
@@ -27,8 +61,8 @@ jobs:
27
61
  uses: LegionIO/.github/.github/workflows/stale.yml@main
28
62
 
29
63
  release:
30
- needs: [ci, lint]
64
+ needs: [ci, ci-postgres, lint]
31
65
  if: github.event_name == 'push' && github.ref == 'refs/heads/main'
32
66
  uses: LegionIO/.github/.github/workflows/release.yml@main
33
67
  secrets:
34
- rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
68
+ rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
data/.rubocop.yml CHANGED
@@ -1,26 +1,8 @@
1
- AllCops:
2
- TargetRubyVersion: 3.4
3
- NewCops: enable
4
- SuggestExtensions: false
1
+ inherit_gem:
2
+ rubocop-legion: config/core.yml
5
3
 
6
- Layout/LineLength:
7
- Max: 160
8
-
9
- Layout/SpaceAroundEqualsInParameterDefault:
10
- EnforcedStyle: space
11
-
12
- Layout/HashAlignment:
13
- EnforcedHashRocketStyle: table
14
- EnforcedColonStyle: table
15
-
16
- Metrics/MethodLength:
17
- Max: 50
18
-
19
- Metrics/ClassLength:
20
- Max: 1500
21
-
22
- Metrics/ModuleLength:
23
- Max: 1500
4
+ Metrics/ParameterLists:
5
+ Max: 8
24
6
 
25
7
  Metrics/BlockLength:
26
8
  Max: 40
@@ -28,34 +10,22 @@ Metrics/BlockLength:
28
10
  - 'spec/**/*'
29
11
  - 'lib/legion/data/migrations/**/*'
30
12
 
31
- Metrics/AbcSize:
32
- Max: 60
33
-
34
- Metrics/CyclomaticComplexity:
35
- Max: 15
36
-
37
- Metrics/PerceivedComplexity:
38
- Max: 17
39
-
40
- Style/Documentation:
13
+ Naming/VariableNumber:
41
14
  Enabled: false
42
15
 
43
- Style/SymbolArray:
44
- Enabled: true
45
-
46
- Style/FrozenStringLiteralComment:
47
- Enabled: true
48
- EnforcedStyle: always
16
+ Style/FileOpen:
17
+ Exclude:
18
+ - 'lib/legion/data/connection.rb'
49
19
 
50
- Naming/FileName:
20
+ # Pre-existing patterns — suppress until addressed in a dedicated cleanup PR
21
+ ThreadSafety/ClassInstanceVariable:
51
22
  Enabled: false
52
23
 
53
- Naming/VariableNumber:
24
+ ThreadSafety/ClassAndModuleAttributes:
54
25
  Enabled: false
55
26
 
56
- Metrics/ParameterLists:
57
- Max: 8
27
+ Legion/RescueLogging/NoCapture:
28
+ Enabled: false
58
29
 
59
- Style/FileOpen:
60
- Exclude:
61
- - 'lib/legion/data/connection.rb'
30
+ Legion/Framework/EagerSequelModel:
31
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.6.16] - 2026-03-30
6
+
7
+ ### Fixed
8
+ - Migration 019: widen `record_hash` column to size 255 via `set_column_type` (column added in migration 017)
9
+ - Migration 019: rename `prev_hash` to `previous_hash` via `rename_column` instead of adding a duplicate column
10
+ - Migration 019: decouple index creation from column existence checks so indexes are always guarded by their own `idxs.key?` check
11
+ - Migration 019: `down` no longer drops `record_hash` (owned by migration 017, not 019)
12
+ - Migration 019: replace `db.indexes` with bare `indexes()` — inside a `Sequel.migration` block `self` is the DB object, so `db` is undefined
13
+ - Updated to rubocop-legion (`inherit_gem: config/core.yml`) for shared LegionIO cop configuration
14
+
15
+ ### Added
16
+ - Migration 019 spec: 8 examples covering column presence, defaults, indexes, idempotency, and rollback
17
+
5
18
  ## [1.6.15] - 2026-03-29
6
19
 
7
20
  ### Added
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ group :test do
7
7
  gem 'rake'
8
8
  gem 'rspec'
9
9
  gem 'rspec_junit_formatter'
10
- gem 'rubocop'
10
+ gem 'rubocop-legion'
11
11
  gem 'simplecov'
12
12
  end
13
13
  gem 'mysql2', '>= 0.5.5'
@@ -5,7 +5,7 @@ module Legion
5
5
  module Extract
6
6
  module Handlers
7
7
  class Base
8
- @registry = {}
8
+ @registry = {}.freeze
9
9
 
10
10
  class << self
11
11
  attr_reader :registry
@@ -22,7 +22,7 @@ module Legion
22
22
  end
23
23
 
24
24
  def register(handler_class)
25
- @registry[handler_class.type] = handler_class
25
+ @registry = @registry.merge(handler_class.type => handler_class).freeze
26
26
  end
27
27
 
28
28
  def for_type(type)
@@ -16,11 +16,11 @@ module Legion
16
16
  workbook = ::RubyXL::Parser.parse(source)
17
17
  sheets = []
18
18
  workbook.worksheets.each do |sheet|
19
- rows = sheet.each.map do |row|
19
+ rows = sheet.each.filter_map do |row|
20
20
  next unless row
21
21
 
22
22
  row.cells.map { |c| c&.value.to_s }.join(', ')
23
- end.compact
23
+ end
24
24
  sheets << "Sheet: #{sheet.sheet_name}\n#{rows.join("\n")}" unless rows.empty?
25
25
  end
26
26
  text = sheets.join("\n\n")
@@ -41,7 +41,8 @@ module Legion
41
41
  end
42
42
 
43
43
  def register_handler(type, klass)
44
- Handlers::Base.registry[type.to_sym] = klass
44
+ Handlers::Base.instance_variable_set(:@registry,
45
+ Handlers::Base.registry.merge(type.to_sym => klass).freeze)
45
46
  end
46
47
 
47
48
  private
@@ -4,15 +4,32 @@ Sequel.migration do
4
4
  up do
5
5
  return unless table_exists?(:audit_log)
6
6
 
7
- cols = schema(:audit_log).map(&:first)
7
+ cols = schema(:audit_log).map(&:first)
8
+ idxs = indexes(:audit_log)
8
9
 
9
- alter_table(:audit_log) do
10
- add_column :record_hash, String, size: 64 unless cols.include?(:record_hash)
11
- add_column :previous_hash, String, size: 64 unless cols.include?(:previous_hash)
12
- add_column :retention_tier, String, size: 10, default: 'hot' unless cols.include?(:retention_tier)
13
- add_index :record_hash, unique: true, if_not_exists: true
14
- add_index :retention_tier, if_not_exists: true
10
+ # record_hash exists from migration 017 at size 64; widen to 255 if needed.
11
+ if cols.include?(:record_hash)
12
+ set_column_type :audit_log, :record_hash, String, size: 255
13
+ else
14
+ alter_table(:audit_log) { add_column :record_hash, String, size: 255 }
15
15
  end
16
+
17
+ add_index :audit_log, :record_hash unless idxs.key?(:audit_log_record_hash_index)
18
+
19
+ # Rename prev_hash (introduced in migration 017) to previous_hash for clarity,
20
+ # then widen it to 255 to match record_hash.
21
+ if cols.include?(:prev_hash) && !cols.include?(:previous_hash)
22
+ rename_column :audit_log, :prev_hash, :previous_hash
23
+ set_column_type :audit_log, :previous_hash, String, size: 255
24
+ elsif !cols.include?(:previous_hash)
25
+ alter_table(:audit_log) { add_column :previous_hash, String, size: 255 }
26
+ elsif cols.include?(:previous_hash)
27
+ set_column_type :audit_log, :previous_hash, String, size: 255
28
+ end
29
+
30
+ alter_table(:audit_log) { add_column :retention_tier, String, size: 10, default: 'hot' } unless cols.include?(:retention_tier)
31
+
32
+ add_index :audit_log, :retention_tier unless idxs.key?(:audit_log_retention_tier_index)
16
33
  end
17
34
 
18
35
  down do
@@ -20,10 +37,22 @@ Sequel.migration do
20
37
 
21
38
  cols = schema(:audit_log).map(&:first)
22
39
 
23
- alter_table(:audit_log) do
24
- drop_column :record_hash if cols.include?(:record_hash)
25
- drop_column :previous_hash if cols.include?(:previous_hash)
26
- drop_column :retention_tier if cols.include?(:retention_tier)
40
+ drop_index :audit_log, :record_hash, if_exists: true
41
+
42
+ # Restore record_hash to its original size (64 from migration 017).
43
+ set_column_type :audit_log, :record_hash, String, size: 64 if cols.include?(:record_hash)
44
+
45
+ # Rename previous_hash back to prev_hash (reverse of the up rename) and restore size to 64.
46
+ if cols.include?(:previous_hash) && !cols.include?(:prev_hash)
47
+ rename_column :audit_log, :previous_hash, :prev_hash
48
+ set_column_type :audit_log, :prev_hash, String, size: 64
49
+ elsif cols.include?(:previous_hash)
50
+ alter_table(:audit_log) { drop_column :previous_hash }
51
+ end
52
+
53
+ if cols.include?(:retention_tier)
54
+ drop_index :audit_log, :retention_tier, if_exists: true
55
+ alter_table(:audit_log) { drop_column :retention_tier }
27
56
  end
28
57
  end
29
58
  end
@@ -34,4 +34,10 @@ Sequel.migration do
34
34
  DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
35
35
  end
36
36
  end
37
+
38
+ down do
39
+ drop_table?(:webhook_dead_letters)
40
+ drop_table?(:webhook_deliveries)
41
+ drop_table?(:webhooks)
42
+ end
37
43
  end
@@ -128,7 +128,7 @@ module Legion
128
128
  end
129
129
 
130
130
  begin
131
- Legion::Settings.merge_settings('data', Legion::Data::Settings.default) if Legion.const_defined?('Settings')
131
+ Legion::Settings.merge_settings('data', Legion::Data::Settings.default) if Legion.const_defined?('Settings', false)
132
132
  rescue StandardError => e
133
133
  Legion::Logging.fatal(e.message) if Legion::Logging.method_defined?(:fatal)
134
134
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Data
5
- VERSION = '1.6.15'
5
+ VERSION = '1.6.16'
6
6
  end
7
7
  end
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.6.15
4
+ version: 1.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity