1
0

update migrate

This commit is contained in:
2023-04-05 15:05:14 +09:00
parent 9573dc895f
commit 1d5cb2ad9f
87 changed files with 65302 additions and 622 deletions

View File

@ -3,11 +3,11 @@
package ent
import (
"api/ent/card"
"api/ent/user"
"context"
"errors"
"fmt"
"t/ent/card"
"t/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -21,6 +21,12 @@ type CardCreate struct {
hooks []Hook
}
// SetPassword sets the "password" field.
func (cc *CardCreate) SetPassword(s string) *CardCreate {
cc.mutation.SetPassword(s)
return cc
}
// SetCard sets the "card" field.
func (cc *CardCreate) SetCard(i int) *CardCreate {
cc.mutation.SetCard(i)
@ -35,6 +41,20 @@ func (cc *CardCreate) SetNillableCard(i *int) *CardCreate {
return cc
}
// SetSkill sets the "skill" field.
func (cc *CardCreate) SetSkill(s string) *CardCreate {
cc.mutation.SetSkill(s)
return cc
}
// SetNillableSkill sets the "skill" field if the given value is not nil.
func (cc *CardCreate) SetNillableSkill(s *string) *CardCreate {
if s != nil {
cc.SetSkill(*s)
}
return cc
}
// SetStatus sets the "status" field.
func (cc *CardCreate) SetStatus(s string) *CardCreate {
cc.mutation.SetStatus(s)
@ -49,6 +69,20 @@ func (cc *CardCreate) SetNillableStatus(s *string) *CardCreate {
return cc
}
// SetToken sets the "token" field.
func (cc *CardCreate) SetToken(s string) *CardCreate {
cc.mutation.SetToken(s)
return cc
}
// SetNillableToken sets the "token" field if the given value is not nil.
func (cc *CardCreate) SetNillableToken(s *string) *CardCreate {
if s != nil {
cc.SetToken(*s)
}
return cc
}
// SetCp sets the "cp" field.
func (cc *CardCreate) SetCp(i int) *CardCreate {
cc.mutation.SetCp(i)
@ -77,6 +111,34 @@ func (cc *CardCreate) SetNillableURL(s *string) *CardCreate {
return cc
}
// SetCount sets the "count" field.
func (cc *CardCreate) SetCount(i int) *CardCreate {
cc.mutation.SetCount(i)
return cc
}
// SetNillableCount sets the "count" field if the given value is not nil.
func (cc *CardCreate) SetNillableCount(i *int) *CardCreate {
if i != nil {
cc.SetCount(*i)
}
return cc
}
// SetAuthor sets the "author" field.
func (cc *CardCreate) SetAuthor(s string) *CardCreate {
cc.mutation.SetAuthor(s)
return cc
}
// SetNillableAuthor sets the "author" field if the given value is not nil.
func (cc *CardCreate) SetNillableAuthor(s *string) *CardCreate {
if s != nil {
cc.SetAuthor(*s)
}
return cc
}
// SetCreatedAt sets the "created_at" field.
func (cc *CardCreate) SetCreatedAt(t time.Time) *CardCreate {
cc.mutation.SetCreatedAt(t)
@ -141,6 +203,10 @@ func (cc *CardCreate) defaults() {
v := card.DefaultCard()
cc.mutation.SetCard(v)
}
if _, ok := cc.mutation.Skill(); !ok {
v := card.DefaultSkill()
cc.mutation.SetSkill(v)
}
if _, ok := cc.mutation.Status(); !ok {
v := card.DefaultStatus()
cc.mutation.SetStatus(v)
@ -161,6 +227,14 @@ func (cc *CardCreate) defaults() {
// check runs all checks and user-defined validators on the builder.
func (cc *CardCreate) check() error {
if _, ok := cc.mutation.Password(); !ok {
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Card.password"`)}
}
if v, ok := cc.mutation.Password(); ok {
if err := card.PasswordValidator(v); err != nil {
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Card.password": %w`, err)}
}
}
if _, ok := cc.mutation.OwnerID(); !ok {
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Card.owner"`)}
}
@ -190,14 +264,26 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
_node = &Card{config: cc.config}
_spec = sqlgraph.NewCreateSpec(card.Table, sqlgraph.NewFieldSpec(card.FieldID, field.TypeInt))
)
if value, ok := cc.mutation.Password(); ok {
_spec.SetField(card.FieldPassword, field.TypeString, value)
_node.Password = value
}
if value, ok := cc.mutation.Card(); ok {
_spec.SetField(card.FieldCard, field.TypeInt, value)
_node.Card = value
}
if value, ok := cc.mutation.Skill(); ok {
_spec.SetField(card.FieldSkill, field.TypeString, value)
_node.Skill = value
}
if value, ok := cc.mutation.Status(); ok {
_spec.SetField(card.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := cc.mutation.Token(); ok {
_spec.SetField(card.FieldToken, field.TypeString, value)
_node.Token = value
}
if value, ok := cc.mutation.Cp(); ok {
_spec.SetField(card.FieldCp, field.TypeInt, value)
_node.Cp = value
@ -206,6 +292,14 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
_spec.SetField(card.FieldURL, field.TypeString, value)
_node.URL = value
}
if value, ok := cc.mutation.Count(); ok {
_spec.SetField(card.FieldCount, field.TypeInt, value)
_node.Count = value
}
if value, ok := cc.mutation.Author(); ok {
_spec.SetField(card.FieldAuthor, field.TypeString, value)
_node.Author = value
}
if value, ok := cc.mutation.CreatedAt(); ok {
_spec.SetField(card.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
@ -218,10 +312,7 @@ func (cc *CardCreate) createSpec() (*Card, *sqlgraph.CreateSpec) {
Columns: []string{card.OwnerColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: &sqlgraph.FieldSpec{
Type: field.TypeInt,
Column: user.FieldID,
},
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
},
}
for _, k := range nodes {
@ -257,8 +348,8 @@ func (ccb *CardCreateBulk) Save(ctx context.Context) ([]*Card, error) {
return nil, err
}
builder.mutation = mutation
nodes[i], specs[i] = builder.createSpec()
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
} else {