dynflow 1.6.3 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynflow/execution_plan/hooks.rb +1 -1
- data/lib/dynflow/persistence_adapters/sequel_migrations/022_store_flows_as_msgpack.rb +5 -72
- data/lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb +18 -0
- data/lib/dynflow/persistence_adapters/sequel_migrations/msgpack_migration_helper.rb +85 -0
- data/lib/dynflow/rails/configuration.rb +1 -1
- data/lib/dynflow/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '068120950f509e0e118319244c51c2cc1c593b95c808e550636515dace4a984b'
|
4
|
+
data.tar.gz: 0a7b42cc5c57ba401c983582cebd1b428c6a9876d6187f3e511bcf5b82f33d4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa1c11576f57765c44d2efb27d80237e07e07733da768e79d2622cce9e5cdea295ae18894601905a431632c3a261668bb65a851f340baec681bbabec3e2d7dc1
|
7
|
+
data.tar.gz: 51d939e678a1e90880767b772d10f25fb69870da708180d9c07a42e46840428a929620206a5a05f1014c17bc7e5d7f71d8eff92e0c99654e1ec31a9ab73d2889
|
@@ -1,65 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'msgpack'
|
5
|
-
|
6
|
-
def table_pkeys(table)
|
7
|
-
case table
|
8
|
-
when :dynflow_execution_plans
|
9
|
-
[:uuid]
|
10
|
-
when :dynflow_actions, :dynflow_steps
|
11
|
-
[:execution_plan_uuid, :id]
|
12
|
-
when :dynflow_coordinator_records
|
13
|
-
[:id, :class]
|
14
|
-
when :dynflow_delayed_plans
|
15
|
-
[:execution_plan_uuid]
|
16
|
-
when :dynflow_envelopes
|
17
|
-
[:id]
|
18
|
-
when :dynflow_output_chunks
|
19
|
-
[:chunk]
|
20
|
-
else
|
21
|
-
raise "Unknown table '#{table}'"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def conditions_for_row(table, row)
|
26
|
-
row.slice(*table_pkeys(table))
|
27
|
-
end
|
28
|
-
|
29
|
-
def migrate_table(table, from_names, to_names, new_type)
|
30
|
-
alter_table(table) do
|
31
|
-
to_names.each do |new|
|
32
|
-
add_column new, new_type
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
relevant_columns = table_pkeys(table) | from_names
|
37
|
-
|
38
|
-
from(table).select(*relevant_columns).each do |row|
|
39
|
-
update = from_names.zip(to_names).reduce({}) do |acc, (from, to)|
|
40
|
-
row[from].nil? ? acc : acc.merge(to => yield(row[from]))
|
41
|
-
end
|
42
|
-
next if update.empty?
|
43
|
-
from(table).where(conditions_for_row(table, row)).update(update)
|
44
|
-
end
|
45
|
-
|
46
|
-
from_names.zip(to_names).each do |old, new|
|
47
|
-
alter_table(table) do
|
48
|
-
drop_column old
|
49
|
-
end
|
50
|
-
|
51
|
-
if database_type == :mysql
|
52
|
-
type = new_type == File ? 'blob' : 'mediumtext'
|
53
|
-
run "ALTER TABLE #{table} CHANGE COLUMN `#{new}` `#{old}` #{type};"
|
54
|
-
else
|
55
|
-
rename_column table, new, old
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
3
|
+
require_relative 'msgpack_migration_helper'
|
59
4
|
|
60
5
|
Sequel.migration do
|
61
|
-
|
62
|
-
TABLES = {
|
6
|
+
helper = MsgpackMigrationHelper.new({
|
63
7
|
:dynflow_actions => [:data, :input, :output],
|
64
8
|
:dynflow_coordinator_records => [:data],
|
65
9
|
:dynflow_delayed_plans => [:serialized_args, :data],
|
@@ -67,24 +11,13 @@ Sequel.migration do
|
|
67
11
|
:dynflow_execution_plans => [:run_flow, :finalize_flow, :execution_history, :step_ids],
|
68
12
|
:dynflow_steps => [:error, :children],
|
69
13
|
:dynflow_output_chunks => [:chunk]
|
70
|
-
}
|
14
|
+
})
|
71
15
|
|
72
16
|
up do
|
73
|
-
|
74
|
-
new_columns = columns.map { |c| "#{c}_blob" }
|
75
|
-
|
76
|
-
migrate_table table, columns, new_columns, File do |data|
|
77
|
-
::Sequel.blob(MessagePack.pack(JSON.parse(data)))
|
78
|
-
end
|
79
|
-
end
|
17
|
+
helper.up(self)
|
80
18
|
end
|
81
19
|
|
82
20
|
down do
|
83
|
-
|
84
|
-
new_columns = columns.map { |c| c + '_text' }
|
85
|
-
migrate_table table, columns, new_columns, String do |data|
|
86
|
-
JSON.dump(MessagePack.unpack(data))
|
87
|
-
end
|
88
|
-
end
|
21
|
+
helper.down(self)
|
89
22
|
end
|
90
23
|
end
|
data/lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'msgpack_migration_helper'
|
4
|
+
|
5
|
+
Sequel.migration do
|
6
|
+
helper = MsgpackMigrationHelper.new({
|
7
|
+
:dynflow_execution_plans => [:data],
|
8
|
+
:dynflow_steps => [:data]
|
9
|
+
})
|
10
|
+
|
11
|
+
up do
|
12
|
+
helper.up(self)
|
13
|
+
end
|
14
|
+
|
15
|
+
down do
|
16
|
+
helper.down(self)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'msgpack'
|
5
|
+
|
6
|
+
class MsgpackMigrationHelper
|
7
|
+
def initialize(tables)
|
8
|
+
@tables = tables
|
9
|
+
end
|
10
|
+
|
11
|
+
def up(migration)
|
12
|
+
@tables.each do |table, columns|
|
13
|
+
new_columns = columns.map { |c| "#{c}_blob" }
|
14
|
+
|
15
|
+
migrate_table migration, table, columns, new_columns, File do |data|
|
16
|
+
::Sequel.blob(MessagePack.pack(JSON.parse(data)))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def down(migration)
|
22
|
+
@tables.each do |table, columns|
|
23
|
+
new_columns = columns.map { |c| c + '_text' }
|
24
|
+
migrate_table migration, table, columns, new_columns, String do |data|
|
25
|
+
JSON.dump(MessagePack.unpack(data))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def migrate_table(migration, table, from_names, to_names, new_type)
|
33
|
+
migration.alter_table(table) do
|
34
|
+
to_names.each do |new|
|
35
|
+
add_column new, new_type
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
relevant_columns = table_pkeys(table) | from_names
|
40
|
+
|
41
|
+
migration.from(table).select(*relevant_columns).each do |row|
|
42
|
+
update = from_names.zip(to_names).reduce({}) do |acc, (from, to)|
|
43
|
+
row[from].nil? ? acc : acc.merge(to => yield(row[from]))
|
44
|
+
end
|
45
|
+
next if update.empty?
|
46
|
+
migration.from(table).where(conditions_for_row(table, row)).update(update)
|
47
|
+
end
|
48
|
+
|
49
|
+
from_names.zip(to_names).each do |old, new|
|
50
|
+
migration.alter_table(table) do
|
51
|
+
drop_column old
|
52
|
+
end
|
53
|
+
|
54
|
+
if migration.database_type == :mysql
|
55
|
+
type = new_type == File ? 'blob' : 'mediumtext'
|
56
|
+
run "ALTER TABLE #{table} CHANGE COLUMN `#{new}` `#{old}` #{type};"
|
57
|
+
else
|
58
|
+
migration.rename_column table, new, old
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def conditions_for_row(table, row)
|
64
|
+
row.slice(*table_pkeys(table))
|
65
|
+
end
|
66
|
+
|
67
|
+
def table_pkeys(table)
|
68
|
+
case table
|
69
|
+
when :dynflow_execution_plans
|
70
|
+
[:uuid]
|
71
|
+
when :dynflow_actions, :dynflow_steps
|
72
|
+
[:execution_plan_uuid, :id]
|
73
|
+
when :dynflow_coordinator_records
|
74
|
+
[:id, :class]
|
75
|
+
when :dynflow_delayed_plans
|
76
|
+
[:execution_plan_uuid]
|
77
|
+
when :dynflow_envelopes
|
78
|
+
[:id]
|
79
|
+
when :dynflow_output_chunks
|
80
|
+
[:id]
|
81
|
+
else
|
82
|
+
raise "Unknown table '#{table}'"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -158,7 +158,7 @@ module Dynflow
|
|
158
158
|
protected
|
159
159
|
|
160
160
|
def default_sequel_adapter_options(world)
|
161
|
-
db_config = ::
|
161
|
+
db_config = ::Rails.application.config.database_configuration[::Rails.env].dup
|
162
162
|
db_config['adapter'] = db_config['adapter'].gsub(/_?makara_?/, '')
|
163
163
|
db_config['adapter'] = 'postgres' if db_config['adapter'] == 'postgresql'
|
164
164
|
db_config['max_connections'] = calculate_db_pool_size(world) if increase_db_pool_size?
|
data/lib/dynflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Necas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -547,6 +547,8 @@ files:
|
|
547
547
|
- lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb
|
548
548
|
- lib/dynflow/persistence_adapters/sequel_migrations/022_store_flows_as_msgpack.rb
|
549
549
|
- lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb
|
550
|
+
- lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb
|
551
|
+
- lib/dynflow/persistence_adapters/sequel_migrations/msgpack_migration_helper.rb
|
550
552
|
- lib/dynflow/rails.rb
|
551
553
|
- lib/dynflow/rails/configuration.rb
|
552
554
|
- lib/dynflow/rails/daemon.rb
|