Files
ent/entc/integration/migrate/entv1/schema/user.go
Ariel Mashraki 1ebfa489c5 ent: add support for enum types
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/45

Reviewed By: alexsn

Differential Revision: D17715085

fbshipit-source-id: 7472e1bd9cf7a8a5bd98f96e6e884c0e27f36803
2019-10-02 12:55:28 -07:00

41 lines
910 B
Go

// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
package schema
import (
"github.com/facebookincubator/ent"
"github.com/facebookincubator/ent/schema/field"
"github.com/facebookincubator/ent/schema/index"
)
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
// Fields of the User.
func (User) Fields() []ent.Field {
return []ent.Field{
field.Int32("age"),
field.String("name").MaxLen(10),
field.String("address").Optional(),
field.String("renamed").
Optional(),
field.Bytes("blob").
Optional().
MaxLen(255),
field.Enum("state").
Optional().
Values("logged_in", "logged_out"),
}
}
func (User) Indexes() []ent.Index {
return []ent.Index{
index.Fields("name", "address").
Unique(),
}
}