Files
go-utils/entgo/mixin/switch_status.go
2023-10-31 04:46:17 +08:00

39 lines
677 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package mixin
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/mixin"
)
type SwitchStatus struct {
mixin.Schema
}
func (SwitchStatus) Fields() []ent.Field {
return []ent.Field{
/**
在PostgreSQL下还需要为此创建一个Type否则无法使用。
DROP TYPE IF EXISTS switch_status CASCADE;
CREATE TYPE switch_status AS ENUM (
'OFF',
'ON'
);
*/
field.Enum("status").
Comment("状态").
Optional().
Nillable().
//SchemaType(map[string]string{
// dialect.MySQL: "switch_status",
// dialect.Postgres: "switch_status",
//}).
Default("ON").
Values(
"OFF",
"ON",
),
}
}