mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-06 01:20:31 +00:00
schema changes
This commit is contained in:
parent
974d6914a2
commit
d38e3d5263
2 changed files with 36 additions and 0 deletions
34
backend/internal/data/ent/schema/auth_roles.go
Normal file
34
backend/internal/data/ent/schema/auth_roles.go
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/edge"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthRoles holds the schema definition for the AuthRoles entity.
|
||||||
|
type AuthRoles struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the AuthRoles.
|
||||||
|
func (AuthRoles) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
field.Enum("role").
|
||||||
|
Default("user").
|
||||||
|
Values(
|
||||||
|
"admin", // can do everything - currently unused
|
||||||
|
"user", // default login role
|
||||||
|
"attachments", // Read Attachments
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edges of the AuthRoles.
|
||||||
|
func (AuthRoles) Edges() []ent.Edge {
|
||||||
|
return []ent.Edge{
|
||||||
|
edge.From("token", AuthTokens.Type).
|
||||||
|
Ref("roles").
|
||||||
|
Unique(),
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,8 @@ func (AuthTokens) Edges() []ent.Edge {
|
||||||
edge.From("user", User.Type).
|
edge.From("user", User.Type).
|
||||||
Ref("auth_tokens").
|
Ref("auth_tokens").
|
||||||
Unique(),
|
Unique(),
|
||||||
|
edge.To("roles", AuthRoles.Type).
|
||||||
|
Unique(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue