db: mark immutable columns / remove unused (#3024)

* db: mark immutable columns

* db: drop unused column

* lint
This commit is contained in:
mmetc 2024-05-31 15:19:48 +02:00 committed by GitHub
parent 02e2c8aed7
commit 6dbc5fd522
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 54 additions and 2236 deletions

File diff suppressed because it is too large Load diff

View file

@ -33,8 +33,6 @@ type Bouncer struct {
Type string `json:"type"`
// Version holds the value of the "version" field.
Version string `json:"version"`
// Until holds the value of the "until" field.
Until time.Time `json:"until"`
// LastPull holds the value of the "last_pull" field.
LastPull time.Time `json:"last_pull"`
// AuthType holds the value of the "auth_type" field.
@ -53,7 +51,7 @@ func (*Bouncer) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullInt64)
case bouncer.FieldName, bouncer.FieldAPIKey, bouncer.FieldIPAddress, bouncer.FieldType, bouncer.FieldVersion, bouncer.FieldAuthType:
values[i] = new(sql.NullString)
case bouncer.FieldCreatedAt, bouncer.FieldUpdatedAt, bouncer.FieldUntil, bouncer.FieldLastPull:
case bouncer.FieldCreatedAt, bouncer.FieldUpdatedAt, bouncer.FieldLastPull:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
@ -124,12 +122,6 @@ func (b *Bouncer) assignValues(columns []string, values []any) error {
} else if value.Valid {
b.Version = value.String
}
case bouncer.FieldUntil:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field until", values[i])
} else if value.Valid {
b.Until = value.Time
}
case bouncer.FieldLastPull:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field last_pull", values[i])
@ -201,9 +193,6 @@ func (b *Bouncer) String() string {
builder.WriteString("version=")
builder.WriteString(b.Version)
builder.WriteString(", ")
builder.WriteString("until=")
builder.WriteString(b.Until.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("last_pull=")
builder.WriteString(b.LastPull.Format(time.ANSIC))
builder.WriteString(", ")

View file

@ -29,8 +29,6 @@ const (
FieldType = "type"
// FieldVersion holds the string denoting the version field in the database.
FieldVersion = "version"
// FieldUntil holds the string denoting the until field in the database.
FieldUntil = "until"
// FieldLastPull holds the string denoting the last_pull field in the database.
FieldLastPull = "last_pull"
// FieldAuthType holds the string denoting the auth_type field in the database.
@ -50,7 +48,6 @@ var Columns = []string{
FieldIPAddress,
FieldType,
FieldVersion,
FieldUntil,
FieldLastPull,
FieldAuthType,
}
@ -74,8 +71,6 @@ var (
UpdateDefaultUpdatedAt func() time.Time
// DefaultIPAddress holds the default value on creation for the "ip_address" field.
DefaultIPAddress string
// DefaultUntil holds the default value on creation for the "until" field.
DefaultUntil func() time.Time
// DefaultLastPull holds the default value on creation for the "last_pull" field.
DefaultLastPull func() time.Time
// DefaultAuthType holds the default value on creation for the "auth_type" field.
@ -130,11 +125,6 @@ func ByVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVersion, opts...).ToFunc()
}
// ByUntil orders the results by the until field.
func ByUntil(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUntil, opts...).ToFunc()
}
// ByLastPull orders the results by the last_pull field.
func ByLastPull(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLastPull, opts...).ToFunc()

View file

@ -94,11 +94,6 @@ func Version(v string) predicate.Bouncer {
return predicate.Bouncer(sql.FieldEQ(FieldVersion, v))
}
// Until applies equality check predicate on the "until" field. It's identical to UntilEQ.
func Until(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldEQ(FieldUntil, v))
}
// LastPull applies equality check predicate on the "last_pull" field. It's identical to LastPullEQ.
func LastPull(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldEQ(FieldLastPull, v))
@ -554,56 +549,6 @@ func VersionContainsFold(v string) predicate.Bouncer {
return predicate.Bouncer(sql.FieldContainsFold(FieldVersion, v))
}
// UntilEQ applies the EQ predicate on the "until" field.
func UntilEQ(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldEQ(FieldUntil, v))
}
// UntilNEQ applies the NEQ predicate on the "until" field.
func UntilNEQ(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldNEQ(FieldUntil, v))
}
// UntilIn applies the In predicate on the "until" field.
func UntilIn(vs ...time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldIn(FieldUntil, vs...))
}
// UntilNotIn applies the NotIn predicate on the "until" field.
func UntilNotIn(vs ...time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldNotIn(FieldUntil, vs...))
}
// UntilGT applies the GT predicate on the "until" field.
func UntilGT(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldGT(FieldUntil, v))
}
// UntilGTE applies the GTE predicate on the "until" field.
func UntilGTE(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldGTE(FieldUntil, v))
}
// UntilLT applies the LT predicate on the "until" field.
func UntilLT(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldLT(FieldUntil, v))
}
// UntilLTE applies the LTE predicate on the "until" field.
func UntilLTE(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldLTE(FieldUntil, v))
}
// UntilIsNil applies the IsNil predicate on the "until" field.
func UntilIsNil() predicate.Bouncer {
return predicate.Bouncer(sql.FieldIsNull(FieldUntil))
}
// UntilNotNil applies the NotNil predicate on the "until" field.
func UntilNotNil() predicate.Bouncer {
return predicate.Bouncer(sql.FieldNotNull(FieldUntil))
}
// LastPullEQ applies the EQ predicate on the "last_pull" field.
func LastPullEQ(v time.Time) predicate.Bouncer {
return predicate.Bouncer(sql.FieldEQ(FieldLastPull, v))

View file

@ -108,20 +108,6 @@ func (bc *BouncerCreate) SetNillableVersion(s *string) *BouncerCreate {
return bc
}
// SetUntil sets the "until" field.
func (bc *BouncerCreate) SetUntil(t time.Time) *BouncerCreate {
bc.mutation.SetUntil(t)
return bc
}
// SetNillableUntil sets the "until" field if the given value is not nil.
func (bc *BouncerCreate) SetNillableUntil(t *time.Time) *BouncerCreate {
if t != nil {
bc.SetUntil(*t)
}
return bc
}
// SetLastPull sets the "last_pull" field.
func (bc *BouncerCreate) SetLastPull(t time.Time) *BouncerCreate {
bc.mutation.SetLastPull(t)
@ -197,10 +183,6 @@ func (bc *BouncerCreate) defaults() {
v := bouncer.DefaultIPAddress
bc.mutation.SetIPAddress(v)
}
if _, ok := bc.mutation.Until(); !ok {
v := bouncer.DefaultUntil()
bc.mutation.SetUntil(v)
}
if _, ok := bc.mutation.LastPull(); !ok {
v := bouncer.DefaultLastPull()
bc.mutation.SetLastPull(v)
@ -292,10 +274,6 @@ func (bc *BouncerCreate) createSpec() (*Bouncer, *sqlgraph.CreateSpec) {
_spec.SetField(bouncer.FieldVersion, field.TypeString, value)
_node.Version = value
}
if value, ok := bc.mutation.Until(); ok {
_spec.SetField(bouncer.FieldUntil, field.TypeTime, value)
_node.Until = value
}
if value, ok := bc.mutation.LastPull(); ok {
_spec.SetField(bouncer.FieldLastPull, field.TypeTime, value)
_node.LastPull = value

View file

@ -28,40 +28,12 @@ func (bu *BouncerUpdate) Where(ps ...predicate.Bouncer) *BouncerUpdate {
return bu
}
// SetCreatedAt sets the "created_at" field.
func (bu *BouncerUpdate) SetCreatedAt(t time.Time) *BouncerUpdate {
bu.mutation.SetCreatedAt(t)
return bu
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (bu *BouncerUpdate) SetNillableCreatedAt(t *time.Time) *BouncerUpdate {
if t != nil {
bu.SetCreatedAt(*t)
}
return bu
}
// SetUpdatedAt sets the "updated_at" field.
func (bu *BouncerUpdate) SetUpdatedAt(t time.Time) *BouncerUpdate {
bu.mutation.SetUpdatedAt(t)
return bu
}
// SetName sets the "name" field.
func (bu *BouncerUpdate) SetName(s string) *BouncerUpdate {
bu.mutation.SetName(s)
return bu
}
// SetNillableName sets the "name" field if the given value is not nil.
func (bu *BouncerUpdate) SetNillableName(s *string) *BouncerUpdate {
if s != nil {
bu.SetName(*s)
}
return bu
}
// SetAPIKey sets the "api_key" field.
func (bu *BouncerUpdate) SetAPIKey(s string) *BouncerUpdate {
bu.mutation.SetAPIKey(s)
@ -150,26 +122,6 @@ func (bu *BouncerUpdate) ClearVersion() *BouncerUpdate {
return bu
}
// SetUntil sets the "until" field.
func (bu *BouncerUpdate) SetUntil(t time.Time) *BouncerUpdate {
bu.mutation.SetUntil(t)
return bu
}
// SetNillableUntil sets the "until" field if the given value is not nil.
func (bu *BouncerUpdate) SetNillableUntil(t *time.Time) *BouncerUpdate {
if t != nil {
bu.SetUntil(*t)
}
return bu
}
// ClearUntil clears the value of the "until" field.
func (bu *BouncerUpdate) ClearUntil() *BouncerUpdate {
bu.mutation.ClearUntil()
return bu
}
// SetLastPull sets the "last_pull" field.
func (bu *BouncerUpdate) SetLastPull(t time.Time) *BouncerUpdate {
bu.mutation.SetLastPull(t)
@ -248,15 +200,9 @@ func (bu *BouncerUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
}
if value, ok := bu.mutation.CreatedAt(); ok {
_spec.SetField(bouncer.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := bu.mutation.UpdatedAt(); ok {
_spec.SetField(bouncer.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := bu.mutation.Name(); ok {
_spec.SetField(bouncer.FieldName, field.TypeString, value)
}
if value, ok := bu.mutation.APIKey(); ok {
_spec.SetField(bouncer.FieldAPIKey, field.TypeString, value)
}
@ -281,12 +227,6 @@ func (bu *BouncerUpdate) sqlSave(ctx context.Context) (n int, err error) {
if bu.mutation.VersionCleared() {
_spec.ClearField(bouncer.FieldVersion, field.TypeString)
}
if value, ok := bu.mutation.Until(); ok {
_spec.SetField(bouncer.FieldUntil, field.TypeTime, value)
}
if bu.mutation.UntilCleared() {
_spec.ClearField(bouncer.FieldUntil, field.TypeTime)
}
if value, ok := bu.mutation.LastPull(); ok {
_spec.SetField(bouncer.FieldLastPull, field.TypeTime, value)
}
@ -313,40 +253,12 @@ type BouncerUpdateOne struct {
mutation *BouncerMutation
}
// SetCreatedAt sets the "created_at" field.
func (buo *BouncerUpdateOne) SetCreatedAt(t time.Time) *BouncerUpdateOne {
buo.mutation.SetCreatedAt(t)
return buo
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (buo *BouncerUpdateOne) SetNillableCreatedAt(t *time.Time) *BouncerUpdateOne {
if t != nil {
buo.SetCreatedAt(*t)
}
return buo
}
// SetUpdatedAt sets the "updated_at" field.
func (buo *BouncerUpdateOne) SetUpdatedAt(t time.Time) *BouncerUpdateOne {
buo.mutation.SetUpdatedAt(t)
return buo
}
// SetName sets the "name" field.
func (buo *BouncerUpdateOne) SetName(s string) *BouncerUpdateOne {
buo.mutation.SetName(s)
return buo
}
// SetNillableName sets the "name" field if the given value is not nil.
func (buo *BouncerUpdateOne) SetNillableName(s *string) *BouncerUpdateOne {
if s != nil {
buo.SetName(*s)
}
return buo
}
// SetAPIKey sets the "api_key" field.
func (buo *BouncerUpdateOne) SetAPIKey(s string) *BouncerUpdateOne {
buo.mutation.SetAPIKey(s)
@ -435,26 +347,6 @@ func (buo *BouncerUpdateOne) ClearVersion() *BouncerUpdateOne {
return buo
}
// SetUntil sets the "until" field.
func (buo *BouncerUpdateOne) SetUntil(t time.Time) *BouncerUpdateOne {
buo.mutation.SetUntil(t)
return buo
}
// SetNillableUntil sets the "until" field if the given value is not nil.
func (buo *BouncerUpdateOne) SetNillableUntil(t *time.Time) *BouncerUpdateOne {
if t != nil {
buo.SetUntil(*t)
}
return buo
}
// ClearUntil clears the value of the "until" field.
func (buo *BouncerUpdateOne) ClearUntil() *BouncerUpdateOne {
buo.mutation.ClearUntil()
return buo
}
// SetLastPull sets the "last_pull" field.
func (buo *BouncerUpdateOne) SetLastPull(t time.Time) *BouncerUpdateOne {
buo.mutation.SetLastPull(t)
@ -563,15 +455,9 @@ func (buo *BouncerUpdateOne) sqlSave(ctx context.Context) (_node *Bouncer, err e
}
}
}
if value, ok := buo.mutation.CreatedAt(); ok {
_spec.SetField(bouncer.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := buo.mutation.UpdatedAt(); ok {
_spec.SetField(bouncer.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := buo.mutation.Name(); ok {
_spec.SetField(bouncer.FieldName, field.TypeString, value)
}
if value, ok := buo.mutation.APIKey(); ok {
_spec.SetField(bouncer.FieldAPIKey, field.TypeString, value)
}
@ -596,12 +482,6 @@ func (buo *BouncerUpdateOne) sqlSave(ctx context.Context) (_node *Bouncer, err e
if buo.mutation.VersionCleared() {
_spec.ClearField(bouncer.FieldVersion, field.TypeString)
}
if value, ok := buo.mutation.Until(); ok {
_spec.SetField(bouncer.FieldUntil, field.TypeTime, value)
}
if buo.mutation.UntilCleared() {
_spec.ClearField(bouncer.FieldUntil, field.TypeTime)
}
if value, ok := buo.mutation.LastPull(); ok {
_spec.SetField(bouncer.FieldLastPull, field.TypeTime, value)
}

View file

@ -34,20 +34,6 @@ func (ciu *ConfigItemUpdate) SetUpdatedAt(t time.Time) *ConfigItemUpdate {
return ciu
}
// SetName sets the "name" field.
func (ciu *ConfigItemUpdate) SetName(s string) *ConfigItemUpdate {
ciu.mutation.SetName(s)
return ciu
}
// SetNillableName sets the "name" field if the given value is not nil.
func (ciu *ConfigItemUpdate) SetNillableName(s *string) *ConfigItemUpdate {
if s != nil {
ciu.SetName(*s)
}
return ciu
}
// SetValue sets the "value" field.
func (ciu *ConfigItemUpdate) SetValue(s string) *ConfigItemUpdate {
ciu.mutation.SetValue(s)
@ -115,9 +101,6 @@ func (ciu *ConfigItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := ciu.mutation.UpdatedAt(); ok {
_spec.SetField(configitem.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := ciu.mutation.Name(); ok {
_spec.SetField(configitem.FieldName, field.TypeString, value)
}
if value, ok := ciu.mutation.Value(); ok {
_spec.SetField(configitem.FieldValue, field.TypeString, value)
}
@ -147,20 +130,6 @@ func (ciuo *ConfigItemUpdateOne) SetUpdatedAt(t time.Time) *ConfigItemUpdateOne
return ciuo
}
// SetName sets the "name" field.
func (ciuo *ConfigItemUpdateOne) SetName(s string) *ConfigItemUpdateOne {
ciuo.mutation.SetName(s)
return ciuo
}
// SetNillableName sets the "name" field if the given value is not nil.
func (ciuo *ConfigItemUpdateOne) SetNillableName(s *string) *ConfigItemUpdateOne {
if s != nil {
ciuo.SetName(*s)
}
return ciuo
}
// SetValue sets the "value" field.
func (ciuo *ConfigItemUpdateOne) SetValue(s string) *ConfigItemUpdateOne {
ciuo.mutation.SetValue(s)
@ -258,9 +227,6 @@ func (ciuo *ConfigItemUpdateOne) sqlSave(ctx context.Context) (_node *ConfigItem
if value, ok := ciuo.mutation.UpdatedAt(); ok {
_spec.SetField(configitem.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := ciuo.mutation.Name(); ok {
_spec.SetField(configitem.FieldName, field.TypeString, value)
}
if value, ok := ciuo.mutation.Value(); ok {
_spec.SetField(configitem.FieldValue, field.TypeString, value)
}

View file

@ -55,245 +55,6 @@ func (du *DecisionUpdate) ClearUntil() *DecisionUpdate {
return du
}
// SetScenario sets the "scenario" field.
func (du *DecisionUpdate) SetScenario(s string) *DecisionUpdate {
du.mutation.SetScenario(s)
return du
}
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableScenario(s *string) *DecisionUpdate {
if s != nil {
du.SetScenario(*s)
}
return du
}
// SetType sets the "type" field.
func (du *DecisionUpdate) SetType(s string) *DecisionUpdate {
du.mutation.SetType(s)
return du
}
// SetNillableType sets the "type" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableType(s *string) *DecisionUpdate {
if s != nil {
du.SetType(*s)
}
return du
}
// SetStartIP sets the "start_ip" field.
func (du *DecisionUpdate) SetStartIP(i int64) *DecisionUpdate {
du.mutation.ResetStartIP()
du.mutation.SetStartIP(i)
return du
}
// SetNillableStartIP sets the "start_ip" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableStartIP(i *int64) *DecisionUpdate {
if i != nil {
du.SetStartIP(*i)
}
return du
}
// AddStartIP adds i to the "start_ip" field.
func (du *DecisionUpdate) AddStartIP(i int64) *DecisionUpdate {
du.mutation.AddStartIP(i)
return du
}
// ClearStartIP clears the value of the "start_ip" field.
func (du *DecisionUpdate) ClearStartIP() *DecisionUpdate {
du.mutation.ClearStartIP()
return du
}
// SetEndIP sets the "end_ip" field.
func (du *DecisionUpdate) SetEndIP(i int64) *DecisionUpdate {
du.mutation.ResetEndIP()
du.mutation.SetEndIP(i)
return du
}
// SetNillableEndIP sets the "end_ip" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableEndIP(i *int64) *DecisionUpdate {
if i != nil {
du.SetEndIP(*i)
}
return du
}
// AddEndIP adds i to the "end_ip" field.
func (du *DecisionUpdate) AddEndIP(i int64) *DecisionUpdate {
du.mutation.AddEndIP(i)
return du
}
// ClearEndIP clears the value of the "end_ip" field.
func (du *DecisionUpdate) ClearEndIP() *DecisionUpdate {
du.mutation.ClearEndIP()
return du
}
// SetStartSuffix sets the "start_suffix" field.
func (du *DecisionUpdate) SetStartSuffix(i int64) *DecisionUpdate {
du.mutation.ResetStartSuffix()
du.mutation.SetStartSuffix(i)
return du
}
// SetNillableStartSuffix sets the "start_suffix" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableStartSuffix(i *int64) *DecisionUpdate {
if i != nil {
du.SetStartSuffix(*i)
}
return du
}
// AddStartSuffix adds i to the "start_suffix" field.
func (du *DecisionUpdate) AddStartSuffix(i int64) *DecisionUpdate {
du.mutation.AddStartSuffix(i)
return du
}
// ClearStartSuffix clears the value of the "start_suffix" field.
func (du *DecisionUpdate) ClearStartSuffix() *DecisionUpdate {
du.mutation.ClearStartSuffix()
return du
}
// SetEndSuffix sets the "end_suffix" field.
func (du *DecisionUpdate) SetEndSuffix(i int64) *DecisionUpdate {
du.mutation.ResetEndSuffix()
du.mutation.SetEndSuffix(i)
return du
}
// SetNillableEndSuffix sets the "end_suffix" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableEndSuffix(i *int64) *DecisionUpdate {
if i != nil {
du.SetEndSuffix(*i)
}
return du
}
// AddEndSuffix adds i to the "end_suffix" field.
func (du *DecisionUpdate) AddEndSuffix(i int64) *DecisionUpdate {
du.mutation.AddEndSuffix(i)
return du
}
// ClearEndSuffix clears the value of the "end_suffix" field.
func (du *DecisionUpdate) ClearEndSuffix() *DecisionUpdate {
du.mutation.ClearEndSuffix()
return du
}
// SetIPSize sets the "ip_size" field.
func (du *DecisionUpdate) SetIPSize(i int64) *DecisionUpdate {
du.mutation.ResetIPSize()
du.mutation.SetIPSize(i)
return du
}
// SetNillableIPSize sets the "ip_size" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableIPSize(i *int64) *DecisionUpdate {
if i != nil {
du.SetIPSize(*i)
}
return du
}
// AddIPSize adds i to the "ip_size" field.
func (du *DecisionUpdate) AddIPSize(i int64) *DecisionUpdate {
du.mutation.AddIPSize(i)
return du
}
// ClearIPSize clears the value of the "ip_size" field.
func (du *DecisionUpdate) ClearIPSize() *DecisionUpdate {
du.mutation.ClearIPSize()
return du
}
// SetScope sets the "scope" field.
func (du *DecisionUpdate) SetScope(s string) *DecisionUpdate {
du.mutation.SetScope(s)
return du
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableScope(s *string) *DecisionUpdate {
if s != nil {
du.SetScope(*s)
}
return du
}
// SetValue sets the "value" field.
func (du *DecisionUpdate) SetValue(s string) *DecisionUpdate {
du.mutation.SetValue(s)
return du
}
// SetNillableValue sets the "value" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableValue(s *string) *DecisionUpdate {
if s != nil {
du.SetValue(*s)
}
return du
}
// SetOrigin sets the "origin" field.
func (du *DecisionUpdate) SetOrigin(s string) *DecisionUpdate {
du.mutation.SetOrigin(s)
return du
}
// SetNillableOrigin sets the "origin" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableOrigin(s *string) *DecisionUpdate {
if s != nil {
du.SetOrigin(*s)
}
return du
}
// SetSimulated sets the "simulated" field.
func (du *DecisionUpdate) SetSimulated(b bool) *DecisionUpdate {
du.mutation.SetSimulated(b)
return du
}
// SetNillableSimulated sets the "simulated" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableSimulated(b *bool) *DecisionUpdate {
if b != nil {
du.SetSimulated(*b)
}
return du
}
// SetUUID sets the "uuid" field.
func (du *DecisionUpdate) SetUUID(s string) *DecisionUpdate {
du.mutation.SetUUID(s)
return du
}
// SetNillableUUID sets the "uuid" field if the given value is not nil.
func (du *DecisionUpdate) SetNillableUUID(s *string) *DecisionUpdate {
if s != nil {
du.SetUUID(*s)
}
return du
}
// ClearUUID clears the value of the "uuid" field.
func (du *DecisionUpdate) ClearUUID() *DecisionUpdate {
du.mutation.ClearUUID()
return du
}
// SetAlertDecisions sets the "alert_decisions" field.
func (du *DecisionUpdate) SetAlertDecisions(i int) *DecisionUpdate {
du.mutation.SetAlertDecisions(i)
@ -398,72 +159,21 @@ func (du *DecisionUpdate) sqlSave(ctx context.Context) (n int, err error) {
if du.mutation.UntilCleared() {
_spec.ClearField(decision.FieldUntil, field.TypeTime)
}
if value, ok := du.mutation.Scenario(); ok {
_spec.SetField(decision.FieldScenario, field.TypeString, value)
}
if value, ok := du.mutation.GetType(); ok {
_spec.SetField(decision.FieldType, field.TypeString, value)
}
if value, ok := du.mutation.StartIP(); ok {
_spec.SetField(decision.FieldStartIP, field.TypeInt64, value)
}
if value, ok := du.mutation.AddedStartIP(); ok {
_spec.AddField(decision.FieldStartIP, field.TypeInt64, value)
}
if du.mutation.StartIPCleared() {
_spec.ClearField(decision.FieldStartIP, field.TypeInt64)
}
if value, ok := du.mutation.EndIP(); ok {
_spec.SetField(decision.FieldEndIP, field.TypeInt64, value)
}
if value, ok := du.mutation.AddedEndIP(); ok {
_spec.AddField(decision.FieldEndIP, field.TypeInt64, value)
}
if du.mutation.EndIPCleared() {
_spec.ClearField(decision.FieldEndIP, field.TypeInt64)
}
if value, ok := du.mutation.StartSuffix(); ok {
_spec.SetField(decision.FieldStartSuffix, field.TypeInt64, value)
}
if value, ok := du.mutation.AddedStartSuffix(); ok {
_spec.AddField(decision.FieldStartSuffix, field.TypeInt64, value)
}
if du.mutation.StartSuffixCleared() {
_spec.ClearField(decision.FieldStartSuffix, field.TypeInt64)
}
if value, ok := du.mutation.EndSuffix(); ok {
_spec.SetField(decision.FieldEndSuffix, field.TypeInt64, value)
}
if value, ok := du.mutation.AddedEndSuffix(); ok {
_spec.AddField(decision.FieldEndSuffix, field.TypeInt64, value)
}
if du.mutation.EndSuffixCleared() {
_spec.ClearField(decision.FieldEndSuffix, field.TypeInt64)
}
if value, ok := du.mutation.IPSize(); ok {
_spec.SetField(decision.FieldIPSize, field.TypeInt64, value)
}
if value, ok := du.mutation.AddedIPSize(); ok {
_spec.AddField(decision.FieldIPSize, field.TypeInt64, value)
}
if du.mutation.IPSizeCleared() {
_spec.ClearField(decision.FieldIPSize, field.TypeInt64)
}
if value, ok := du.mutation.Scope(); ok {
_spec.SetField(decision.FieldScope, field.TypeString, value)
}
if value, ok := du.mutation.Value(); ok {
_spec.SetField(decision.FieldValue, field.TypeString, value)
}
if value, ok := du.mutation.Origin(); ok {
_spec.SetField(decision.FieldOrigin, field.TypeString, value)
}
if value, ok := du.mutation.Simulated(); ok {
_spec.SetField(decision.FieldSimulated, field.TypeBool, value)
}
if value, ok := du.mutation.UUID(); ok {
_spec.SetField(decision.FieldUUID, field.TypeString, value)
}
if du.mutation.UUIDCleared() {
_spec.ClearField(decision.FieldUUID, field.TypeString)
}
@ -542,245 +252,6 @@ func (duo *DecisionUpdateOne) ClearUntil() *DecisionUpdateOne {
return duo
}
// SetScenario sets the "scenario" field.
func (duo *DecisionUpdateOne) SetScenario(s string) *DecisionUpdateOne {
duo.mutation.SetScenario(s)
return duo
}
// SetNillableScenario sets the "scenario" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableScenario(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetScenario(*s)
}
return duo
}
// SetType sets the "type" field.
func (duo *DecisionUpdateOne) SetType(s string) *DecisionUpdateOne {
duo.mutation.SetType(s)
return duo
}
// SetNillableType sets the "type" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableType(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetType(*s)
}
return duo
}
// SetStartIP sets the "start_ip" field.
func (duo *DecisionUpdateOne) SetStartIP(i int64) *DecisionUpdateOne {
duo.mutation.ResetStartIP()
duo.mutation.SetStartIP(i)
return duo
}
// SetNillableStartIP sets the "start_ip" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableStartIP(i *int64) *DecisionUpdateOne {
if i != nil {
duo.SetStartIP(*i)
}
return duo
}
// AddStartIP adds i to the "start_ip" field.
func (duo *DecisionUpdateOne) AddStartIP(i int64) *DecisionUpdateOne {
duo.mutation.AddStartIP(i)
return duo
}
// ClearStartIP clears the value of the "start_ip" field.
func (duo *DecisionUpdateOne) ClearStartIP() *DecisionUpdateOne {
duo.mutation.ClearStartIP()
return duo
}
// SetEndIP sets the "end_ip" field.
func (duo *DecisionUpdateOne) SetEndIP(i int64) *DecisionUpdateOne {
duo.mutation.ResetEndIP()
duo.mutation.SetEndIP(i)
return duo
}
// SetNillableEndIP sets the "end_ip" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableEndIP(i *int64) *DecisionUpdateOne {
if i != nil {
duo.SetEndIP(*i)
}
return duo
}
// AddEndIP adds i to the "end_ip" field.
func (duo *DecisionUpdateOne) AddEndIP(i int64) *DecisionUpdateOne {
duo.mutation.AddEndIP(i)
return duo
}
// ClearEndIP clears the value of the "end_ip" field.
func (duo *DecisionUpdateOne) ClearEndIP() *DecisionUpdateOne {
duo.mutation.ClearEndIP()
return duo
}
// SetStartSuffix sets the "start_suffix" field.
func (duo *DecisionUpdateOne) SetStartSuffix(i int64) *DecisionUpdateOne {
duo.mutation.ResetStartSuffix()
duo.mutation.SetStartSuffix(i)
return duo
}
// SetNillableStartSuffix sets the "start_suffix" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableStartSuffix(i *int64) *DecisionUpdateOne {
if i != nil {
duo.SetStartSuffix(*i)
}
return duo
}
// AddStartSuffix adds i to the "start_suffix" field.
func (duo *DecisionUpdateOne) AddStartSuffix(i int64) *DecisionUpdateOne {
duo.mutation.AddStartSuffix(i)
return duo
}
// ClearStartSuffix clears the value of the "start_suffix" field.
func (duo *DecisionUpdateOne) ClearStartSuffix() *DecisionUpdateOne {
duo.mutation.ClearStartSuffix()
return duo
}
// SetEndSuffix sets the "end_suffix" field.
func (duo *DecisionUpdateOne) SetEndSuffix(i int64) *DecisionUpdateOne {
duo.mutation.ResetEndSuffix()
duo.mutation.SetEndSuffix(i)
return duo
}
// SetNillableEndSuffix sets the "end_suffix" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableEndSuffix(i *int64) *DecisionUpdateOne {
if i != nil {
duo.SetEndSuffix(*i)
}
return duo
}
// AddEndSuffix adds i to the "end_suffix" field.
func (duo *DecisionUpdateOne) AddEndSuffix(i int64) *DecisionUpdateOne {
duo.mutation.AddEndSuffix(i)
return duo
}
// ClearEndSuffix clears the value of the "end_suffix" field.
func (duo *DecisionUpdateOne) ClearEndSuffix() *DecisionUpdateOne {
duo.mutation.ClearEndSuffix()
return duo
}
// SetIPSize sets the "ip_size" field.
func (duo *DecisionUpdateOne) SetIPSize(i int64) *DecisionUpdateOne {
duo.mutation.ResetIPSize()
duo.mutation.SetIPSize(i)
return duo
}
// SetNillableIPSize sets the "ip_size" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableIPSize(i *int64) *DecisionUpdateOne {
if i != nil {
duo.SetIPSize(*i)
}
return duo
}
// AddIPSize adds i to the "ip_size" field.
func (duo *DecisionUpdateOne) AddIPSize(i int64) *DecisionUpdateOne {
duo.mutation.AddIPSize(i)
return duo
}
// ClearIPSize clears the value of the "ip_size" field.
func (duo *DecisionUpdateOne) ClearIPSize() *DecisionUpdateOne {
duo.mutation.ClearIPSize()
return duo
}
// SetScope sets the "scope" field.
func (duo *DecisionUpdateOne) SetScope(s string) *DecisionUpdateOne {
duo.mutation.SetScope(s)
return duo
}
// SetNillableScope sets the "scope" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableScope(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetScope(*s)
}
return duo
}
// SetValue sets the "value" field.
func (duo *DecisionUpdateOne) SetValue(s string) *DecisionUpdateOne {
duo.mutation.SetValue(s)
return duo
}
// SetNillableValue sets the "value" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableValue(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetValue(*s)
}
return duo
}
// SetOrigin sets the "origin" field.
func (duo *DecisionUpdateOne) SetOrigin(s string) *DecisionUpdateOne {
duo.mutation.SetOrigin(s)
return duo
}
// SetNillableOrigin sets the "origin" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableOrigin(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetOrigin(*s)
}
return duo
}
// SetSimulated sets the "simulated" field.
func (duo *DecisionUpdateOne) SetSimulated(b bool) *DecisionUpdateOne {
duo.mutation.SetSimulated(b)
return duo
}
// SetNillableSimulated sets the "simulated" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableSimulated(b *bool) *DecisionUpdateOne {
if b != nil {
duo.SetSimulated(*b)
}
return duo
}
// SetUUID sets the "uuid" field.
func (duo *DecisionUpdateOne) SetUUID(s string) *DecisionUpdateOne {
duo.mutation.SetUUID(s)
return duo
}
// SetNillableUUID sets the "uuid" field if the given value is not nil.
func (duo *DecisionUpdateOne) SetNillableUUID(s *string) *DecisionUpdateOne {
if s != nil {
duo.SetUUID(*s)
}
return duo
}
// ClearUUID clears the value of the "uuid" field.
func (duo *DecisionUpdateOne) ClearUUID() *DecisionUpdateOne {
duo.mutation.ClearUUID()
return duo
}
// SetAlertDecisions sets the "alert_decisions" field.
func (duo *DecisionUpdateOne) SetAlertDecisions(i int) *DecisionUpdateOne {
duo.mutation.SetAlertDecisions(i)
@ -915,72 +386,21 @@ func (duo *DecisionUpdateOne) sqlSave(ctx context.Context) (_node *Decision, err
if duo.mutation.UntilCleared() {
_spec.ClearField(decision.FieldUntil, field.TypeTime)
}
if value, ok := duo.mutation.Scenario(); ok {
_spec.SetField(decision.FieldScenario, field.TypeString, value)
}
if value, ok := duo.mutation.GetType(); ok {
_spec.SetField(decision.FieldType, field.TypeString, value)
}
if value, ok := duo.mutation.StartIP(); ok {
_spec.SetField(decision.FieldStartIP, field.TypeInt64, value)
}
if value, ok := duo.mutation.AddedStartIP(); ok {
_spec.AddField(decision.FieldStartIP, field.TypeInt64, value)
}
if duo.mutation.StartIPCleared() {
_spec.ClearField(decision.FieldStartIP, field.TypeInt64)
}
if value, ok := duo.mutation.EndIP(); ok {
_spec.SetField(decision.FieldEndIP, field.TypeInt64, value)
}
if value, ok := duo.mutation.AddedEndIP(); ok {
_spec.AddField(decision.FieldEndIP, field.TypeInt64, value)
}
if duo.mutation.EndIPCleared() {
_spec.ClearField(decision.FieldEndIP, field.TypeInt64)
}
if value, ok := duo.mutation.StartSuffix(); ok {
_spec.SetField(decision.FieldStartSuffix, field.TypeInt64, value)
}
if value, ok := duo.mutation.AddedStartSuffix(); ok {
_spec.AddField(decision.FieldStartSuffix, field.TypeInt64, value)
}
if duo.mutation.StartSuffixCleared() {
_spec.ClearField(decision.FieldStartSuffix, field.TypeInt64)
}
if value, ok := duo.mutation.EndSuffix(); ok {
_spec.SetField(decision.FieldEndSuffix, field.TypeInt64, value)
}
if value, ok := duo.mutation.AddedEndSuffix(); ok {
_spec.AddField(decision.FieldEndSuffix, field.TypeInt64, value)
}
if duo.mutation.EndSuffixCleared() {
_spec.ClearField(decision.FieldEndSuffix, field.TypeInt64)
}
if value, ok := duo.mutation.IPSize(); ok {
_spec.SetField(decision.FieldIPSize, field.TypeInt64, value)
}
if value, ok := duo.mutation.AddedIPSize(); ok {
_spec.AddField(decision.FieldIPSize, field.TypeInt64, value)
}
if duo.mutation.IPSizeCleared() {
_spec.ClearField(decision.FieldIPSize, field.TypeInt64)
}
if value, ok := duo.mutation.Scope(); ok {
_spec.SetField(decision.FieldScope, field.TypeString, value)
}
if value, ok := duo.mutation.Value(); ok {
_spec.SetField(decision.FieldValue, field.TypeString, value)
}
if value, ok := duo.mutation.Origin(); ok {
_spec.SetField(decision.FieldOrigin, field.TypeString, value)
}
if value, ok := duo.mutation.Simulated(); ok {
_spec.SetField(decision.FieldSimulated, field.TypeBool, value)
}
if value, ok := duo.mutation.UUID(); ok {
_spec.SetField(decision.FieldUUID, field.TypeString, value)
}
if duo.mutation.UUIDCleared() {
_spec.ClearField(decision.FieldUUID, field.TypeString)
}

View file

@ -35,34 +35,6 @@ func (eu *EventUpdate) SetUpdatedAt(t time.Time) *EventUpdate {
return eu
}
// SetTime sets the "time" field.
func (eu *EventUpdate) SetTime(t time.Time) *EventUpdate {
eu.mutation.SetTime(t)
return eu
}
// SetNillableTime sets the "time" field if the given value is not nil.
func (eu *EventUpdate) SetNillableTime(t *time.Time) *EventUpdate {
if t != nil {
eu.SetTime(*t)
}
return eu
}
// SetSerialized sets the "serialized" field.
func (eu *EventUpdate) SetSerialized(s string) *EventUpdate {
eu.mutation.SetSerialized(s)
return eu
}
// SetNillableSerialized sets the "serialized" field if the given value is not nil.
func (eu *EventUpdate) SetNillableSerialized(s *string) *EventUpdate {
if s != nil {
eu.SetSerialized(*s)
}
return eu
}
// SetAlertEvents sets the "alert_events" field.
func (eu *EventUpdate) SetAlertEvents(i int) *EventUpdate {
eu.mutation.SetAlertEvents(i)
@ -149,20 +121,7 @@ func (eu *EventUpdate) defaults() {
}
}
// check runs all checks and user-defined validators on the builder.
func (eu *EventUpdate) check() error {
if v, ok := eu.mutation.Serialized(); ok {
if err := event.SerializedValidator(v); err != nil {
return &ValidationError{Name: "serialized", err: fmt.Errorf(`ent: validator failed for field "Event.serialized": %w`, err)}
}
}
return nil
}
func (eu *EventUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := eu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt))
if ps := eu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
@ -174,12 +133,6 @@ func (eu *EventUpdate) sqlSave(ctx context.Context) (n int, err error) {
if value, ok := eu.mutation.UpdatedAt(); ok {
_spec.SetField(event.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := eu.mutation.Time(); ok {
_spec.SetField(event.FieldTime, field.TypeTime, value)
}
if value, ok := eu.mutation.Serialized(); ok {
_spec.SetField(event.FieldSerialized, field.TypeString, value)
}
if eu.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
@ -235,34 +188,6 @@ func (euo *EventUpdateOne) SetUpdatedAt(t time.Time) *EventUpdateOne {
return euo
}
// SetTime sets the "time" field.
func (euo *EventUpdateOne) SetTime(t time.Time) *EventUpdateOne {
euo.mutation.SetTime(t)
return euo
}
// SetNillableTime sets the "time" field if the given value is not nil.
func (euo *EventUpdateOne) SetNillableTime(t *time.Time) *EventUpdateOne {
if t != nil {
euo.SetTime(*t)
}
return euo
}
// SetSerialized sets the "serialized" field.
func (euo *EventUpdateOne) SetSerialized(s string) *EventUpdateOne {
euo.mutation.SetSerialized(s)
return euo
}
// SetNillableSerialized sets the "serialized" field if the given value is not nil.
func (euo *EventUpdateOne) SetNillableSerialized(s *string) *EventUpdateOne {
if s != nil {
euo.SetSerialized(*s)
}
return euo
}
// SetAlertEvents sets the "alert_events" field.
func (euo *EventUpdateOne) SetAlertEvents(i int) *EventUpdateOne {
euo.mutation.SetAlertEvents(i)
@ -362,20 +287,7 @@ func (euo *EventUpdateOne) defaults() {
}
}
// check runs all checks and user-defined validators on the builder.
func (euo *EventUpdateOne) check() error {
if v, ok := euo.mutation.Serialized(); ok {
if err := event.SerializedValidator(v); err != nil {
return &ValidationError{Name: "serialized", err: fmt.Errorf(`ent: validator failed for field "Event.serialized": %w`, err)}
}
}
return nil
}
func (euo *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error) {
if err := euo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeInt))
id, ok := euo.mutation.ID()
if !ok {
@ -404,12 +316,6 @@ func (euo *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error
if value, ok := euo.mutation.UpdatedAt(); ok {
_spec.SetField(event.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := euo.mutation.Time(); ok {
_spec.SetField(event.FieldTime, field.TypeTime, value)
}
if value, ok := euo.mutation.Serialized(); ok {
_spec.SetField(event.FieldSerialized, field.TypeString, value)
}
if euo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,

View file

@ -6,7 +6,6 @@ import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
@ -28,20 +27,6 @@ func (lu *LockUpdate) Where(ps ...predicate.Lock) *LockUpdate {
return lu
}
// SetCreatedAt sets the "created_at" field.
func (lu *LockUpdate) SetCreatedAt(t time.Time) *LockUpdate {
lu.mutation.SetCreatedAt(t)
return lu
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (lu *LockUpdate) SetNillableCreatedAt(t *time.Time) *LockUpdate {
if t != nil {
lu.SetCreatedAt(*t)
}
return lu
}
// Mutation returns the LockMutation object of the builder.
func (lu *LockUpdate) Mutation() *LockMutation {
return lu.mutation
@ -83,9 +68,6 @@ func (lu *LockUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
}
if value, ok := lu.mutation.CreatedAt(); ok {
_spec.SetField(lock.FieldCreatedAt, field.TypeTime, value)
}
if n, err = sqlgraph.UpdateNodes(ctx, lu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{lock.Label}
@ -106,20 +88,6 @@ type LockUpdateOne struct {
mutation *LockMutation
}
// SetCreatedAt sets the "created_at" field.
func (luo *LockUpdateOne) SetCreatedAt(t time.Time) *LockUpdateOne {
luo.mutation.SetCreatedAt(t)
return luo
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (luo *LockUpdateOne) SetNillableCreatedAt(t *time.Time) *LockUpdateOne {
if t != nil {
luo.SetCreatedAt(*t)
}
return luo
}
// Mutation returns the LockMutation object of the builder.
func (luo *LockUpdateOne) Mutation() *LockMutation {
return luo.mutation
@ -191,9 +159,6 @@ func (luo *LockUpdateOne) sqlSave(ctx context.Context) (_node *Lock, err error)
}
}
}
if value, ok := luo.mutation.CreatedAt(); ok {
_spec.SetField(lock.FieldCreatedAt, field.TypeTime, value)
}
_node = &Lock{config: luo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues

View file

@ -29,54 +29,12 @@ func (mu *MetaUpdate) Where(ps ...predicate.Meta) *MetaUpdate {
return mu
}
// SetCreatedAt sets the "created_at" field.
func (mu *MetaUpdate) SetCreatedAt(t time.Time) *MetaUpdate {
mu.mutation.SetCreatedAt(t)
return mu
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (mu *MetaUpdate) SetNillableCreatedAt(t *time.Time) *MetaUpdate {
if t != nil {
mu.SetCreatedAt(*t)
}
return mu
}
// SetUpdatedAt sets the "updated_at" field.
func (mu *MetaUpdate) SetUpdatedAt(t time.Time) *MetaUpdate {
mu.mutation.SetUpdatedAt(t)
return mu
}
// SetKey sets the "key" field.
func (mu *MetaUpdate) SetKey(s string) *MetaUpdate {
mu.mutation.SetKey(s)
return mu
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (mu *MetaUpdate) SetNillableKey(s *string) *MetaUpdate {
if s != nil {
mu.SetKey(*s)
}
return mu
}
// SetValue sets the "value" field.
func (mu *MetaUpdate) SetValue(s string) *MetaUpdate {
mu.mutation.SetValue(s)
return mu
}
// SetNillableValue sets the "value" field if the given value is not nil.
func (mu *MetaUpdate) SetNillableValue(s *string) *MetaUpdate {
if s != nil {
mu.SetValue(*s)
}
return mu
}
// SetAlertMetas sets the "alert_metas" field.
func (mu *MetaUpdate) SetAlertMetas(i int) *MetaUpdate {
mu.mutation.SetAlertMetas(i)
@ -163,20 +121,7 @@ func (mu *MetaUpdate) defaults() {
}
}
// check runs all checks and user-defined validators on the builder.
func (mu *MetaUpdate) check() error {
if v, ok := mu.mutation.Value(); ok {
if err := meta.ValueValidator(v); err != nil {
return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "Meta.value": %w`, err)}
}
}
return nil
}
func (mu *MetaUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := mu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(meta.Table, meta.Columns, sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt))
if ps := mu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
@ -185,18 +130,9 @@ func (mu *MetaUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
}
if value, ok := mu.mutation.CreatedAt(); ok {
_spec.SetField(meta.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := mu.mutation.UpdatedAt(); ok {
_spec.SetField(meta.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := mu.mutation.Key(); ok {
_spec.SetField(meta.FieldKey, field.TypeString, value)
}
if value, ok := mu.mutation.Value(); ok {
_spec.SetField(meta.FieldValue, field.TypeString, value)
}
if mu.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
@ -246,54 +182,12 @@ type MetaUpdateOne struct {
mutation *MetaMutation
}
// SetCreatedAt sets the "created_at" field.
func (muo *MetaUpdateOne) SetCreatedAt(t time.Time) *MetaUpdateOne {
muo.mutation.SetCreatedAt(t)
return muo
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (muo *MetaUpdateOne) SetNillableCreatedAt(t *time.Time) *MetaUpdateOne {
if t != nil {
muo.SetCreatedAt(*t)
}
return muo
}
// SetUpdatedAt sets the "updated_at" field.
func (muo *MetaUpdateOne) SetUpdatedAt(t time.Time) *MetaUpdateOne {
muo.mutation.SetUpdatedAt(t)
return muo
}
// SetKey sets the "key" field.
func (muo *MetaUpdateOne) SetKey(s string) *MetaUpdateOne {
muo.mutation.SetKey(s)
return muo
}
// SetNillableKey sets the "key" field if the given value is not nil.
func (muo *MetaUpdateOne) SetNillableKey(s *string) *MetaUpdateOne {
if s != nil {
muo.SetKey(*s)
}
return muo
}
// SetValue sets the "value" field.
func (muo *MetaUpdateOne) SetValue(s string) *MetaUpdateOne {
muo.mutation.SetValue(s)
return muo
}
// SetNillableValue sets the "value" field if the given value is not nil.
func (muo *MetaUpdateOne) SetNillableValue(s *string) *MetaUpdateOne {
if s != nil {
muo.SetValue(*s)
}
return muo
}
// SetAlertMetas sets the "alert_metas" field.
func (muo *MetaUpdateOne) SetAlertMetas(i int) *MetaUpdateOne {
muo.mutation.SetAlertMetas(i)
@ -393,20 +287,7 @@ func (muo *MetaUpdateOne) defaults() {
}
}
// check runs all checks and user-defined validators on the builder.
func (muo *MetaUpdateOne) check() error {
if v, ok := muo.mutation.Value(); ok {
if err := meta.ValueValidator(v); err != nil {
return &ValidationError{Name: "value", err: fmt.Errorf(`ent: validator failed for field "Meta.value": %w`, err)}
}
}
return nil
}
func (muo *MetaUpdateOne) sqlSave(ctx context.Context) (_node *Meta, err error) {
if err := muo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(meta.Table, meta.Columns, sqlgraph.NewFieldSpec(meta.FieldID, field.TypeInt))
id, ok := muo.mutation.ID()
if !ok {
@ -432,18 +313,9 @@ func (muo *MetaUpdateOne) sqlSave(ctx context.Context) (_node *Meta, err error)
}
}
}
if value, ok := muo.mutation.CreatedAt(); ok {
_spec.SetField(meta.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := muo.mutation.UpdatedAt(); ok {
_spec.SetField(meta.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := muo.mutation.Key(); ok {
_spec.SetField(meta.FieldKey, field.TypeString, value)
}
if value, ok := muo.mutation.Value(); ok {
_spec.SetField(meta.FieldValue, field.TypeString, value)
}
if muo.mutation.OwnerCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,

View file

@ -68,7 +68,6 @@ var (
{Name: "ip_address", Type: field.TypeString, Nullable: true, Default: ""},
{Name: "type", Type: field.TypeString, Nullable: true},
{Name: "version", Type: field.TypeString, Nullable: true},
{Name: "until", Type: field.TypeTime, Nullable: true},
{Name: "last_pull", Type: field.TypeTime},
{Name: "auth_type", Type: field.TypeString, Default: "api-key"},
}

View file

@ -2390,7 +2390,6 @@ type BouncerMutation struct {
ip_address *string
_type *string
version *string
until *time.Time
last_pull *time.Time
auth_type *string
clearedFields map[string]struct{}
@ -2824,55 +2823,6 @@ func (m *BouncerMutation) ResetVersion() {
delete(m.clearedFields, bouncer.FieldVersion)
}
// SetUntil sets the "until" field.
func (m *BouncerMutation) SetUntil(t time.Time) {
m.until = &t
}
// Until returns the value of the "until" field in the mutation.
func (m *BouncerMutation) Until() (r time.Time, exists bool) {
v := m.until
if v == nil {
return
}
return *v, true
}
// OldUntil returns the old "until" field's value of the Bouncer entity.
// If the Bouncer object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *BouncerMutation) OldUntil(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUntil is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUntil requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUntil: %w", err)
}
return oldValue.Until, nil
}
// ClearUntil clears the value of the "until" field.
func (m *BouncerMutation) ClearUntil() {
m.until = nil
m.clearedFields[bouncer.FieldUntil] = struct{}{}
}
// UntilCleared returns if the "until" field was cleared in this mutation.
func (m *BouncerMutation) UntilCleared() bool {
_, ok := m.clearedFields[bouncer.FieldUntil]
return ok
}
// ResetUntil resets all changes to the "until" field.
func (m *BouncerMutation) ResetUntil() {
m.until = nil
delete(m.clearedFields, bouncer.FieldUntil)
}
// SetLastPull sets the "last_pull" field.
func (m *BouncerMutation) SetLastPull(t time.Time) {
m.last_pull = &t
@ -2979,7 +2929,7 @@ func (m *BouncerMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *BouncerMutation) Fields() []string {
fields := make([]string, 0, 11)
fields := make([]string, 0, 10)
if m.created_at != nil {
fields = append(fields, bouncer.FieldCreatedAt)
}
@ -3004,9 +2954,6 @@ func (m *BouncerMutation) Fields() []string {
if m.version != nil {
fields = append(fields, bouncer.FieldVersion)
}
if m.until != nil {
fields = append(fields, bouncer.FieldUntil)
}
if m.last_pull != nil {
fields = append(fields, bouncer.FieldLastPull)
}
@ -3037,8 +2984,6 @@ func (m *BouncerMutation) Field(name string) (ent.Value, bool) {
return m.GetType()
case bouncer.FieldVersion:
return m.Version()
case bouncer.FieldUntil:
return m.Until()
case bouncer.FieldLastPull:
return m.LastPull()
case bouncer.FieldAuthType:
@ -3068,8 +3013,6 @@ func (m *BouncerMutation) OldField(ctx context.Context, name string) (ent.Value,
return m.OldType(ctx)
case bouncer.FieldVersion:
return m.OldVersion(ctx)
case bouncer.FieldUntil:
return m.OldUntil(ctx)
case bouncer.FieldLastPull:
return m.OldLastPull(ctx)
case bouncer.FieldAuthType:
@ -3139,13 +3082,6 @@ func (m *BouncerMutation) SetField(name string, value ent.Value) error {
}
m.SetVersion(v)
return nil
case bouncer.FieldUntil:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUntil(v)
return nil
case bouncer.FieldLastPull:
v, ok := value.(time.Time)
if !ok {
@ -3199,9 +3135,6 @@ func (m *BouncerMutation) ClearedFields() []string {
if m.FieldCleared(bouncer.FieldVersion) {
fields = append(fields, bouncer.FieldVersion)
}
if m.FieldCleared(bouncer.FieldUntil) {
fields = append(fields, bouncer.FieldUntil)
}
return fields
}
@ -3225,9 +3158,6 @@ func (m *BouncerMutation) ClearField(name string) error {
case bouncer.FieldVersion:
m.ClearVersion()
return nil
case bouncer.FieldUntil:
m.ClearUntil()
return nil
}
return fmt.Errorf("unknown Bouncer nullable field %s", name)
}
@ -3260,9 +3190,6 @@ func (m *BouncerMutation) ResetField(name string) error {
case bouncer.FieldVersion:
m.ResetVersion()
return nil
case bouncer.FieldUntil:
m.ResetUntil()
return nil
case bouncer.FieldLastPull:
m.ResetLastPull()
return nil

View file

@ -72,16 +72,12 @@ func init() {
bouncerDescIPAddress := bouncerFields[5].Descriptor()
// bouncer.DefaultIPAddress holds the default value on creation for the ip_address field.
bouncer.DefaultIPAddress = bouncerDescIPAddress.Default.(string)
// bouncerDescUntil is the schema descriptor for until field.
bouncerDescUntil := bouncerFields[8].Descriptor()
// bouncer.DefaultUntil holds the default value on creation for the until field.
bouncer.DefaultUntil = bouncerDescUntil.Default.(func() time.Time)
// bouncerDescLastPull is the schema descriptor for last_pull field.
bouncerDescLastPull := bouncerFields[9].Descriptor()
bouncerDescLastPull := bouncerFields[8].Descriptor()
// bouncer.DefaultLastPull holds the default value on creation for the last_pull field.
bouncer.DefaultLastPull = bouncerDescLastPull.Default.(func() time.Time)
// bouncerDescAuthType is the schema descriptor for auth_type field.
bouncerDescAuthType := bouncerFields[10].Descriptor()
bouncerDescAuthType := bouncerFields[9].Descriptor()
// bouncer.DefaultAuthType holds the default value on creation for the auth_type field.
bouncer.DefaultAuthType = bouncerDescAuthType.Default.(string)
configitemFields := schema.ConfigItem{}.Fields()

View file

@ -6,6 +6,7 @@ import (
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -23,34 +24,34 @@ func (Alert) Fields() []ent.Field {
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow),
field.String("scenario"),
field.String("bucketId").Default("").Optional(),
field.String("message").Default("").Optional(),
field.Int32("eventsCount").Default(0).Optional(),
field.Time("startedAt").Default(types.UtcNow).Optional(),
field.Time("stoppedAt").Default(types.UtcNow).Optional(),
field.String("scenario").Immutable(),
field.String("bucketId").Default("").Optional().Immutable(),
field.String("message").Default("").Optional().Immutable(),
field.Int32("eventsCount").Default(0).Optional().Immutable(),
field.Time("startedAt").Default(types.UtcNow).Optional().Immutable(),
field.Time("stoppedAt").Default(types.UtcNow).Optional().Immutable(),
field.String("sourceIp").
Optional(),
Optional().Immutable(),
field.String("sourceRange").
Optional(),
Optional().Immutable(),
field.String("sourceAsNumber").
Optional(),
Optional().Immutable(),
field.String("sourceAsName").
Optional(),
Optional().Immutable(),
field.String("sourceCountry").
Optional(),
Optional().Immutable(),
field.Float32("sourceLatitude").
Optional(),
Optional().Immutable(),
field.Float32("sourceLongitude").
Optional(),
field.String("sourceScope").Optional(),
field.String("sourceValue").Optional(),
field.Int32("capacity").Optional(),
field.String("leakSpeed").Optional(),
field.String("scenarioVersion").Optional(),
field.String("scenarioHash").Optional(),
field.Bool("simulated").Default(false),
field.String("uuid").Optional(), //this uuid is mostly here to ensure that CAPI/PAPI has a unique id for each alert
Optional().Immutable(),
field.String("sourceScope").Optional().Immutable(),
field.String("sourceValue").Optional().Immutable(),
field.Int32("capacity").Optional().Immutable(),
field.String("leakSpeed").Optional().Immutable(),
field.String("scenarioVersion").Optional().Immutable(),
field.String("scenarioHash").Optional().Immutable(),
field.Bool("simulated").Default(false).Immutable(),
field.String("uuid").Optional().Immutable(), // this uuid is mostly here to ensure that CAPI/PAPI has a unique id for each alert
}
}

View file

@ -3,6 +3,7 @@ package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -16,17 +17,17 @@ func (Bouncer) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(types.UtcNow).
StructTag(`json:"created_at"`),
StructTag(`json:"created_at"`).
Immutable(),
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).StructTag(`json:"updated_at"`),
field.String("name").Unique().StructTag(`json:"name"`),
field.String("name").Unique().StructTag(`json:"name"`).Immutable(),
field.String("api_key").Sensitive(), // hash of api_key
field.Bool("revoked").StructTag(`json:"revoked"`),
field.String("ip_address").Default("").Optional().StructTag(`json:"ip_address"`),
field.String("type").Optional().StructTag(`json:"type"`),
field.String("version").Optional().StructTag(`json:"version"`),
field.Time("until").Default(types.UtcNow).Optional().StructTag(`json:"until"`),
field.Time("last_pull").
Default(types.UtcNow).StructTag(`json:"last_pull"`),
field.String("auth_type").StructTag(`json:"auth_type"`).Default(types.ApiKeyAuthType),

View file

@ -3,6 +3,7 @@ package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -20,7 +21,7 @@ func (ConfigItem) Fields() []ent.Field {
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).StructTag(`json:"updated_at"`),
field.String("name").Unique().StructTag(`json:"name"`),
field.String("name").Unique().StructTag(`json:"name"`).Immutable(),
field.String("value").StructTag(`json:"value"`), // a json object
}
}

View file

@ -6,6 +6,7 @@ import (
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -26,18 +27,18 @@ func (Decision) Fields() []ent.Field {
field.Time("until").Nillable().Optional().SchemaType(map[string]string{
dialect.MySQL: "datetime",
}),
field.String("scenario"),
field.String("type"),
field.Int64("start_ip").Optional(),
field.Int64("end_ip").Optional(),
field.Int64("start_suffix").Optional(),
field.Int64("end_suffix").Optional(),
field.Int64("ip_size").Optional(),
field.String("scope"),
field.String("value"),
field.String("origin"),
field.Bool("simulated").Default(false),
field.String("uuid").Optional(), //this uuid is mostly here to ensure that CAPI/PAPI has a unique id for each decision
field.String("scenario").Immutable(),
field.String("type").Immutable(),
field.Int64("start_ip").Optional().Immutable(),
field.Int64("end_ip").Optional().Immutable(),
field.Int64("start_suffix").Optional().Immutable(),
field.Int64("end_suffix").Optional().Immutable(),
field.Int64("ip_size").Optional().Immutable(),
field.String("scope").Immutable(),
field.String("value").Immutable(),
field.String("origin").Immutable(),
field.Bool("simulated").Default(false).Immutable(),
field.String("uuid").Optional().Immutable(), // this uuid is mostly here to ensure that CAPI/PAPI has a unique id for each decision
field.Int("alert_decisions").Optional(),
}
}

View file

@ -5,6 +5,7 @@ import (
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -22,8 +23,8 @@ func (Event) Fields() []ent.Field {
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow),
field.Time("time"),
field.String("serialized").MaxLen(8191),
field.Time("time").Immutable(),
field.String("serialized").MaxLen(8191).Immutable(),
field.Int("alert_events").Optional(),
}
}

View file

@ -3,6 +3,7 @@ package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -13,7 +14,7 @@ type Lock struct {
func (Lock) Fields() []ent.Field {
return []ent.Field{
field.String("name").Unique().Immutable().StructTag(`json:"name"`),
field.Time("created_at").Default(types.UtcNow).StructTag(`json:"created_at"`),
field.Time("created_at").Default(types.UtcNow).StructTag(`json:"created_at"`).Immutable(),
}
}

View file

@ -5,6 +5,7 @@ import (
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
@ -17,12 +18,12 @@ type Meta struct {
func (Meta) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(types.UtcNow),
Default(types.UtcNow).Immutable(),
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow),
field.String("key"),
field.String("value").MaxLen(4095),
field.String("key").Immutable(),
field.String("value").MaxLen(4095).Immutable(),
field.Int("alert_metas").Optional(),
}
}