Files
ent/entc/integration/migrate/entv2/schema/user.go
Ariel Mashraki 108affa8dd ent/schema: move schema packages into a separate package
Reviewed By: alexsn

Differential Revision: D16763332

fbshipit-source-id: e3e4279c62992de192464c3d3b1036c45687507c
2019-08-12 07:53:03 -07:00

45 lines
840 B
Go

package schema
import (
"fbc/ent"
"fbc/ent/schema/field"
"fbc/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{
// changing the type of the field.
field.Int("age"),
// extending name field to longtext.
field.Text("name"),
// adding new columns.
field.String("phone"),
field.Bytes("buffer").
Default([]byte("{}")),
// deleting the address column.
}
}
func (User) Indexes() []ent.Index {
return []ent.Index{
// deleting old indexes (name, address),
// and defining a new one.
index.Fields("phone", "age").
Unique(),
}
}
// Additional types to be added to the schema.
type (
// Pet schema.
Pet struct{ ent.Schema }
// Group schema.
Group struct{ ent.Schema }
)