chrono_forge 0.4.0 → 0.5.0

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: cbb73c055f7439bc5e787d68a6d46bbb687143a85a3d57dcade8910aaae93916
4
- data.tar.gz: 7b40ca8cc17398e695434c3e1ab61c7cfa12dfeb0ac941dd257daa18b633dbed
3
+ metadata.gz: 9da8de8f1664f4234f1a87cd69b1f32a2ccf96ce8501be4ef0e5f9585ceb7417
4
+ data.tar.gz: afe72783ec386e3aa9b5f3b79e468c83eb5bc2dd144634f797a882760a4f6eac
5
5
  SHA512:
6
- metadata.gz: 0a6db6125a515d250b19ba3bd59db16056973a0d23df3acf76b5341a7990f962694dec5b9732302a0a850844c62a97847640c289bdebcee0f684f691e214049f
7
- data.tar.gz: 852d241932f2cfc28e48bb6713f79d0c5086dfe8f92b92828f6ef03943250c548cef331de43d208d756c209ea99633f3ab99229391dd8c207fed47b6e4bf31f4
6
+ metadata.gz: b24ef7eb8e7b2c2a07a368efde14bdfb54c4e846b1da9681013d23f3159693497f42d373aea3e85b6db340e737a03d907e8d745e4a3424843ecad7c8daa6e4b6
7
+ data.tar.gz: 742063a706c815f8f9a568fe2ee40f774d1510c3d46f2cdc90dd5f83304b8feeeb937c363d9f07ae19f2d8fbb75dcc33db57e9eecedc714f0a9f6dba19113da0
@@ -23,7 +23,7 @@
23
23
  #
24
24
 
25
25
  module ChronoForge
26
- class ErrorLog < ActiveRecord::Base
26
+ class ErrorLog < ApplicationRecord()
27
27
  self.table_name = "chrono_forge_error_logs"
28
28
 
29
29
  belongs_to :workflow
@@ -28,7 +28,7 @@
28
28
  # workflow_id (workflow_id => chrono_forge_workflows.id)
29
29
  #
30
30
  module ChronoForge
31
- class ExecutionLog < ActiveRecord::Base
31
+ class ExecutionLog < ApplicationRecord()
32
32
  self.table_name = "chrono_forge_execution_logs"
33
33
 
34
34
  belongs_to :workflow
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChronoForge
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -22,7 +22,7 @@
22
22
  # index_chrono_forge_workflows_on_key (key) UNIQUE
23
23
  #
24
24
  module ChronoForge
25
- class Workflow < ActiveRecord::Base
25
+ class Workflow < ApplicationRecord()
26
26
  self.table_name = "chrono_forge_workflows"
27
27
 
28
28
  has_many :execution_logs, -> { order(id: :asc) }, dependent: :destroy
data/lib/chrono_forge.rb CHANGED
@@ -11,4 +11,6 @@ module ChronoForge
11
11
  end
12
12
 
13
13
  class Error < StandardError; end
14
+
15
+ def self.ApplicationRecord() = defined?(::ApplicationRecord) ? ::ApplicationRecord : ActiveRecord::Base
14
16
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class InstallChronoForge < ActiveRecord::Migration[7.1]
4
4
  def change
5
- create_table :chrono_forge_workflows do |t|
5
+ create_table :chrono_forge_workflows, id: primary_key_type do |t|
6
6
  t.string :key, null: false, index: true
7
7
  t.string :job_class, null: false
8
8
 
@@ -27,18 +27,23 @@ class InstallChronoForge < ActiveRecord::Migration[7.1]
27
27
  t.index %i[job_class key], unique: true
28
28
  end
29
29
 
30
- create_table :chrono_forge_execution_logs do |t|
31
- t.references :workflow, null: false, foreign_key: {to_table: :chrono_forge_workflows}
30
+ create_table :chrono_forge_execution_logs, id: primary_key_type do |t|
31
+ t.references :workflow, null: false,
32
+ foreign_key: {to_table: :chrono_forge_workflows},
33
+ type: reference_type
34
+
32
35
  t.string :step_name, null: false
33
36
  t.integer :attempts, null: false, default: 0
34
37
  t.datetime :started_at
35
38
  t.datetime :last_executed_at
36
39
  t.datetime :completed_at
40
+
37
41
  if t.respond_to?(:jsonb)
38
42
  t.jsonb :metadata
39
43
  else
40
44
  t.json :metadata
41
45
  end
46
+
42
47
  t.integer :state, null: false, default: 0
43
48
  t.string :error_class
44
49
  t.text :error_message
@@ -47,11 +52,15 @@ class InstallChronoForge < ActiveRecord::Migration[7.1]
47
52
  t.index %i[workflow_id step_name], unique: true
48
53
  end
49
54
 
50
- create_table :chrono_forge_error_logs do |t|
51
- t.references :workflow, null: false, foreign_key: {to_table: :chrono_forge_workflows}
55
+ create_table :chrono_forge_error_logs, id: primary_key_type do |t|
56
+ t.references :workflow, null: false,
57
+ foreign_key: {to_table: :chrono_forge_workflows},
58
+ type: reference_type
59
+
52
60
  t.string :error_class
53
61
  t.text :error_message
54
62
  t.text :backtrace
63
+
55
64
  if t.respond_to?(:jsonb)
56
65
  t.jsonb :context
57
66
  else
@@ -61,4 +70,35 @@ class InstallChronoForge < ActiveRecord::Migration[7.1]
61
70
  t.timestamps
62
71
  end
63
72
  end
64
- end
73
+
74
+ private
75
+
76
+ def primary_key_type
77
+ # Check if the application is configured to use UUIDs
78
+ if ActiveRecord.respond_to?(:default_id) && ActiveRecord.default_id.respond_to?(:to_s) &&
79
+ ActiveRecord.default_id.to_s.include?('uuid')
80
+ return :uuid
81
+ end
82
+
83
+ # Rails 6+ configuration style
84
+ if ActiveRecord.respond_to?(:primary_key_type) &&
85
+ ActiveRecord.primary_key_type.to_s == 'uuid'
86
+ return :uuid
87
+ end
88
+
89
+ # Check application config
90
+ app_config = Rails.application.config.generators
91
+ if app_config.options.key?(:active_record) &&
92
+ app_config.options[:active_record].key?(:primary_key_type) &&
93
+ app_config.options[:active_record][:primary_key_type].to_s == 'uuid'
94
+ return :uuid
95
+ end
96
+
97
+ # Default to traditional integer keys
98
+ return :bigint
99
+ end
100
+
101
+ def reference_type
102
+ primary_key_type == :uuid ? :uuid : nil
103
+ end
104
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrono_forge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-30 00:00:00.000000000 Z
11
+ date: 2025-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord