@@ -22,6 +22,43 @@ user experience akin to that offered by the well-regarded Devise gem.
22
22
7 . [ License] ( #license )
23
23
8 . [ Credits] ( #credits )
24
24
25
+ ## Breaking Changes
26
+
27
+ With the release of v1.0.0, there are some breaking changes that have been introduced. The
28
+ biggest change is that the ` ActionAuth::User ` model now uses the table name of ` users ` instead
29
+ of ` action_auth_users ` . This was done to make it easier to integrate with your application
30
+ without having to worry about the table name. If you have an existing application that is
31
+ using ActionAuth, you will need to rename the table to ` users ` with a migration like
32
+
33
+ ``` ruby
34
+ rename_table :action_auth_users , :users
35
+ ```
36
+
37
+ Coming from ` v0.3.0 ` to ` v1.0.0 ` , you will need to create a migration to rename the table and foreign keys.
38
+
39
+ ``` ruby
40
+ class UpgradeActionAuth < ActiveRecord ::Migration [7.1 ]
41
+ def change
42
+ rename_table :action_auth_users , :users
43
+
44
+ rename_table :action_auth_sessions , :sessions
45
+ rename_column :sessions , :action_auth_user_id , :user_id
46
+
47
+ rename_table :action_auth_webauthn_credentials , :webauthn_credentials
48
+ rename_column :webauthn_credentials , :action_auth_user_id , :user_id
49
+ end
50
+ end
51
+ ```
52
+
53
+ You will then need to undo the migrations where the foreign keys were added in cases where ` foreign_key: true ` was
54
+ changed to ` foreign_key: { to_table: 'action_auth_users' } ` . You can do this for each table with a migration like:
55
+
56
+ ``` ruby
57
+ add_foreign_key :user_settings , :users , column: :user_id unless foreign_key_exists?(:user_settings , :users )
58
+ add_foreign_key :profiles , :users , column: :user_id unless foreign_key_exists?(:profiles , :users )
59
+ add_foreign_key :nfcs , :users , column: :user_id unless foreign_key_exists?(:nfcs , :users )
60
+ ```
61
+
25
62
## Installation
26
63
Add this line to your application's Gemfile:
27
64
@@ -242,30 +279,12 @@ end
242
279
243
280
#### Generating an association
244
281
245
- There's one little gotcha when generating the associations. We are using ` user:belongs_to ` instead of
246
- ` action_auth_user:belongs_to ` . However, when the foreign key is generated, it will look for the users table
247
- instead of the action_auth_users table. To get around this, we'll need to modify the migration.
282
+ We are using ` user:belongs_to ` instead of ` action_auth_user:belongs_to ` .
248
283
249
284
``` bash
250
285
bin/rails g scaffold posts user:belongs_to title
251
286
```
252
287
253
- We can update the ` foreign_key ` from ` true ` to ` { to_table: :action_auth_users } ` to get around this.
254
-
255
- ``` ruby
256
- # db/migrate/XXXXXXXXXXX_create_posts.rb
257
- class CreatePosts < ActiveRecord ::Migration [7.1 ]
258
- def change
259
- create_table :posts do |t |
260
- t.belongs_to :user , null: false , foreign_key: { to_table: :action_auth_users }
261
- t.string :title
262
-
263
- t.timestamps
264
- end
265
- end
266
- end
267
- ```
268
-
269
288
And the post model doesn't need anything special to ActionAuth.
270
289
271
290
``` ruby
0 commit comments