update schema
This commit is contained in:
parent
d50ea5f994
commit
42a57e0a5f
6 changed files with 59 additions and 5 deletions
|
@ -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.
|
// MachineIdEQ applies the EQ predicate on the "machineId" field.
|
||||||
func MachineIdEQ(v string) predicate.Machine {
|
func MachineIdEQ(v string) predicate.Machine {
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
|
|
|
@ -249,9 +249,6 @@ func (mc *MachineCreate) check() error {
|
||||||
if _, ok := mc.mutation.UpdatedAt(); !ok {
|
if _, ok := mc.mutation.UpdatedAt(); !ok {
|
||||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "updated_at"`)}
|
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 {
|
if _, ok := mc.mutation.MachineId(); !ok {
|
||||||
return &ValidationError{Name: "machineId", err: errors.New(`ent: missing required field "machineId"`)}
|
return &ValidationError{Name: "machineId", err: errors.New(`ent: missing required field "machineId"`)}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,12 @@ func (mu *MachineUpdate) SetNillableLastPush(t *time.Time) *MachineUpdate {
|
||||||
return mu
|
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.
|
// SetMachineId sets the "machineId" field.
|
||||||
func (mu *MachineUpdate) SetMachineId(s string) *MachineUpdate {
|
func (mu *MachineUpdate) SetMachineId(s string) *MachineUpdate {
|
||||||
mu.mutation.SetMachineId(s)
|
mu.mutation.SetMachineId(s)
|
||||||
|
@ -312,6 +318,12 @@ func (mu *MachineUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
Column: machine.FieldLastPush,
|
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 {
|
if value, ok := mu.mutation.MachineId(); ok {
|
||||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
|
@ -494,6 +506,12 @@ func (muo *MachineUpdateOne) SetNillableLastPush(t *time.Time) *MachineUpdateOne
|
||||||
return muo
|
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.
|
// SetMachineId sets the "machineId" field.
|
||||||
func (muo *MachineUpdateOne) SetMachineId(s string) *MachineUpdateOne {
|
func (muo *MachineUpdateOne) SetMachineId(s string) *MachineUpdateOne {
|
||||||
muo.mutation.SetMachineId(s)
|
muo.mutation.SetMachineId(s)
|
||||||
|
@ -760,6 +778,12 @@ func (muo *MachineUpdateOne) sqlSave(ctx context.Context) (_node *Machine, err e
|
||||||
Column: machine.FieldLastPush,
|
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 {
|
if value, ok := muo.mutation.MachineId(); ok {
|
||||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||||
Type: field.TypeString,
|
Type: field.TypeString,
|
||||||
|
|
|
@ -137,7 +137,7 @@ var (
|
||||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
{Name: "created_at", Type: field.TypeTime},
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
{Name: "updated_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: "machine_id", Type: field.TypeString, Unique: true},
|
||||||
{Name: "password", Type: field.TypeString},
|
{Name: "password", Type: field.TypeString},
|
||||||
{Name: "ip_address", Type: field.TypeString},
|
{Name: "ip_address", Type: field.TypeString},
|
||||||
|
|
|
@ -5185,9 +5185,22 @@ func (m *MachineMutation) OldLastPush(ctx context.Context) (v time.Time, err err
|
||||||
return oldValue.LastPush, nil
|
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.
|
// ResetLastPush resets all changes to the "last_push" field.
|
||||||
func (m *MachineMutation) ResetLastPush() {
|
func (m *MachineMutation) ResetLastPush() {
|
||||||
m.last_push = nil
|
m.last_push = nil
|
||||||
|
delete(m.clearedFields, machine.FieldLastPush)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMachineId sets the "machineId" field.
|
// SetMachineId sets the "machineId" field.
|
||||||
|
@ -5751,6 +5764,9 @@ func (m *MachineMutation) AddField(name string, value ent.Value) error {
|
||||||
// mutation.
|
// mutation.
|
||||||
func (m *MachineMutation) ClearedFields() []string {
|
func (m *MachineMutation) ClearedFields() []string {
|
||||||
var fields []string
|
var fields []string
|
||||||
|
if m.FieldCleared(machine.FieldLastPush) {
|
||||||
|
fields = append(fields, machine.FieldLastPush)
|
||||||
|
}
|
||||||
if m.FieldCleared(machine.FieldScenarios) {
|
if m.FieldCleared(machine.FieldScenarios) {
|
||||||
fields = append(fields, 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.
|
// error if the field is not defined in the schema.
|
||||||
func (m *MachineMutation) ClearField(name string) error {
|
func (m *MachineMutation) ClearField(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
|
case machine.FieldLastPush:
|
||||||
|
m.ClearLastPush()
|
||||||
|
return nil
|
||||||
case machine.FieldScenarios:
|
case machine.FieldScenarios:
|
||||||
m.ClearScenarios()
|
m.ClearScenarios()
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -21,7 +21,7 @@ func (Machine) Fields() []ent.Field {
|
||||||
field.Time("updated_at").
|
field.Time("updated_at").
|
||||||
Default(time.Now),
|
Default(time.Now),
|
||||||
field.Time("last_push").
|
field.Time("last_push").
|
||||||
Default(time.Now),
|
Default(time.Now).Optional(),
|
||||||
field.String("machineId").Unique(),
|
field.String("machineId").Unique(),
|
||||||
field.String("password").Sensitive(),
|
field.String("password").Sensitive(),
|
||||||
field.String("ipAddress"),
|
field.String("ipAddress"),
|
||||||
|
|
Loading…
Reference in a new issue