snapcher 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -5
- data/lib/generators/snapcher/migration.rb +25 -0
- data/lib/generators/snapcher/migration_helper.rb +11 -0
- data/lib/generators/snapcher/templates/add_user_id_to_scannings.rb +20 -0
- data/lib/generators/snapcher/templates/install.rb +0 -1
- data/lib/generators/snapcher/upgrade_generator.rb +26 -0
- data/lib/snapcher/junker.rb +6 -2
- data/lib/snapcher/version.rb +1 -1
- data/lib/snapcher.rb +11 -1
- data/sample-app/Gemfile.lock +95 -96
- data/sample-app/app/models/post.rb +5 -0
- data/sample-app/db/migrate/20240509025320_add_user_id_to_scannings.rb +20 -0
- data/sample-app/db/migrate/20240509080448_create_posts.rb +11 -0
- data/sample-app/db/schema.rb +4 -1
- metadata +10 -3
- /data/lib/generators/snapcher/{install/install_generator.rb → install_generator.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 494c49faf14017fbe5f13d5fd7f657a7b2fad2b78ac9264c83497217a70c7977
|
4
|
+
data.tar.gz: 6bc6340796e5344951ee7dbf02362978a512a5ca9230acb1d68c9e7293a7362d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d9af61604cd3a0693c832f32ccf7e92c963e913b9800cebf7a6a4094646edca7b559a61b207a5f10f0f1e2149e2e833e156d1d192ca67df6b32a08cb9fe737
|
7
|
+
data.tar.gz: 5e734b6997ef32f8f7fda3f2f23a9267ffa3ef01fa5268fe3303b222d9e20036f71925b2463ed526b62dd34a5fe5a89b74e57b000f07aaefa9c91b36ad51bae9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
snapcher (0.1.
|
4
|
+
snapcher (0.1.5)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -72,7 +72,6 @@ GEM
|
|
72
72
|
minitest (>= 5.1)
|
73
73
|
tzinfo (~> 2.0)
|
74
74
|
ast (2.4.2)
|
75
|
-
base64 (0.1.1)
|
76
75
|
builder (3.2.4)
|
77
76
|
concurrent-ruby (1.2.2)
|
78
77
|
crass (1.0.6)
|
@@ -185,8 +184,7 @@ GEM
|
|
185
184
|
rspec-mocks (~> 3.12)
|
186
185
|
rspec-support (~> 3.12)
|
187
186
|
rspec-support (3.12.1)
|
188
|
-
rubocop (1.57.
|
189
|
-
base64 (~> 0.1.1)
|
187
|
+
rubocop (1.57.2)
|
190
188
|
json (~> 2.3)
|
191
189
|
language_server-protocol (>= 3.17.0)
|
192
190
|
parallel (~> 1.10)
|
@@ -197,7 +195,7 @@ GEM
|
|
197
195
|
rubocop-ast (>= 1.28.1, < 2.0)
|
198
196
|
ruby-progressbar (~> 1.7)
|
199
197
|
unicode-display_width (>= 2.4.0, < 3.0)
|
200
|
-
rubocop-ast (1.
|
198
|
+
rubocop-ast (1.30.0)
|
201
199
|
parser (>= 3.2.1.0)
|
202
200
|
rubocop-capybara (2.19.0)
|
203
201
|
rubocop (~> 1.41)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Snapcher
|
4
|
+
module Generators
|
5
|
+
module Migration
|
6
|
+
# Implement the required interface for Rails::Generators::Migration.
|
7
|
+
def next_migration_number(dirname) # :nodoc:
|
8
|
+
next_migration_number = current_migration_number(dirname) + 1
|
9
|
+
if timestamped_migrations?
|
10
|
+
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
11
|
+
else
|
12
|
+
"%.3d" % next_migration_number
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def timestamped_migrations?
|
19
|
+
(Rails.gem_version >= Gem::Version.new("7.0")) ?
|
20
|
+
::ActiveRecord.timestamped_migrations :
|
21
|
+
::ActiveRecord::Base.timestamped_migrations
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class <%= migration_class_name %> < <%= migration_parent %>
|
4
|
+
def self.up
|
5
|
+
add_column :scannings, :user_id, :<%= options[:snapcher_user_id_column_type] %>, after: :action
|
6
|
+
|
7
|
+
add_index :scannings, [:user_id], name: index_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.down
|
11
|
+
remove_column :scannings, :user_id
|
12
|
+
remove_index :scannings, name: index_name
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def index_name
|
18
|
+
'snapcher_user_index'
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "rails/generators/migration"
|
5
|
+
require "active_record"
|
6
|
+
require "rails/generators/active_record"
|
7
|
+
require "generators/snapcher/migration"
|
8
|
+
require "generators/snapcher/migration_helper"
|
9
|
+
|
10
|
+
module Snapcher
|
11
|
+
module Generators
|
12
|
+
class UpgradeGenerator < Rails::Generators::Base
|
13
|
+
include Rails::Generators::Migration
|
14
|
+
include Snapcher::Generators::MigrationHelper
|
15
|
+
extend Snapcher::Generators::Migration
|
16
|
+
|
17
|
+
class_option :snapcher_user_id_column_type, type: :string, default: "integer", required: false
|
18
|
+
|
19
|
+
source_root File.expand_path("../templates", __FILE__)
|
20
|
+
|
21
|
+
def copy_templates
|
22
|
+
migration_template "add_user_id_to_scannings.rb", "db/migrate/add_user_id_to_scannings.rb"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/snapcher/junker.rb
CHANGED
@@ -32,6 +32,7 @@ module Snapcher
|
|
32
32
|
run_scanning(action: "create",
|
33
33
|
column_name: snapcher_options[:column_name],
|
34
34
|
after_params: snapcher_attributes[snapcher_options[:column_name]],
|
35
|
+
user_id: snapcher_attributes["user_id"],
|
35
36
|
table_name: self.class.table_name)
|
36
37
|
end
|
37
38
|
|
@@ -41,6 +42,7 @@ module Snapcher
|
|
41
42
|
run_scanning(action: "update",
|
42
43
|
column_name: snapcher_options[:column_name],
|
43
44
|
table_name: self.class.table_name,
|
45
|
+
user_id: snapcher_attributes["user_id"],
|
44
46
|
before_params: snapcher_changes[:before_params],
|
45
47
|
after_params: snapcher_changes[:after_params])
|
46
48
|
end
|
@@ -48,8 +50,10 @@ module Snapcher
|
|
48
50
|
def scanning_destroy
|
49
51
|
return if new_record?
|
50
52
|
|
51
|
-
run_scanning(action: "destroy",
|
52
|
-
|
53
|
+
run_scanning(action: "destroy",
|
54
|
+
column_name: snapcher_options[:column_name],
|
55
|
+
table_name: self.class.table_name,
|
56
|
+
user_id: snapcher_attributes["user_id"])
|
53
57
|
end
|
54
58
|
|
55
59
|
# List of attributes that are snapcher.
|
data/lib/snapcher/version.rb
CHANGED
data/lib/snapcher.rb
CHANGED
@@ -6,8 +6,12 @@ module Snapcher
|
|
6
6
|
class Error < StandardError; end
|
7
7
|
# Your code goes here...
|
8
8
|
|
9
|
+
class RequestStore < ActiveSupport::CurrentAttributes
|
10
|
+
attribute :snapcher_store
|
11
|
+
end
|
12
|
+
|
9
13
|
class << self
|
10
|
-
attr_accessor :column_name
|
14
|
+
attr_accessor :column_name, :current_user
|
11
15
|
attr_writer :scanning_class
|
12
16
|
|
13
17
|
def scanning_class
|
@@ -17,7 +21,13 @@ module Snapcher
|
|
17
21
|
@scanning_class = @scanning_class.safe_constantize if @scanning_class.is_a?(String)
|
18
22
|
@scanning_class ||= Snapcher::Scanning
|
19
23
|
end
|
24
|
+
|
25
|
+
def store
|
26
|
+
RequestStore.snapcher_store ||= {}
|
27
|
+
end
|
20
28
|
end
|
29
|
+
|
30
|
+
@current_user_method = :current_user
|
21
31
|
end
|
22
32
|
|
23
33
|
require "snapcher/junker"
|
data/sample-app/Gemfile.lock
CHANGED
@@ -1,75 +1,76 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
snapcher (0.
|
4
|
+
snapcher (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actioncable (7.1.
|
10
|
-
actionpack (= 7.1.
|
11
|
-
activesupport (= 7.1.
|
9
|
+
actioncable (7.1.3.2)
|
10
|
+
actionpack (= 7.1.3.2)
|
11
|
+
activesupport (= 7.1.3.2)
|
12
12
|
nio4r (~> 2.0)
|
13
13
|
websocket-driver (>= 0.6.1)
|
14
14
|
zeitwerk (~> 2.6)
|
15
|
-
actionmailbox (7.1.
|
16
|
-
actionpack (= 7.1.
|
17
|
-
activejob (= 7.1.
|
18
|
-
activerecord (= 7.1.
|
19
|
-
activestorage (= 7.1.
|
20
|
-
activesupport (= 7.1.
|
15
|
+
actionmailbox (7.1.3.2)
|
16
|
+
actionpack (= 7.1.3.2)
|
17
|
+
activejob (= 7.1.3.2)
|
18
|
+
activerecord (= 7.1.3.2)
|
19
|
+
activestorage (= 7.1.3.2)
|
20
|
+
activesupport (= 7.1.3.2)
|
21
21
|
mail (>= 2.7.1)
|
22
22
|
net-imap
|
23
23
|
net-pop
|
24
24
|
net-smtp
|
25
|
-
actionmailer (7.1.
|
26
|
-
actionpack (= 7.1.
|
27
|
-
actionview (= 7.1.
|
28
|
-
activejob (= 7.1.
|
29
|
-
activesupport (= 7.1.
|
25
|
+
actionmailer (7.1.3.2)
|
26
|
+
actionpack (= 7.1.3.2)
|
27
|
+
actionview (= 7.1.3.2)
|
28
|
+
activejob (= 7.1.3.2)
|
29
|
+
activesupport (= 7.1.3.2)
|
30
30
|
mail (~> 2.5, >= 2.5.4)
|
31
31
|
net-imap
|
32
32
|
net-pop
|
33
33
|
net-smtp
|
34
34
|
rails-dom-testing (~> 2.2)
|
35
|
-
actionpack (7.1.
|
36
|
-
actionview (= 7.1.
|
37
|
-
activesupport (= 7.1.
|
35
|
+
actionpack (7.1.3.2)
|
36
|
+
actionview (= 7.1.3.2)
|
37
|
+
activesupport (= 7.1.3.2)
|
38
38
|
nokogiri (>= 1.8.5)
|
39
|
+
racc
|
39
40
|
rack (>= 2.2.4)
|
40
41
|
rack-session (>= 1.0.1)
|
41
42
|
rack-test (>= 0.6.3)
|
42
43
|
rails-dom-testing (~> 2.2)
|
43
44
|
rails-html-sanitizer (~> 1.6)
|
44
|
-
actiontext (7.1.
|
45
|
-
actionpack (= 7.1.
|
46
|
-
activerecord (= 7.1.
|
47
|
-
activestorage (= 7.1.
|
48
|
-
activesupport (= 7.1.
|
45
|
+
actiontext (7.1.3.2)
|
46
|
+
actionpack (= 7.1.3.2)
|
47
|
+
activerecord (= 7.1.3.2)
|
48
|
+
activestorage (= 7.1.3.2)
|
49
|
+
activesupport (= 7.1.3.2)
|
49
50
|
globalid (>= 0.6.0)
|
50
51
|
nokogiri (>= 1.8.5)
|
51
|
-
actionview (7.1.
|
52
|
-
activesupport (= 7.1.
|
52
|
+
actionview (7.1.3.2)
|
53
|
+
activesupport (= 7.1.3.2)
|
53
54
|
builder (~> 3.1)
|
54
55
|
erubi (~> 1.11)
|
55
56
|
rails-dom-testing (~> 2.2)
|
56
57
|
rails-html-sanitizer (~> 1.6)
|
57
|
-
activejob (7.1.
|
58
|
-
activesupport (= 7.1.
|
58
|
+
activejob (7.1.3.2)
|
59
|
+
activesupport (= 7.1.3.2)
|
59
60
|
globalid (>= 0.3.6)
|
60
|
-
activemodel (7.1.
|
61
|
-
activesupport (= 7.1.
|
62
|
-
activerecord (7.1.
|
63
|
-
activemodel (= 7.1.
|
64
|
-
activesupport (= 7.1.
|
61
|
+
activemodel (7.1.3.2)
|
62
|
+
activesupport (= 7.1.3.2)
|
63
|
+
activerecord (7.1.3.2)
|
64
|
+
activemodel (= 7.1.3.2)
|
65
|
+
activesupport (= 7.1.3.2)
|
65
66
|
timeout (>= 0.4.0)
|
66
|
-
activestorage (7.1.
|
67
|
-
actionpack (= 7.1.
|
68
|
-
activejob (= 7.1.
|
69
|
-
activerecord (= 7.1.
|
70
|
-
activesupport (= 7.1.
|
67
|
+
activestorage (7.1.3.2)
|
68
|
+
actionpack (= 7.1.3.2)
|
69
|
+
activejob (= 7.1.3.2)
|
70
|
+
activerecord (= 7.1.3.2)
|
71
|
+
activesupport (= 7.1.3.2)
|
71
72
|
marcel (~> 1.0)
|
72
|
-
activesupport (7.1.
|
73
|
+
activesupport (7.1.3.2)
|
73
74
|
base64
|
74
75
|
bigdecimal
|
75
76
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -79,34 +80,33 @@ GEM
|
|
79
80
|
minitest (>= 5.1)
|
80
81
|
mutex_m
|
81
82
|
tzinfo (~> 2.0)
|
82
|
-
base64 (0.
|
83
|
-
bigdecimal (3.1.
|
83
|
+
base64 (0.2.0)
|
84
|
+
bigdecimal (3.1.8)
|
84
85
|
bindex (0.8.1)
|
85
|
-
bootsnap (1.
|
86
|
+
bootsnap (1.18.3)
|
86
87
|
msgpack (~> 1.2)
|
87
88
|
builder (3.2.4)
|
88
|
-
concurrent-ruby (1.2.
|
89
|
+
concurrent-ruby (1.2.3)
|
89
90
|
connection_pool (2.4.1)
|
90
91
|
crass (1.0.6)
|
91
|
-
date (3.3.
|
92
|
-
debug (1.
|
93
|
-
irb (
|
94
|
-
reline (>= 0.3.
|
95
|
-
drb (2.
|
96
|
-
ruby2_keywords
|
92
|
+
date (3.3.4)
|
93
|
+
debug (1.9.2)
|
94
|
+
irb (~> 1.10)
|
95
|
+
reline (>= 0.3.8)
|
96
|
+
drb (2.2.1)
|
97
97
|
erubi (1.12.0)
|
98
98
|
globalid (1.2.1)
|
99
99
|
activesupport (>= 6.1)
|
100
|
-
i18n (1.14.
|
100
|
+
i18n (1.14.5)
|
101
101
|
concurrent-ruby (~> 1.0)
|
102
|
-
io-console (0.
|
103
|
-
irb (1.
|
104
|
-
rdoc
|
105
|
-
reline (>= 0.
|
106
|
-
jbuilder (2.
|
102
|
+
io-console (0.7.2)
|
103
|
+
irb (1.13.1)
|
104
|
+
rdoc (>= 4.0.0)
|
105
|
+
reline (>= 0.4.2)
|
106
|
+
jbuilder (2.12.0)
|
107
107
|
actionview (>= 5.0.0)
|
108
108
|
activesupport (>= 5.0.0)
|
109
|
-
loofah (2.
|
109
|
+
loofah (2.22.0)
|
110
110
|
crass (~> 1.0.2)
|
111
111
|
nokogiri (>= 1.12.0)
|
112
112
|
mail (2.8.1)
|
@@ -114,33 +114,33 @@ GEM
|
|
114
114
|
net-imap
|
115
115
|
net-pop
|
116
116
|
net-smtp
|
117
|
-
marcel (1.0.
|
117
|
+
marcel (1.0.4)
|
118
118
|
mini_mime (1.1.5)
|
119
|
-
minitest (5.
|
119
|
+
minitest (5.22.3)
|
120
120
|
msgpack (1.7.2)
|
121
|
-
mutex_m (0.
|
122
|
-
net-imap (0.4.
|
121
|
+
mutex_m (0.2.0)
|
122
|
+
net-imap (0.4.11)
|
123
123
|
date
|
124
124
|
net-protocol
|
125
125
|
net-pop (0.1.2)
|
126
126
|
net-protocol
|
127
|
-
net-protocol (0.2.
|
127
|
+
net-protocol (0.2.2)
|
128
128
|
timeout
|
129
|
-
net-smtp (0.
|
129
|
+
net-smtp (0.5.0)
|
130
130
|
net-protocol
|
131
|
-
nio4r (2.
|
132
|
-
nokogiri (1.
|
131
|
+
nio4r (2.7.3)
|
132
|
+
nokogiri (1.16.4-aarch64-linux)
|
133
133
|
racc (~> 1.4)
|
134
|
-
nokogiri (1.
|
134
|
+
nokogiri (1.16.4-arm64-darwin)
|
135
135
|
racc (~> 1.4)
|
136
|
-
nokogiri (1.
|
136
|
+
nokogiri (1.16.4-x86_64-linux)
|
137
137
|
racc (~> 1.4)
|
138
|
-
psych (5.1.
|
138
|
+
psych (5.1.2)
|
139
139
|
stringio
|
140
|
-
puma (6.4.
|
140
|
+
puma (6.4.2)
|
141
141
|
nio4r (~> 2.0)
|
142
|
-
racc (1.7.
|
143
|
-
rack (3.0.
|
142
|
+
racc (1.7.3)
|
143
|
+
rack (3.0.10)
|
144
144
|
rack-session (2.0.0)
|
145
145
|
rack (>= 3.0.0)
|
146
146
|
rack-test (2.1.0)
|
@@ -148,20 +148,20 @@ GEM
|
|
148
148
|
rackup (2.1.0)
|
149
149
|
rack (>= 3)
|
150
150
|
webrick (~> 1.8)
|
151
|
-
rails (7.1.
|
152
|
-
actioncable (= 7.1.
|
153
|
-
actionmailbox (= 7.1.
|
154
|
-
actionmailer (= 7.1.
|
155
|
-
actionpack (= 7.1.
|
156
|
-
actiontext (= 7.1.
|
157
|
-
actionview (= 7.1.
|
158
|
-
activejob (= 7.1.
|
159
|
-
activemodel (= 7.1.
|
160
|
-
activerecord (= 7.1.
|
161
|
-
activestorage (= 7.1.
|
162
|
-
activesupport (= 7.1.
|
151
|
+
rails (7.1.3.2)
|
152
|
+
actioncable (= 7.1.3.2)
|
153
|
+
actionmailbox (= 7.1.3.2)
|
154
|
+
actionmailer (= 7.1.3.2)
|
155
|
+
actionpack (= 7.1.3.2)
|
156
|
+
actiontext (= 7.1.3.2)
|
157
|
+
actionview (= 7.1.3.2)
|
158
|
+
activejob (= 7.1.3.2)
|
159
|
+
activemodel (= 7.1.3.2)
|
160
|
+
activerecord (= 7.1.3.2)
|
161
|
+
activestorage (= 7.1.3.2)
|
162
|
+
activesupport (= 7.1.3.2)
|
163
163
|
bundler (>= 1.15.0)
|
164
|
-
railties (= 7.1.
|
164
|
+
railties (= 7.1.3.2)
|
165
165
|
rails-dom-testing (2.2.0)
|
166
166
|
activesupport (>= 5.0.0)
|
167
167
|
minitest
|
@@ -169,20 +169,19 @@ GEM
|
|
169
169
|
rails-html-sanitizer (1.6.0)
|
170
170
|
loofah (~> 2.21)
|
171
171
|
nokogiri (~> 1.14)
|
172
|
-
railties (7.1.
|
173
|
-
actionpack (= 7.1.
|
174
|
-
activesupport (= 7.1.
|
172
|
+
railties (7.1.3.2)
|
173
|
+
actionpack (= 7.1.3.2)
|
174
|
+
activesupport (= 7.1.3.2)
|
175
175
|
irb
|
176
176
|
rackup (>= 1.0.0)
|
177
177
|
rake (>= 12.2)
|
178
178
|
thor (~> 1.0, >= 1.2.2)
|
179
179
|
zeitwerk (~> 2.6)
|
180
|
-
rake (13.
|
181
|
-
rdoc (6.
|
180
|
+
rake (13.2.1)
|
181
|
+
rdoc (6.6.3.1)
|
182
182
|
psych (>= 4.0.0)
|
183
|
-
reline (0.
|
183
|
+
reline (0.5.5)
|
184
184
|
io-console (~> 0.5)
|
185
|
-
ruby2_keywords (0.0.5)
|
186
185
|
sprockets (4.2.1)
|
187
186
|
concurrent-ruby (~> 1.0)
|
188
187
|
rack (>= 2.2.4, < 4)
|
@@ -190,12 +189,12 @@ GEM
|
|
190
189
|
actionpack (>= 5.2)
|
191
190
|
activesupport (>= 5.2)
|
192
191
|
sprockets (>= 3.0.0)
|
193
|
-
sqlite3 (1.
|
194
|
-
sqlite3 (1.
|
195
|
-
sqlite3 (1.
|
196
|
-
stringio (3.0
|
197
|
-
thor (1.3.
|
198
|
-
timeout (0.4.
|
192
|
+
sqlite3 (1.7.3-aarch64-linux)
|
193
|
+
sqlite3 (1.7.3-arm64-darwin)
|
194
|
+
sqlite3 (1.7.3-x86_64-linux)
|
195
|
+
stringio (3.1.0)
|
196
|
+
thor (1.3.1)
|
197
|
+
timeout (0.4.1)
|
199
198
|
tzinfo (2.0.6)
|
200
199
|
concurrent-ruby (~> 1.0)
|
201
200
|
web-console (4.2.1)
|
@@ -207,7 +206,7 @@ GEM
|
|
207
206
|
websocket-driver (0.7.6)
|
208
207
|
websocket-extensions (>= 0.1.0)
|
209
208
|
websocket-extensions (0.1.5)
|
210
|
-
zeitwerk (2.6.
|
209
|
+
zeitwerk (2.6.13)
|
211
210
|
|
212
211
|
PLATFORMS
|
213
212
|
aarch64-linux
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddUserIdToScannings < ActiveRecord::Migration[7.1]
|
4
|
+
def self.up
|
5
|
+
add_column :scannings, :user_id, :integer
|
6
|
+
|
7
|
+
add_index :scannings, [:user_id], name: index_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.down
|
11
|
+
remove_column :scannings, :user_id
|
12
|
+
remove_index :scannings, name: index_name
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def index_name
|
18
|
+
'user_index'
|
19
|
+
end
|
20
|
+
end
|
data/sample-app/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema[7.1].define(version:
|
13
|
+
ActiveRecord::Schema[7.1].define(version: 2024_05_09_025320) do
|
14
14
|
create_table "scannings", force: :cascade do |t|
|
15
15
|
t.integer "scannable_id"
|
16
16
|
t.string "scannable_type"
|
@@ -20,6 +20,8 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_19_151334) do
|
|
20
20
|
t.string "after_params"
|
21
21
|
t.string "action"
|
22
22
|
t.datetime "created_at"
|
23
|
+
t.integer "user_id"
|
24
|
+
t.index ["user_id"], name: "user_index"
|
23
25
|
end
|
24
26
|
|
25
27
|
create_table "users", force: :cascade do |t|
|
@@ -33,4 +35,5 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_19_151334) do
|
|
33
35
|
t.datetime "created_at", null: false
|
34
36
|
t.datetime "updated_at", null: false
|
35
37
|
end
|
38
|
+
|
36
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryosk7
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Snapcher is an ORM extension that logs changes to specific columns to your model.
|
@@ -31,8 +31,12 @@ files:
|
|
31
31
|
- LICENSE.txt
|
32
32
|
- README.md
|
33
33
|
- Rakefile
|
34
|
-
- lib/generators/snapcher/
|
34
|
+
- lib/generators/snapcher/install_generator.rb
|
35
|
+
- lib/generators/snapcher/migration.rb
|
36
|
+
- lib/generators/snapcher/migration_helper.rb
|
37
|
+
- lib/generators/snapcher/templates/add_user_id_to_scannings.rb
|
35
38
|
- lib/generators/snapcher/templates/install.rb
|
39
|
+
- lib/generators/snapcher/upgrade_generator.rb
|
36
40
|
- lib/snapcher.rb
|
37
41
|
- lib/snapcher/junker.rb
|
38
42
|
- lib/snapcher/railtie.rb
|
@@ -58,6 +62,7 @@ files:
|
|
58
62
|
- sample-app/app/jobs/application_job.rb
|
59
63
|
- sample-app/app/models/application_record.rb
|
60
64
|
- sample-app/app/models/concerns/.keep
|
65
|
+
- sample-app/app/models/post.rb
|
61
66
|
- sample-app/app/models/user.rb
|
62
67
|
- sample-app/app/views/layouts/application.html.erb
|
63
68
|
- sample-app/bin/bundle
|
@@ -84,6 +89,8 @@ files:
|
|
84
89
|
- sample-app/config/routes.rb
|
85
90
|
- sample-app/db/migrate/20231019150803_create_users.rb
|
86
91
|
- sample-app/db/migrate/20231019151334_install_snapcher.rb
|
92
|
+
- sample-app/db/migrate/20240509025320_add_user_id_to_scannings.rb
|
93
|
+
- sample-app/db/migrate/20240509080448_create_posts.rb
|
87
94
|
- sample-app/db/schema.rb
|
88
95
|
- sample-app/db/seeds.rb
|
89
96
|
- sample-app/lib/assets/.keep
|
File without changes
|