iron_trail 0.3.0.pre.alpha2 → 0.3.0.pre.alpha3
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 +4 -4
- data/lib/iron_trail/change_model_concern.rb +15 -11
- data/lib/iron_trail/version.rb +1 -1
- data/lib/tasks/tracking.rake +40 -29
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 25117e0591f067570aa8feed5b58cde1c01c09a0fdb386b48fe80e9349684ac4
|
|
4
|
+
data.tar.gz: e73f15bcc8bb2c2e26e6a1f9de39ecf6517e1f60489d9a795df863c0e082c207
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87ae15bd0c12904c32d7bc10d4d89eb8a50e719a0ca3eb518bebf42eef5383c860eb165251bb8406a3ae63497541e3cdbf676066f1e3fa354af7bb07d28b15a0
|
|
7
|
+
data.tar.gz: 975ba22ccae12a3d90f9b7fbb35cc837b1c2d93c7fbbb1abe271724f62480450b72c8999fcfcc640079c7646e26539967cee504674ec8caba370ec66e65caa09
|
|
@@ -66,7 +66,9 @@ module IronTrail
|
|
|
66
66
|
# This works by inspecting whether there are any keys in the rec_delta column
|
|
67
67
|
# other than the columns specified in the `columns` parameter.
|
|
68
68
|
def with_delta_other_than(*columns)
|
|
69
|
-
quoted_columns =
|
|
69
|
+
quoted_columns = with_connection do |conn|
|
|
70
|
+
columns.map { |col_name| conn.quote(col_name) }
|
|
71
|
+
end
|
|
70
72
|
exclude_array = "ARRAY[#{quoted_columns.join(', ')}]::text[]"
|
|
71
73
|
|
|
72
74
|
sql = "rec_delta IS NULL OR (rec_delta - #{exclude_array}) <> '{}'::jsonb"
|
|
@@ -79,17 +81,19 @@ module IronTrail
|
|
|
79
81
|
ary_index = Integer(ary_index)
|
|
80
82
|
scope = all
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
::Arel::Nodes::
|
|
89
|
-
|
|
84
|
+
with_connection do |conn|
|
|
85
|
+
args.each do |col_name, value|
|
|
86
|
+
col_delta = "rec_delta->#{conn.quote(col_name)}"
|
|
87
|
+
node = if value == nil
|
|
88
|
+
::Arel::Nodes::SqlLiteral.new("#{col_delta}->#{ary_index} = 'null'::jsonb")
|
|
89
|
+
else
|
|
90
|
+
::Arel::Nodes::SqlLiteral.new("#{col_delta}->>#{ary_index}").eq(
|
|
91
|
+
::Arel::Nodes::BindParam.new(value.to_s)
|
|
92
|
+
)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
scope.where!(node)
|
|
90
96
|
end
|
|
91
|
-
|
|
92
|
-
scope.where!(node)
|
|
93
97
|
end
|
|
94
98
|
|
|
95
99
|
scope
|
data/lib/iron_trail/version.rb
CHANGED
data/lib/tasks/tracking.rake
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module IronTrail::RakeHelper
|
|
4
4
|
class << self
|
|
5
|
-
def db_functions
|
|
6
|
-
IronTrail::DbFunctions.new(
|
|
5
|
+
def db_functions(connection)
|
|
6
|
+
IronTrail::DbFunctions.new(connection)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def abort_when_unsafe!
|
|
@@ -22,28 +22,33 @@ namespace :iron_trail do
|
|
|
22
22
|
namespace :tracking do
|
|
23
23
|
desc 'Enables tracking for all missing tables.'
|
|
24
24
|
task enable: :environment do
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
ActiveRecord::Base.with_connection do |conn|
|
|
26
|
+
db_functions = IronTrail::RakeHelper.db_functions(conn)
|
|
27
|
+
tables = db_functions.collect_tables_tracking_status[:missing]
|
|
28
|
+
|
|
29
|
+
if tables.empty?
|
|
30
|
+
puts "All tables are being tracked already (no missing tables found)."
|
|
31
|
+
puts "If you think this is wrong, check your ignored_tables list."
|
|
32
|
+
else
|
|
33
|
+
puts "Will start tracking #{tables.length} tables."
|
|
34
|
+
tables.each do |table_name|
|
|
35
|
+
db_functions.enable_tracking_for_table(table_name)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
35
38
|
end
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
desc 'Disabled tracking for any ignored table that might still have the trigger enabled.'
|
|
39
42
|
task disable_on_ignored: :environment do
|
|
40
|
-
|
|
43
|
+
ActiveRecord::Base.with_connection do |conn|
|
|
44
|
+
affected_tables = IronTrail::RakeHelper.db_functions(conn).disable_for_all_ignored_tables
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
unless affected_tables.empty?
|
|
47
|
+
puts "Removed tracking from #{affected_tables.length} tables:"
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
affected_tables.each do |table_name|
|
|
50
|
+
puts "\t#{table_name}"
|
|
51
|
+
end
|
|
47
52
|
end
|
|
48
53
|
end
|
|
49
54
|
end
|
|
@@ -52,24 +57,30 @@ namespace :iron_trail do
|
|
|
52
57
|
task disable: :environment do
|
|
53
58
|
IronTrail::RakeHelper.abort_when_unsafe!
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
tables.each do |table_name|
|
|
58
|
-
IronTrail::RakeHelper.db_functions.disable_tracking_for_table(table_name)
|
|
59
|
-
end
|
|
60
|
+
ActiveRecord::Base.with_connection do |conn|
|
|
61
|
+
db_functions = IronTrail::RakeHelper.db_functions(conn)
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
tables = db_functions.collect_tables_tracking_status[:tracked]
|
|
64
|
+
puts "Will stop tracking #{tables.length} tables."
|
|
65
|
+
tables.each do |table_name|
|
|
66
|
+
db_functions.disable_tracking_for_table(table_name)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
tables = db_functions.collect_tables_tracking_status[:tracked]
|
|
70
|
+
if tables.length > 0
|
|
71
|
+
puts "WARNING: Something went wrong. There are still #{tables.length}" + \
|
|
72
|
+
" tables being tracked."
|
|
73
|
+
else
|
|
74
|
+
puts "Done!"
|
|
75
|
+
end
|
|
67
76
|
end
|
|
68
77
|
end
|
|
69
78
|
|
|
70
79
|
desc 'Shows which tables are tracking, missing and ignored.'
|
|
71
80
|
task status: :environment do
|
|
72
|
-
status =
|
|
81
|
+
status = ActiveRecord::Base.with_connection do |conn|
|
|
82
|
+
IronTrail::RakeHelper.db_functions(conn).collect_tables_tracking_status
|
|
83
|
+
end
|
|
73
84
|
ignored = (IronTrail.config.ignored_tables || [])
|
|
74
85
|
|
|
75
86
|
# We likely want to keep this structure of text untouched as someone
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iron_trail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.0.pre.
|
|
4
|
+
version: 0.3.0.pre.alpha3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- André Diego Piske
|
|
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
159
159
|
requirements:
|
|
160
160
|
- - ">="
|
|
161
161
|
- !ruby/object:Gem::Version
|
|
162
|
-
version: 3.
|
|
162
|
+
version: 3.3.0
|
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
requirements:
|
|
165
165
|
- - ">="
|