schema changes

This commit is contained in:
Hayden 2022-12-02 20:34:00 -09:00
parent 974d6914a2
commit d38e3d5263
No known key found for this signature in database
GPG key ID: 17CF79474E257545
2 changed files with 36 additions and 0 deletions

View 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(),
}
}

View file

@ -37,6 +37,8 @@ func (AuthTokens) Edges() []ent.Edge {
edge.From("user", User.Type).
Ref("auth_tokens").
Unique(),
edge.To("roles", AuthRoles.Type).
Unique(),
}
}