active_record-log_deleted 0.1.0 → 0.3.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: bffe9549ed5ab620b57a5a098fa369263c52236749b186671c30c1afd9a1ac1e
4
- data.tar.gz: 7dcefc7b5d7d93148882267ec67a7ca276856743da9a5b4b0ebd519d6730b3f2
3
+ metadata.gz: 4d3963d533092074a82f0c722825e1c662a6f2a67d3e75b62aca7b4533788497
4
+ data.tar.gz: 9c34203c31d671687ad0c960540f7df3717324d8b77eb8fb9dbcfba2284df2fe
5
5
  SHA512:
6
- metadata.gz: 52ae0e41b2752475b49b64b8cd4b8c2748ce45638204a4f35faeeb70ed8be7c405999f75987683d007f929d376902afca1dae866e00d1b2de9dd492a5b7cdd55
7
- data.tar.gz: 51b5e460988b8dedbb553e484cf55c3056f220e28320e8a223b9846e71c4fdbd31ab5aa0bebcb21511855d5c33d32fd80e73deea1b177d2ab6485abd6c24b874
6
+ metadata.gz: c61548f52359bd927ed2e7321b245f17a350a2720c9a586b00743cad3acf6a812a95d8dc2f20a5732d8967f772ca1d3ce62325a479ca4dfa79b295e628def8b1
7
+ data.tar.gz: fed8b70ab8963a72a648f8e80f08e52b4d06458caf2699c2e65904de72bea9f38af090ac72b12d246d9d2c25d4d6841df257b2572cb4b3504d18c5b133d01676
data/Gemfile.lock CHANGED
@@ -1,98 +1,99 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record-log_deleted (0.1.0)
5
- activerecord (>= 5.2, < 7.0)
4
+ active_record-log_deleted (0.3.0)
5
+ activerecord (>= 5.2, < 8.0)
6
6
  pg
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.0.3.1)
12
- actionview (= 6.0.3.1)
13
- activesupport (= 6.0.3.1)
14
- rack (~> 2.0, >= 2.0.8)
11
+ actionpack (7.0.0)
12
+ actionview (= 7.0.0)
13
+ activesupport (= 7.0.0)
14
+ rack (~> 2.0, >= 2.2.0)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.0.3.1)
19
- activesupport (= 6.0.3.1)
18
+ actionview (7.0.0)
19
+ activesupport (= 7.0.0)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activemodel (6.0.3.1)
25
- activesupport (= 6.0.3.1)
26
- activerecord (6.0.3.1)
27
- activemodel (= 6.0.3.1)
28
- activesupport (= 6.0.3.1)
29
- activesupport (6.0.3.1)
24
+ activemodel (7.0.0)
25
+ activesupport (= 7.0.0)
26
+ activerecord (7.0.0)
27
+ activemodel (= 7.0.0)
28
+ activesupport (= 7.0.0)
29
+ activesupport (7.0.0)
30
30
  concurrent-ruby (~> 1.0, >= 1.0.2)
31
- i18n (>= 0.7, < 2)
32
- minitest (~> 5.1)
33
- tzinfo (~> 1.1)
34
- zeitwerk (~> 2.2, >= 2.2.2)
31
+ i18n (>= 1.6, < 2)
32
+ minitest (>= 5.1)
33
+ tzinfo (~> 2.0)
35
34
  builder (3.2.4)
36
- combustion (1.3.0)
35
+ combustion (1.3.5)
37
36
  activesupport (>= 3.0.0)
38
37
  railties (>= 3.0.0)
39
38
  thor (>= 0.14.6)
40
- concurrent-ruby (1.1.6)
39
+ concurrent-ruby (1.1.9)
41
40
  crass (1.0.6)
42
- diff-lcs (1.3)
43
- erubi (1.9.0)
44
- i18n (1.8.3)
41
+ diff-lcs (1.4.4)
42
+ erubi (1.10.0)
43
+ i18n (1.8.11)
45
44
  concurrent-ruby (~> 1.0)
46
- loofah (2.5.0)
45
+ loofah (2.13.0)
47
46
  crass (~> 1.0.2)
48
47
  nokogiri (>= 1.5.9)
49
48
  method_source (1.0.0)
50
- mini_portile2 (2.4.0)
51
- minitest (5.14.1)
52
- nokogiri (1.10.9)
53
- mini_portile2 (~> 2.4.0)
49
+ mini_portile2 (2.6.1)
50
+ minitest (5.15.0)
51
+ nokogiri (1.12.5)
52
+ mini_portile2 (~> 2.6.1)
53
+ racc (~> 1.4)
54
54
  pg (1.2.3)
55
- rack (2.2.2)
55
+ racc (1.6.0)
56
+ rack (2.2.3)
56
57
  rack-test (1.1.0)
57
58
  rack (>= 1.0, < 3)
58
59
  rails-dom-testing (2.0.3)
59
60
  activesupport (>= 4.2.0)
60
61
  nokogiri (>= 1.6)
61
- rails-html-sanitizer (1.3.0)
62
+ rails-html-sanitizer (1.4.2)
62
63
  loofah (~> 2.3)
63
- railties (6.0.3.1)
64
- actionpack (= 6.0.3.1)
65
- activesupport (= 6.0.3.1)
64
+ railties (7.0.0)
65
+ actionpack (= 7.0.0)
66
+ activesupport (= 7.0.0)
66
67
  method_source
67
- rake (>= 0.8.7)
68
- thor (>= 0.20.3, < 2.0)
69
- rake (13.0.1)
70
- rspec (3.9.0)
71
- rspec-core (~> 3.9.0)
72
- rspec-expectations (~> 3.9.0)
73
- rspec-mocks (~> 3.9.0)
74
- rspec-core (3.9.2)
75
- rspec-support (~> 3.9.3)
76
- rspec-expectations (3.9.2)
68
+ rake (>= 12.2)
69
+ thor (~> 1.0)
70
+ zeitwerk (~> 2.5)
71
+ rake (13.0.6)
72
+ rspec (3.10.0)
73
+ rspec-core (~> 3.10.0)
74
+ rspec-expectations (~> 3.10.0)
75
+ rspec-mocks (~> 3.10.0)
76
+ rspec-core (3.10.1)
77
+ rspec-support (~> 3.10.0)
78
+ rspec-expectations (3.10.1)
77
79
  diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (~> 3.9.0)
79
- rspec-mocks (3.9.1)
80
+ rspec-support (~> 3.10.0)
81
+ rspec-mocks (3.10.2)
80
82
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.9.0)
82
- rspec-rails (4.0.1)
83
- actionpack (>= 4.2)
84
- activesupport (>= 4.2)
85
- railties (>= 4.2)
86
- rspec-core (~> 3.9)
87
- rspec-expectations (~> 3.9)
88
- rspec-mocks (~> 3.9)
89
- rspec-support (~> 3.9)
90
- rspec-support (3.9.3)
91
- thor (1.0.1)
92
- thread_safe (0.3.6)
93
- tzinfo (1.2.7)
94
- thread_safe (~> 0.1)
95
- zeitwerk (2.3.0)
83
+ rspec-support (~> 3.10.0)
84
+ rspec-rails (5.0.2)
85
+ actionpack (>= 5.2)
86
+ activesupport (>= 5.2)
87
+ railties (>= 5.2)
88
+ rspec-core (~> 3.10)
89
+ rspec-expectations (~> 3.10)
90
+ rspec-mocks (~> 3.10)
91
+ rspec-support (~> 3.10)
92
+ rspec-support (3.10.3)
93
+ thor (1.1.0)
94
+ tzinfo (2.0.4)
95
+ concurrent-ruby (~> 1.0)
96
+ zeitwerk (2.5.1)
96
97
 
97
98
  PLATFORMS
98
99
  ruby
@@ -105,4 +106,4 @@ DEPENDENCIES
105
106
  rspec-rails
106
107
 
107
108
  BUNDLED WITH
108
- 2.1.4
109
+ 2.2.33
data/README.md CHANGED
@@ -30,6 +30,7 @@ ActiveRecord::LogDeleted.configure do |config|
30
30
  config.deleted_rows_table_name = :deleted_rows
31
31
  config.log_deleted_row_function_name = :log_deleted_row
32
32
  config.log_deleted_row_trigger_name = :log_deleted_row_trigger
33
+ config.support_uuids = true
33
34
  end
34
35
  ```
35
36
 
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "combustion"
31
31
  spec.add_development_dependency "rspec-rails"
32
32
 
33
- spec.add_runtime_dependency "activerecord", ">= 5.2", "< 7.0"
33
+ spec.add_runtime_dependency "activerecord", ">= 5.2", "< 8.0"
34
34
  spec.add_runtime_dependency "pg"
35
35
  end
@@ -1,12 +1,18 @@
1
1
  module ActiveRecord
2
2
  module LogDeleted
3
3
  class Configuration
4
- attr_reader :deleted_rows_table_name, :log_deleted_row_function_name, :log_deleted_row_trigger_name
4
+ attr_reader(
5
+ :deleted_rows_table_name,
6
+ :log_deleted_row_function_name,
7
+ :log_deleted_row_trigger_name,
8
+ :support_uuids
9
+ )
5
10
 
6
11
  def initialize
7
12
  @deleted_rows_table_name = :deleted_rows
8
13
  @log_deleted_row_function_name = :log_deleted_row
9
14
  @log_deleted_row_trigger_name = :log_deleted_row_trigger
15
+ @support_uuids = true
10
16
  end
11
17
 
12
18
  def deleted_rows_table_name=(name)
@@ -21,6 +27,10 @@ module ActiveRecord
21
27
  @log_deleted_row_trigger_name = sanitize(name)
22
28
  end
23
29
 
30
+ def support_uuids=(value)
31
+ @support_uuids = value
32
+ end
33
+
24
34
  private
25
35
 
26
36
  def sanitize(value)
@@ -4,10 +4,11 @@ module ActiveRecord
4
4
  module LogDeleted
5
5
  module PostgreSQLAdapter
6
6
  def create_deleted_rows_table
7
+ old_primary_key_type = configuration.support_uuids ? :string : :bigint
7
8
  create_table deleted_rows_table_name do |t|
8
9
  t.datetime :created_at, comment: 'The datetime at which the record was created.'
9
10
  t.text :old_row_json, comment: 'JSON with the entire row that was hard deleted.'
10
- t.string :primary_key, comment: 'The primary key of the row which was hard deleted.'
11
+ t.send old_primary_key_type, :primary_key, comment: 'The primary key of the row which was hard deleted.'
11
12
  t.string :table_name, limit: 255, comment: 'The table name from which the row was hard deleted.'
12
13
  end
13
14
  end
@@ -22,7 +23,7 @@ module ActiveRecord
22
23
  BEGIN
23
24
  INSERT INTO
24
25
  deleted_rows(table_name, primary_key, old_row_json, created_at)
25
- VALUES (TG_TABLE_NAME, OLD.id::varchar, ROW_TO_JSON(OLD), now());
26
+ VALUES (TG_TABLE_NAME, #{old_primary_key('OLD')}, ROW_TO_JSON(OLD), now());
26
27
  RETURN OLD;
27
28
  END;
28
29
  $$ LANGUAGE plpgsql;
@@ -30,7 +31,9 @@ module ActiveRecord
30
31
  end
31
32
 
32
33
  def drop_log_deleted_row_function
33
- execute "DROP FUNCTION #{log_deleted_row_function_name};"
34
+ execute <<~SQL
35
+ DROP FUNCTION IF EXISTS #{log_deleted_row_function_name}();
36
+ SQL
34
37
  end
35
38
 
36
39
  def create_deleted_row_trigger(table_name)
@@ -47,6 +50,12 @@ module ActiveRecord
47
50
 
48
51
  private
49
52
 
53
+ def old_primary_key(table)
54
+ value = "#{table}.id"
55
+ value += '::varchar' if configuration.support_uuids
56
+ value
57
+ end
58
+
50
59
  def log_deleted_row_trigger_name
51
60
  configuration.log_deleted_row_trigger_name
52
61
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module LogDeleted
3
- VERSION = "0.1.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ module ActiveRecord
18
18
  end
19
19
 
20
20
  def self.configure
21
- yield(@configuration)
21
+ yield(configuration)
22
22
  end
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record-log_deleted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matthew fong
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -75,7 +75,7 @@ dependencies:
75
75
  version: '5.2'
76
76
  - - "<"
77
77
  - !ruby/object:Gem::Version
78
- version: '7.0'
78
+ version: '8.0'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
@@ -85,7 +85,7 @@ dependencies:
85
85
  version: '5.2'
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: '7.0'
88
+ version: '8.0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: pg
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +132,7 @@ metadata:
132
132
  homepage_uri: https://github.com/hoverinc/active_record-log_deleted
133
133
  source_code_uri: https://github.com/hoverinc/active_record-log_deleted
134
134
  changelog_uri: https://github.com/hoverinc/active_record-log_deleted/blob/master/CHANGELOG.md
135
- post_install_message:
135
+ post_install_message:
136
136
  rdoc_options: []
137
137
  require_paths:
138
138
  - lib
@@ -147,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.1.2
151
- signing_key:
150
+ rubygems_version: 3.2.32
151
+ signing_key:
152
152
  specification_version: 4
153
153
  summary: ActiveRecord migration methods for logging deleted records
154
154
  test_files: []