Role
Defines a user's permissions.
We'll store the possible roles for a user in an enum. So first, create the file auth -> roles -> enums -> role.enum with following content.
Now, let's go back to the User
entity and declare a role
for it. This is how we can map an enum to the database. Also notice the default
value.
The
enumName
option replaces the default name, which follows the pattern "className"_"fieldName"_enum. It would be user_role_enum in this case.
Now, generate and run the migration add-role-to-user. Existing users will receive the USER
role.
Commit - Creating role enum
Last updated