File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1+ ## 0.6.0 (unreleased)
2+
3+ - Improved generator for Active Record encryption and MySQL
4+
15## 0.5.0 (2023-07-02)
26
37- Made Active Record and Active Job optional
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ rails generate authtrail:install --encryption=lockbox
2121rails db:migrate
2222```
2323
24- To use Active Record encryption (Rails 7+, experimental ), run:
24+ To use Active Record encryption (Rails 7+), run:
2525
2626``` sh
2727rails generate authtrail:install --encryption=activerecord
Original file line number Diff line number Diff line change @@ -39,8 +39,11 @@ def identity_column
3939 when "lockbox"
4040 "t.text :identity_ciphertext\n t.string :identity_bidx, index: true"
4141 else
42- # TODO add limit: 510 for Active Record encryption + MySQL?
43- "t.string :identity, index: true"
42+ if encryption == "activerecord" && mysql?
43+ "t.string :identity, limit: 510, index: true"
44+ else
45+ "t.string :identity, index: true"
46+ end
4447 end
4548 end
4649
@@ -49,7 +52,6 @@ def ip_column
4952 when "lockbox"
5053 "t.text :ip_ciphertext\n t.string :ip_bidx, index: true"
5154 else
52- # TODO add limit: 510 for Active Record encryption + MySQL?
5355 "t.string :ip, index: true"
5456 end
5557 end
@@ -78,6 +80,14 @@ def lockbox_method
7880 "has_encrypted"
7981 end
8082 end
83+
84+ def mysql?
85+ adapter =~ /mysql|trilogy/i
86+ end
87+
88+ def adapter
89+ ActiveRecord ::Base . connection_db_config . adapter . to_s
90+ end
8191 end
8292 end
8393end
You can’t perform that action at this time.
0 commit comments