| package schema |
|
|
| import ( |
| "github.com/Wei-Shaw/sub2api/ent/schema/mixins" |
|
|
| "entgo.io/ent" |
| "entgo.io/ent/dialect" |
| "entgo.io/ent/dialect/entsql" |
| "entgo.io/ent/schema" |
| "entgo.io/ent/schema/edge" |
| "entgo.io/ent/schema/field" |
| "entgo.io/ent/schema/index" |
| ) |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| type UserAttributeDefinition struct { |
| ent.Schema |
| } |
|
|
| func (UserAttributeDefinition) Annotations() []schema.Annotation { |
| return []schema.Annotation{ |
| entsql.Annotation{Table: "user_attribute_definitions"}, |
| } |
| } |
|
|
| func (UserAttributeDefinition) Mixin() []ent.Mixin { |
| return []ent.Mixin{ |
| mixins.TimeMixin{}, |
| mixins.SoftDeleteMixin{}, |
| } |
| } |
|
|
| func (UserAttributeDefinition) Fields() []ent.Field { |
| return []ent.Field{ |
| |
| |
| field.String("key"). |
| MaxLen(100). |
| NotEmpty(), |
|
|
| |
| field.String("name"). |
| MaxLen(255). |
| NotEmpty(), |
|
|
| |
| field.String("description"). |
| SchemaType(map[string]string{dialect.Postgres: "text"}). |
| Default(""), |
|
|
| |
| field.String("type"). |
| MaxLen(20). |
| NotEmpty(), |
|
|
| |
| |
| field.JSON("options", []map[string]any{}). |
| Default([]map[string]any{}). |
| SchemaType(map[string]string{dialect.Postgres: "jsonb"}), |
|
|
| |
| field.Bool("required"). |
| Default(false), |
|
|
| |
| |
| field.JSON("validation", map[string]any{}). |
| Default(map[string]any{}). |
| SchemaType(map[string]string{dialect.Postgres: "jsonb"}), |
|
|
| |
| field.String("placeholder"). |
| MaxLen(255). |
| Default(""), |
|
|
| |
| field.Int("display_order"). |
| Default(0), |
|
|
| |
| field.Bool("enabled"). |
| Default(true), |
| } |
| } |
|
|
| func (UserAttributeDefinition) Edges() []ent.Edge { |
| return []ent.Edge{ |
| |
| edge.To("values", UserAttributeValue.Type), |
| } |
| } |
|
|
| func (UserAttributeDefinition) Indexes() []ent.Index { |
| return []ent.Index{ |
| |
| index.Fields("key"), |
| index.Fields("enabled"), |
| index.Fields("display_order"), |
| index.Fields("deleted_at"), |
| } |
| } |
|
|