feat(schema): restore complete Ent schema files
This commit is contained in:
34
ent/schema/user_role.go
Normal file
34
ent/schema/user_role.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// UserRole holds the schema definition for the UserRole entity (many-to-many relationship).
|
||||
type UserRole struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the UserRole.
|
||||
func (UserRole) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("user_id"),
|
||||
field.String("role_id"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the UserRole.
|
||||
func (UserRole) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("user", User.Type).
|
||||
Unique().
|
||||
Required().
|
||||
Field("user_id"),
|
||||
edge.To("role", Role.Type).
|
||||
Unique().
|
||||
Required().
|
||||
Field("role_id"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user