Use uuid.Nil instead of uuid.New() in ent schema initializers
It is used just to carry the sql.Scanner and sql.Valuer interface.
This commit is contained in:
@@ -13,14 +13,13 @@ type Answer struct {
|
|||||||
|
|
||||||
func (Answer) Fields() []ent.Field {
|
func (Answer) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Immutable().Unique(),
|
field.UUID("id", uuid.Nil).Immutable().Unique(),
|
||||||
field.Time("answered").Immutable(),
|
field.Time("answered").Immutable(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Answer) Indexes() []ent.Index {
|
func (Answer) Indexes() []ent.Index {
|
||||||
return []ent.Index{
|
return []ent.Index{}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Answer) Edges() []ent.Edge {
|
func (Answer) Edges() []ent.Edge {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type AskedQuestion struct {
|
|||||||
|
|
||||||
func (AskedQuestion) Fields() []ent.Field {
|
func (AskedQuestion) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Immutable(),
|
field.UUID("id", uuid.Nil).Immutable(),
|
||||||
field.Time("asked").Immutable(),
|
field.Time("asked").Immutable(),
|
||||||
field.Time("ended"),
|
field.Time("ended"),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,15 +13,14 @@ type Choice struct {
|
|||||||
|
|
||||||
func (Choice) Fields() []ent.Field {
|
func (Choice) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Immutable(),
|
field.UUID("id", uuid.Nil).Immutable(),
|
||||||
field.Text("title").MinLen(1).MaxLen(256),
|
field.Text("title").MinLen(1).MaxLen(256),
|
||||||
field.Bool("correct"),
|
field.Bool("correct"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Choice) Indexes() []ent.Index {
|
func (Choice) Indexes() []ent.Index {
|
||||||
return []ent.Index{
|
return []ent.Index{}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Choice) Edges() []ent.Edge {
|
func (Choice) Edges() []ent.Edge {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type Game struct {
|
|||||||
|
|
||||||
func (Game) Fields() []ent.Field {
|
func (Game) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Unique().Immutable(),
|
field.UUID("id", uuid.Nil).Unique().Immutable(),
|
||||||
field.Text("name").MaxLen(64),
|
field.Text("name").MaxLen(64),
|
||||||
field.Time("created").Immutable(),
|
field.Time("created").Immutable(),
|
||||||
field.Text("author").MaxLen(64),
|
field.Text("author").MaxLen(64),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type Player struct {
|
|||||||
|
|
||||||
func (Player) Fields() []ent.Field {
|
func (Player) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Immutable(),
|
field.UUID("id", uuid.Nil).Immutable(),
|
||||||
field.Text("name").MaxLen(64).MinLen(1).Match(regexp.MustCompile("(?:[a-z]|[A-Z]|_|-|.|,|[0-9])+")),
|
field.Text("name").MaxLen(64).MinLen(1).Match(regexp.MustCompile("(?:[a-z]|[A-Z]|_|-|.|,|[0-9])+")),
|
||||||
field.Time("joined").Immutable(),
|
field.Time("joined").Immutable(),
|
||||||
field.Bool("organiser").Default(false),
|
field.Bool("organiser").Default(false),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type Question struct {
|
|||||||
|
|
||||||
func (Question) Fields() []ent.Field {
|
func (Question) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Immutable(),
|
field.UUID("id", uuid.Nil).Immutable(),
|
||||||
field.Text("title").MaxLen(256).MinLen(1),
|
field.Text("title").MaxLen(256).MinLen(1),
|
||||||
field.Int("order"),
|
field.Int("order"),
|
||||||
field.Uint64("defaultLength"), // in milliseconds
|
field.Uint64("defaultLength"), // in milliseconds
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type Session struct {
|
|||||||
|
|
||||||
func (Session) Fields() []ent.Field {
|
func (Session) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("id", uuid.New()).Immutable(),
|
field.UUID("id", uuid.Nil).Immutable(),
|
||||||
field.Time("created").Immutable(),
|
field.Time("created").Immutable(),
|
||||||
field.Time("started").Nillable().Optional(), // TODO remove?
|
field.Time("started").Nillable().Optional(), // TODO remove?
|
||||||
field.String("code").MinLen(6).MaxLen(6).Immutable().Unique(),
|
field.String("code").MinLen(6).MaxLen(6).Immutable().Unique(),
|
||||||
|
|||||||
Reference in New Issue
Block a user