update schema

This commit is contained in:
alteredCoder 2021-10-26 15:50:24 +02:00
parent d50ea5f994
commit 42a57e0a5f
6 changed files with 59 additions and 5 deletions

View file

@ -391,6 +391,20 @@ func LastPushLTE(v time.Time) predicate.Machine {
})
}
// LastPushIsNil applies the IsNil predicate on the "last_push" field.
func LastPushIsNil() predicate.Machine {
return predicate.Machine(func(s *sql.Selector) {
s.Where(sql.IsNull(s.C(FieldLastPush)))
})
}
// LastPushNotNil applies the NotNil predicate on the "last_push" field.
func LastPushNotNil() predicate.Machine {
return predicate.Machine(func(s *sql.Selector) {
s.Where(sql.NotNull(s.C(FieldLastPush)))
})
}
// MachineIdEQ applies the EQ predicate on the "machineId" field.
func MachineIdEQ(v string) predicate.Machine {
return predicate.Machine(func(s *sql.Selector) {

View file

@ -249,9 +249,6 @@ func (mc *MachineCreate) check() error {
if _, ok := mc.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "updated_at"`)}
}
if _, ok := mc.mutation.LastPush(); !ok {
return &ValidationError{Name: "last_push", err: errors.New("ent: missing required field \"last_push\"")}
}
if _, ok := mc.mutation.MachineId(); !ok {
return &ValidationError{Name: "machineId", err: errors.New(`ent: missing required field "machineId"`)}
}

View file

@ -70,6 +70,12 @@ func (mu *MachineUpdate) SetNillableLastPush(t *time.Time) *MachineUpdate {
return mu
}
// ClearLastPush clears the value of the "last_push" field.
func (mu *MachineUpdate) ClearLastPush() *MachineUpdate {
mu.mutation.ClearLastPush()
return mu
}
// SetMachineId sets the "machineId" field.
func (mu *MachineUpdate) SetMachineId(s string) *MachineUpdate {
mu.mutation.SetMachineId(s)
@ -312,6 +318,12 @@ func (mu *MachineUpdate) sqlSave(ctx context.Context) (n int, err error) {
Column: machine.FieldLastPush,
})
}
if mu.mutation.LastPushCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: machine.FieldLastPush,
})
}
if value, ok := mu.mutation.MachineId(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,
@ -494,6 +506,12 @@ func (muo *MachineUpdateOne) SetNillableLastPush(t *time.Time) *MachineUpdateOne
return muo
}
// ClearLastPush clears the value of the "last_push" field.
func (muo *MachineUpdateOne) ClearLastPush() *MachineUpdateOne {
muo.mutation.ClearLastPush()
return muo
}
// SetMachineId sets the "machineId" field.
func (muo *MachineUpdateOne) SetMachineId(s string) *MachineUpdateOne {
muo.mutation.SetMachineId(s)
@ -760,6 +778,12 @@ func (muo *MachineUpdateOne) sqlSave(ctx context.Context) (_node *Machine, err e
Column: machine.FieldLastPush,
})
}
if muo.mutation.LastPushCleared() {
_spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{
Type: field.TypeTime,
Column: machine.FieldLastPush,
})
}
if value, ok := muo.mutation.MachineId(); ok {
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
Type: field.TypeString,

View file

@ -137,7 +137,7 @@ var (
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "last_push", Type: field.TypeTime},
{Name: "last_push", Type: field.TypeTime, Nullable: true},
{Name: "machine_id", Type: field.TypeString, Unique: true},
{Name: "password", Type: field.TypeString},
{Name: "ip_address", Type: field.TypeString},

View file

@ -5185,9 +5185,22 @@ func (m *MachineMutation) OldLastPush(ctx context.Context) (v time.Time, err err
return oldValue.LastPush, nil
}
// ClearLastPush clears the value of the "last_push" field.
func (m *MachineMutation) ClearLastPush() {
m.last_push = nil
m.clearedFields[machine.FieldLastPush] = struct{}{}
}
// LastPushCleared returns if the "last_push" field was cleared in this mutation.
func (m *MachineMutation) LastPushCleared() bool {
_, ok := m.clearedFields[machine.FieldLastPush]
return ok
}
// ResetLastPush resets all changes to the "last_push" field.
func (m *MachineMutation) ResetLastPush() {
m.last_push = nil
delete(m.clearedFields, machine.FieldLastPush)
}
// SetMachineId sets the "machineId" field.
@ -5751,6 +5764,9 @@ func (m *MachineMutation) AddField(name string, value ent.Value) error {
// mutation.
func (m *MachineMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(machine.FieldLastPush) {
fields = append(fields, machine.FieldLastPush)
}
if m.FieldCleared(machine.FieldScenarios) {
fields = append(fields, machine.FieldScenarios)
}
@ -5774,6 +5790,9 @@ func (m *MachineMutation) FieldCleared(name string) bool {
// error if the field is not defined in the schema.
func (m *MachineMutation) ClearField(name string) error {
switch name {
case machine.FieldLastPush:
m.ClearLastPush()
return nil
case machine.FieldScenarios:
m.ClearScenarios()
return nil

View file

@ -21,7 +21,7 @@ func (Machine) Fields() []ent.Field {
field.Time("updated_at").
Default(time.Now),
field.Time("last_push").
Default(time.Now),
Default(time.Now).Optional(),
field.String("machineId").Unique(),
field.String("password").Sensitive(),
field.String("ipAddress"),