diff --git a/ent/downloadclients.go b/ent/downloadclients.go index a8c2c4d..e2f66fa 100644 --- a/ent/downloadclients.go +++ b/ent/downloadclients.go @@ -6,6 +6,7 @@ import ( "fmt" "polaris/ent/downloadclients" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -37,7 +38,9 @@ type DownloadClients struct { // RemoveFailedDownloads holds the value of the "remove_failed_downloads" field. RemoveFailedDownloads bool `json:"remove_failed_downloads,omitempty"` // Tags holds the value of the "tags" field. - Tags string `json:"tags,omitempty"` + Tags string `json:"tags,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` selectValues sql.SelectValues } @@ -52,6 +55,8 @@ func (*DownloadClients) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldURL, downloadclients.FieldUser, downloadclients.FieldPassword, downloadclients.FieldSettings, downloadclients.FieldTags: values[i] = new(sql.NullString) + case downloadclients.FieldCreateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -139,6 +144,12 @@ func (dc *DownloadClients) assignValues(columns []string, values []any) error { } else if value.Valid { dc.Tags = value.String } + case downloadclients.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + dc.CreateTime = value.Time + } default: dc.selectValues.Set(columns[i], values[i]) } @@ -207,6 +218,9 @@ func (dc *DownloadClients) String() string { builder.WriteString(", ") builder.WriteString("tags=") builder.WriteString(dc.Tags) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(dc.CreateTime.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/downloadclients/downloadclients.go b/ent/downloadclients/downloadclients.go index 23abe48..08c9c89 100644 --- a/ent/downloadclients/downloadclients.go +++ b/ent/downloadclients/downloadclients.go @@ -4,6 +4,7 @@ package downloadclients import ( "fmt" + "time" "entgo.io/ent/dialect/sql" ) @@ -35,6 +36,8 @@ const ( FieldRemoveFailedDownloads = "remove_failed_downloads" // FieldTags holds the string denoting the tags field in the database. FieldTags = "tags" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" // Table holds the table name of the downloadclients in the database. Table = "download_clients" ) @@ -53,6 +56,7 @@ var Columns = []string{ FieldRemoveCompletedDownloads, FieldRemoveFailedDownloads, FieldTags, + FieldCreateTime, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -82,6 +86,8 @@ var ( DefaultRemoveFailedDownloads bool // DefaultTags holds the default value on creation for the "tags" field. DefaultTags string + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time ) // Implementation defines the type for the "implementation" enum field. @@ -170,3 +176,8 @@ func ByRemoveFailedDownloads(opts ...sql.OrderTermOption) OrderOption { func ByTags(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldTags, opts...).ToFunc() } + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} diff --git a/ent/downloadclients/where.go b/ent/downloadclients/where.go index 501f79f..0827c79 100644 --- a/ent/downloadclients/where.go +++ b/ent/downloadclients/where.go @@ -4,6 +4,7 @@ package downloadclients import ( "polaris/ent/predicate" + "time" "entgo.io/ent/dialect/sql" ) @@ -103,6 +104,11 @@ func Tags(v string) predicate.DownloadClients { return predicate.DownloadClients(sql.FieldEQ(FieldTags, v)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldEQ(FieldCreateTime, v)) +} + // EnableEQ applies the EQ predicate on the "enable" field. func EnableEQ(v bool) predicate.DownloadClients { return predicate.DownloadClients(sql.FieldEQ(FieldEnable, v)) @@ -583,6 +589,56 @@ func TagsContainsFold(v string) predicate.DownloadClients { return predicate.DownloadClients(sql.FieldContainsFold(FieldTags, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.DownloadClients { + return predicate.DownloadClients(sql.FieldNotNull(FieldCreateTime)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.DownloadClients) predicate.DownloadClients { return predicate.DownloadClients(sql.AndPredicates(predicates...)) diff --git a/ent/downloadclients_create.go b/ent/downloadclients_create.go index 7c6b08a..2091c67 100644 --- a/ent/downloadclients_create.go +++ b/ent/downloadclients_create.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "polaris/ent/downloadclients" + "time" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -141,6 +142,20 @@ func (dcc *DownloadClientsCreate) SetNillableTags(s *string) *DownloadClientsCre return dcc } +// SetCreateTime sets the "create_time" field. +func (dcc *DownloadClientsCreate) SetCreateTime(t time.Time) *DownloadClientsCreate { + dcc.mutation.SetCreateTime(t) + return dcc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (dcc *DownloadClientsCreate) SetNillableCreateTime(t *time.Time) *DownloadClientsCreate { + if t != nil { + dcc.SetCreateTime(*t) + } + return dcc +} + // Mutation returns the DownloadClientsMutation object of the builder. func (dcc *DownloadClientsCreate) Mutation() *DownloadClientsMutation { return dcc.mutation @@ -204,6 +219,10 @@ func (dcc *DownloadClientsCreate) defaults() { v := downloadclients.DefaultTags dcc.mutation.SetTags(v) } + if _, ok := dcc.mutation.CreateTime(); !ok { + v := downloadclients.DefaultCreateTime() + dcc.mutation.SetCreateTime(v) + } } // check runs all checks and user-defined validators on the builder. @@ -321,6 +340,10 @@ func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.Crea _spec.SetField(downloadclients.FieldTags, field.TypeString, value) _node.Tags = value } + if value, ok := dcc.mutation.CreateTime(); ok { + _spec.SetField(downloadclients.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } return _node, _spec } diff --git a/ent/downloadclients_update.go b/ent/downloadclients_update.go index cee0506..2df820f 100644 --- a/ent/downloadclients_update.go +++ b/ent/downloadclients_update.go @@ -283,6 +283,9 @@ func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error if value, ok := dcu.mutation.Tags(); ok { _spec.SetField(downloadclients.FieldTags, field.TypeString, value) } + if dcu.mutation.CreateTimeCleared() { + _spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime) + } if n, err = sqlgraph.UpdateNodes(ctx, dcu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{downloadclients.Label} @@ -589,6 +592,9 @@ func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *Downl if value, ok := dcuo.mutation.Tags(); ok { _spec.SetField(downloadclients.FieldTags, field.TypeString, value) } + if dcuo.mutation.CreateTimeCleared() { + _spec.ClearField(downloadclients.FieldCreateTime, field.TypeTime) + } _node = &DownloadClients{config: dcuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/ent/episode.go b/ent/episode.go index f159326..5e7a312 100644 --- a/ent/episode.go +++ b/ent/episode.go @@ -7,6 +7,7 @@ import ( "polaris/ent/episode" "polaris/ent/media" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -35,6 +36,8 @@ type Episode struct { Monitored bool `json:"monitored"` // TargetFile holds the value of the "target_file" field. TargetFile string `json:"target_file,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the EpisodeQuery when eager-loading is set. Edges EpisodeEdges `json:"edges"` @@ -72,6 +75,8 @@ func (*Episode) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case episode.FieldTitle, episode.FieldOverview, episode.FieldAirDate, episode.FieldStatus, episode.FieldTargetFile: values[i] = new(sql.NullString) + case episode.FieldCreateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -147,6 +152,12 @@ func (e *Episode) assignValues(columns []string, values []any) error { } else if value.Valid { e.TargetFile = value.String } + case episode.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + e.CreateTime = value.Time + } default: e.selectValues.Set(columns[i], values[i]) } @@ -214,6 +225,9 @@ func (e *Episode) String() string { builder.WriteString(", ") builder.WriteString("target_file=") builder.WriteString(e.TargetFile) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(e.CreateTime.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/episode/episode.go b/ent/episode/episode.go index 231c283..ea8cc30 100644 --- a/ent/episode/episode.go +++ b/ent/episode/episode.go @@ -4,6 +4,7 @@ package episode import ( "fmt" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -32,6 +33,8 @@ const ( FieldMonitored = "monitored" // FieldTargetFile holds the string denoting the target_file field in the database. FieldTargetFile = "target_file" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" // EdgeMedia holds the string denoting the media edge name in mutations. EdgeMedia = "media" // Table holds the table name of the episode in the database. @@ -57,6 +60,7 @@ var Columns = []string{ FieldStatus, FieldMonitored, FieldTargetFile, + FieldCreateTime, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -72,6 +76,8 @@ func ValidColumn(column string) bool { var ( // DefaultMonitored holds the default value on creation for the "monitored" field. DefaultMonitored bool + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time ) // Status defines the type for the "status" enum field. @@ -154,6 +160,11 @@ func ByTargetFile(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldTargetFile, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + // ByMediaField orders the results by media field. func ByMediaField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/ent/episode/where.go b/ent/episode/where.go index 99fe362..72f356d 100644 --- a/ent/episode/where.go +++ b/ent/episode/where.go @@ -4,6 +4,7 @@ package episode import ( "polaris/ent/predicate" + "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -94,6 +95,11 @@ func TargetFile(v string) predicate.Episode { return predicate.Episode(sql.FieldEQ(FieldTargetFile, v)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldEQ(FieldCreateTime, v)) +} + // MediaIDEQ applies the EQ predicate on the "media_id" field. func MediaIDEQ(v int) predicate.Episode { return predicate.Episode(sql.FieldEQ(FieldMediaID, v)) @@ -504,6 +510,56 @@ func TargetFileContainsFold(v string) predicate.Episode { return predicate.Episode(sql.FieldContainsFold(FieldTargetFile, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Episode { + return predicate.Episode(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Episode { + return predicate.Episode(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Episode { + return predicate.Episode(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.Episode { + return predicate.Episode(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.Episode { + return predicate.Episode(sql.FieldNotNull(FieldCreateTime)) +} + // HasMedia applies the HasEdge predicate on the "media" edge. func HasMedia() predicate.Episode { return predicate.Episode(func(s *sql.Selector) { diff --git a/ent/episode_create.go b/ent/episode_create.go index 648f18d..2b519dc 100644 --- a/ent/episode_create.go +++ b/ent/episode_create.go @@ -8,6 +8,7 @@ import ( "fmt" "polaris/ent/episode" "polaris/ent/media" + "time" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -106,6 +107,20 @@ func (ec *EpisodeCreate) SetNillableTargetFile(s *string) *EpisodeCreate { return ec } +// SetCreateTime sets the "create_time" field. +func (ec *EpisodeCreate) SetCreateTime(t time.Time) *EpisodeCreate { + ec.mutation.SetCreateTime(t) + return ec +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (ec *EpisodeCreate) SetNillableCreateTime(t *time.Time) *EpisodeCreate { + if t != nil { + ec.SetCreateTime(*t) + } + return ec +} + // SetMedia sets the "media" edge to the Media entity. func (ec *EpisodeCreate) SetMedia(m *Media) *EpisodeCreate { return ec.SetMediaID(m.ID) @@ -154,6 +169,10 @@ func (ec *EpisodeCreate) defaults() { v := episode.DefaultMonitored ec.mutation.SetMonitored(v) } + if _, ok := ec.mutation.CreateTime(); !ok { + v := episode.DefaultCreateTime() + ec.mutation.SetCreateTime(v) + } } // check runs all checks and user-defined validators on the builder. @@ -242,6 +261,10 @@ func (ec *EpisodeCreate) createSpec() (*Episode, *sqlgraph.CreateSpec) { _spec.SetField(episode.FieldTargetFile, field.TypeString, value) _node.TargetFile = value } + if value, ok := ec.mutation.CreateTime(); ok { + _spec.SetField(episode.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } if nodes := ec.mutation.MediaIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/ent/episode_update.go b/ent/episode_update.go index bc26f08..69a4cee 100644 --- a/ent/episode_update.go +++ b/ent/episode_update.go @@ -278,6 +278,9 @@ func (eu *EpisodeUpdate) sqlSave(ctx context.Context) (n int, err error) { if eu.mutation.TargetFileCleared() { _spec.ClearField(episode.FieldTargetFile, field.TypeString) } + if eu.mutation.CreateTimeCleared() { + _spec.ClearField(episode.FieldCreateTime, field.TypeTime) + } if eu.mutation.MediaCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -607,6 +610,9 @@ func (euo *EpisodeUpdateOne) sqlSave(ctx context.Context) (_node *Episode, err e if euo.mutation.TargetFileCleared() { _spec.ClearField(episode.FieldTargetFile, field.TypeString) } + if euo.mutation.CreateTimeCleared() { + _spec.ClearField(episode.FieldCreateTime, field.TypeTime) + } if euo.mutation.MediaCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/ent/history.go b/ent/history.go index c16c862..2dbf4f5 100644 --- a/ent/history.go +++ b/ent/history.go @@ -41,7 +41,9 @@ type History struct { // torrent hash Hash string `json:"hash,omitempty"` // Status holds the value of the "status" field. - Status history.Status `json:"status,omitempty"` + Status history.Status `json:"status,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` selectValues sql.SelectValues } @@ -56,7 +58,7 @@ func (*History) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldHash, history.FieldStatus: values[i] = new(sql.NullString) - case history.FieldDate: + case history.FieldDate, history.FieldCreateTime: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) @@ -153,6 +155,12 @@ func (h *History) assignValues(columns []string, values []any) error { } else if value.Valid { h.Status = history.Status(value.String) } + case history.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + h.CreateTime = value.Time + } default: h.selectValues.Set(columns[i], values[i]) } @@ -224,6 +232,9 @@ func (h *History) String() string { builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(fmt.Sprintf("%v", h.Status)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(h.CreateTime.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/history/history.go b/ent/history/history.go index 04b88d4..d981504 100644 --- a/ent/history/history.go +++ b/ent/history/history.go @@ -4,6 +4,7 @@ package history import ( "fmt" + "time" "entgo.io/ent/dialect/sql" ) @@ -37,6 +38,8 @@ const ( FieldHash = "hash" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" // Table holds the table name of the history in the database. Table = "histories" ) @@ -56,6 +59,7 @@ var Columns = []string{ FieldLink, FieldHash, FieldStatus, + FieldCreateTime, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -71,6 +75,8 @@ func ValidColumn(column string) bool { var ( // DefaultSize holds the default value on creation for the "size" field. DefaultSize int + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time ) // Status defines the type for the "status" enum field. @@ -162,3 +168,8 @@ func ByHash(opts ...sql.OrderTermOption) OrderOption { func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} diff --git a/ent/history/where.go b/ent/history/where.go index 7fd2a69..26088fd 100644 --- a/ent/history/where.go +++ b/ent/history/where.go @@ -104,6 +104,11 @@ func Hash(v string) predicate.History { return predicate.History(sql.FieldEQ(FieldHash, v)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.History { + return predicate.History(sql.FieldEQ(FieldCreateTime, v)) +} + // MediaIDEQ applies the EQ predicate on the "media_id" field. func MediaIDEQ(v int) predicate.History { return predicate.History(sql.FieldEQ(FieldMediaID, v)) @@ -684,6 +689,56 @@ func StatusNotIn(vs ...Status) predicate.History { return predicate.History(sql.FieldNotIn(FieldStatus, vs...)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.History { + return predicate.History(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.History { + return predicate.History(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.History { + return predicate.History(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.History { + return predicate.History(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.History { + return predicate.History(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.History { + return predicate.History(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.History { + return predicate.History(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.History { + return predicate.History(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.History { + return predicate.History(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.History { + return predicate.History(sql.FieldNotNull(FieldCreateTime)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.History) predicate.History { return predicate.History(sql.AndPredicates(predicates...)) diff --git a/ent/history_create.go b/ent/history_create.go index 7160bcf..951ec4b 100644 --- a/ent/history_create.go +++ b/ent/history_create.go @@ -140,6 +140,20 @@ func (hc *HistoryCreate) SetStatus(h history.Status) *HistoryCreate { return hc } +// SetCreateTime sets the "create_time" field. +func (hc *HistoryCreate) SetCreateTime(t time.Time) *HistoryCreate { + hc.mutation.SetCreateTime(t) + return hc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (hc *HistoryCreate) SetNillableCreateTime(t *time.Time) *HistoryCreate { + if t != nil { + hc.SetCreateTime(*t) + } + return hc +} + // Mutation returns the HistoryMutation object of the builder. func (hc *HistoryCreate) Mutation() *HistoryMutation { return hc.mutation @@ -179,6 +193,10 @@ func (hc *HistoryCreate) defaults() { v := history.DefaultSize hc.mutation.SetSize(v) } + if _, ok := hc.mutation.CreateTime(); !ok { + v := history.DefaultCreateTime() + hc.mutation.SetCreateTime(v) + } } // check runs all checks and user-defined validators on the builder. @@ -280,6 +298,10 @@ func (hc *HistoryCreate) createSpec() (*History, *sqlgraph.CreateSpec) { _spec.SetField(history.FieldStatus, field.TypeEnum, value) _node.Status = value } + if value, ok := hc.mutation.CreateTime(); ok { + _spec.SetField(history.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } return _node, _spec } diff --git a/ent/history_update.go b/ent/history_update.go index 954519d..cea8c4c 100644 --- a/ent/history_update.go +++ b/ent/history_update.go @@ -394,6 +394,9 @@ func (hu *HistoryUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := hu.mutation.Status(); ok { _spec.SetField(history.FieldStatus, field.TypeEnum, value) } + if hu.mutation.CreateTimeCleared() { + _spec.ClearField(history.FieldCreateTime, field.TypeTime) + } if n, err = sqlgraph.UpdateNodes(ctx, hu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{history.Label} @@ -809,6 +812,9 @@ func (huo *HistoryUpdateOne) sqlSave(ctx context.Context) (_node *History, err e if value, ok := huo.mutation.Status(); ok { _spec.SetField(history.FieldStatus, field.TypeEnum, value) } + if huo.mutation.CreateTimeCleared() { + _spec.ClearField(history.FieldCreateTime, field.TypeTime) + } _node = &History{config: huo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/ent/indexers.go b/ent/indexers.go index 6166295..edfa730 100644 --- a/ent/indexers.go +++ b/ent/indexers.go @@ -6,6 +6,7 @@ import ( "fmt" "polaris/ent/indexers" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -39,7 +40,9 @@ type Indexers struct { // URL holds the value of the "url" field. URL string `json:"url,omitempty"` // synced from prowlarr - Synced bool `json:"synced,omitempty"` + Synced bool `json:"synced,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` selectValues sql.SelectValues } @@ -56,6 +59,8 @@ func (*Indexers) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings, indexers.FieldAPIKey, indexers.FieldURL: values[i] = new(sql.NullString) + case indexers.FieldCreateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -149,6 +154,12 @@ func (i *Indexers) assignValues(columns []string, values []any) error { } else if value.Valid { i.Synced = value.Bool } + case indexers.FieldCreateTime: + if value, ok := values[j].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[j]) + } else if value.Valid { + i.CreateTime = value.Time + } default: i.selectValues.Set(columns[j], values[j]) } @@ -220,6 +231,9 @@ func (i *Indexers) String() string { builder.WriteString(", ") builder.WriteString("synced=") builder.WriteString(fmt.Sprintf("%v", i.Synced)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(i.CreateTime.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/indexers/indexers.go b/ent/indexers/indexers.go index 40e0e8a..8872ada 100644 --- a/ent/indexers/indexers.go +++ b/ent/indexers/indexers.go @@ -3,6 +3,8 @@ package indexers import ( + "time" + "entgo.io/ent/dialect/sql" ) @@ -35,6 +37,8 @@ const ( FieldURL = "url" // FieldSynced holds the string denoting the synced field in the database. FieldSynced = "synced" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" // Table holds the table name of the indexers in the database. Table = "indexers" ) @@ -54,6 +58,7 @@ var Columns = []string{ FieldAPIKey, FieldURL, FieldSynced, + FieldCreateTime, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -83,6 +88,8 @@ var ( DefaultMovieSearch bool // DefaultSynced holds the default value on creation for the "synced" field. DefaultSynced bool + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time ) // OrderOption defines the ordering options for the Indexers queries. @@ -152,3 +159,8 @@ func ByURL(opts ...sql.OrderTermOption) OrderOption { func BySynced(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSynced, opts...).ToFunc() } + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} diff --git a/ent/indexers/where.go b/ent/indexers/where.go index d23f008..0e09b70 100644 --- a/ent/indexers/where.go +++ b/ent/indexers/where.go @@ -4,6 +4,7 @@ package indexers import ( "polaris/ent/predicate" + "time" "entgo.io/ent/dialect/sql" ) @@ -113,6 +114,11 @@ func Synced(v bool) predicate.Indexers { return predicate.Indexers(sql.FieldEQ(FieldSynced, v)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldEQ(FieldCreateTime, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Indexers { return predicate.Indexers(sql.FieldEQ(FieldName, v)) @@ -648,6 +654,56 @@ func SyncedNotNil() predicate.Indexers { return predicate.Indexers(sql.FieldNotNull(FieldSynced)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Indexers { + return predicate.Indexers(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.Indexers { + return predicate.Indexers(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.Indexers { + return predicate.Indexers(sql.FieldNotNull(FieldCreateTime)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Indexers) predicate.Indexers { return predicate.Indexers(sql.AndPredicates(predicates...)) diff --git a/ent/indexers_create.go b/ent/indexers_create.go index cdc7357..57a8d5a 100644 --- a/ent/indexers_create.go +++ b/ent/indexers_create.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "polaris/ent/indexers" + "time" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -171,6 +172,20 @@ func (ic *IndexersCreate) SetNillableSynced(b *bool) *IndexersCreate { return ic } +// SetCreateTime sets the "create_time" field. +func (ic *IndexersCreate) SetCreateTime(t time.Time) *IndexersCreate { + ic.mutation.SetCreateTime(t) + return ic +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (ic *IndexersCreate) SetNillableCreateTime(t *time.Time) *IndexersCreate { + if t != nil { + ic.SetCreateTime(*t) + } + return ic +} + // Mutation returns the IndexersMutation object of the builder. func (ic *IndexersCreate) Mutation() *IndexersMutation { return ic.mutation @@ -238,6 +253,10 @@ func (ic *IndexersCreate) defaults() { v := indexers.DefaultSynced ic.mutation.SetSynced(v) } + if _, ok := ic.mutation.CreateTime(); !ok { + v := indexers.DefaultCreateTime() + ic.mutation.SetCreateTime(v) + } } // check runs all checks and user-defined validators on the builder. @@ -328,6 +347,10 @@ func (ic *IndexersCreate) createSpec() (*Indexers, *sqlgraph.CreateSpec) { _spec.SetField(indexers.FieldSynced, field.TypeBool, value) _node.Synced = value } + if value, ok := ic.mutation.CreateTime(); ok { + _spec.SetField(indexers.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } return _node, _spec } diff --git a/ent/indexers_update.go b/ent/indexers_update.go index 3dec05e..4931b23 100644 --- a/ent/indexers_update.go +++ b/ent/indexers_update.go @@ -364,6 +364,9 @@ func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) { if iu.mutation.SyncedCleared() { _spec.ClearField(indexers.FieldSynced, field.TypeBool) } + if iu.mutation.CreateTimeCleared() { + _spec.ClearField(indexers.FieldCreateTime, field.TypeTime) + } if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{indexers.Label} @@ -751,6 +754,9 @@ func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err if iuo.mutation.SyncedCleared() { _spec.ClearField(indexers.FieldSynced, field.TypeBool) } + if iuo.mutation.CreateTimeCleared() { + _spec.ClearField(indexers.FieldCreateTime, field.TypeTime) + } _node = &Indexers{config: iuo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/ent/media.go b/ent/media.go index a0abb94..403332c 100644 --- a/ent/media.go +++ b/ent/media.go @@ -51,6 +51,8 @@ type Media struct { Extras schema.MediaExtras `json:"extras,omitempty"` // AlternativeTitles holds the value of the "alternative_titles" field. AlternativeTitles []schema.AlternativeTilte `json:"alternative_titles,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the MediaQuery when eager-loading is set. Edges MediaEdges `json:"edges"` @@ -88,7 +90,7 @@ func (*Media) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case media.FieldImdbID, media.FieldMediaType, media.FieldNameCn, media.FieldNameEn, media.FieldOriginalName, media.FieldOverview, media.FieldAirDate, media.FieldResolution, media.FieldTargetDir: values[i] = new(sql.NullString) - case media.FieldCreatedAt: + case media.FieldCreatedAt, media.FieldCreateTime: values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) @@ -213,6 +215,12 @@ func (m *Media) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field alternative_titles: %w", err) } } + case media.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + m.CreateTime = value.Time + } default: m.selectValues.Set(columns[i], values[i]) } @@ -301,6 +309,9 @@ func (m *Media) String() string { builder.WriteString(", ") builder.WriteString("alternative_titles=") builder.WriteString(fmt.Sprintf("%v", m.AlternativeTitles)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(m.CreateTime.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/media/media.go b/ent/media/media.go index 8d5e7c9..14b6b15 100644 --- a/ent/media/media.go +++ b/ent/media/media.go @@ -47,6 +47,8 @@ const ( FieldExtras = "extras" // FieldAlternativeTitles holds the string denoting the alternative_titles field in the database. FieldAlternativeTitles = "alternative_titles" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" // EdgeEpisodes holds the string denoting the episodes edge name in mutations. EdgeEpisodes = "episodes" // Table holds the table name of the media in the database. @@ -79,6 +81,7 @@ var Columns = []string{ FieldLimiter, FieldExtras, FieldAlternativeTitles, + FieldCreateTime, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -98,6 +101,8 @@ var ( DefaultAirDate string // DefaultDownloadHistoryEpisodes holds the default value on creation for the "download_history_episodes" field. DefaultDownloadHistoryEpisodes bool + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time ) // MediaType defines the type for the "media_type" enum field. @@ -224,6 +229,11 @@ func ByDownloadHistoryEpisodes(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDownloadHistoryEpisodes, opts...).ToFunc() } +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + // ByEpisodesCount orders the results by episodes count. func ByEpisodesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/ent/media/where.go b/ent/media/where.go index 61eb448..1716e39 100644 --- a/ent/media/where.go +++ b/ent/media/where.go @@ -110,6 +110,11 @@ func DownloadHistoryEpisodes(v bool) predicate.Media { return predicate.Media(sql.FieldEQ(FieldDownloadHistoryEpisodes, v)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Media { + return predicate.Media(sql.FieldEQ(FieldCreateTime, v)) +} + // TmdbIDEQ applies the EQ predicate on the "tmdb_id" field. func TmdbIDEQ(v int) predicate.Media { return predicate.Media(sql.FieldEQ(FieldTmdbID, v)) @@ -805,6 +810,56 @@ func AlternativeTitlesNotNil() predicate.Media { return predicate.Media(sql.FieldNotNull(FieldAlternativeTitles)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Media { + return predicate.Media(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Media { + return predicate.Media(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Media { + return predicate.Media(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Media { + return predicate.Media(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Media { + return predicate.Media(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Media { + return predicate.Media(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Media { + return predicate.Media(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Media { + return predicate.Media(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.Media { + return predicate.Media(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.Media { + return predicate.Media(sql.FieldNotNull(FieldCreateTime)) +} + // HasEpisodes applies the HasEdge predicate on the "episodes" edge. func HasEpisodes() predicate.Media { return predicate.Media(func(s *sql.Selector) { diff --git a/ent/media_create.go b/ent/media_create.go index 1deefef..168343a 100644 --- a/ent/media_create.go +++ b/ent/media_create.go @@ -190,6 +190,20 @@ func (mc *MediaCreate) SetAlternativeTitles(st []schema.AlternativeTilte) *Media return mc } +// SetCreateTime sets the "create_time" field. +func (mc *MediaCreate) SetCreateTime(t time.Time) *MediaCreate { + mc.mutation.SetCreateTime(t) + return mc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (mc *MediaCreate) SetNillableCreateTime(t *time.Time) *MediaCreate { + if t != nil { + mc.SetCreateTime(*t) + } + return mc +} + // AddEpisodeIDs adds the "episodes" edge to the Episode entity by IDs. func (mc *MediaCreate) AddEpisodeIDs(ids ...int) *MediaCreate { mc.mutation.AddEpisodeIDs(ids...) @@ -256,6 +270,10 @@ func (mc *MediaCreate) defaults() { v := media.DefaultDownloadHistoryEpisodes mc.mutation.SetDownloadHistoryEpisodes(v) } + if _, ok := mc.mutation.CreateTime(); !ok { + v := media.DefaultCreateTime() + mc.mutation.SetCreateTime(v) + } } // check runs all checks and user-defined validators on the builder. @@ -387,6 +405,10 @@ func (mc *MediaCreate) createSpec() (*Media, *sqlgraph.CreateSpec) { _spec.SetField(media.FieldAlternativeTitles, field.TypeJSON, value) _node.AlternativeTitles = value } + if value, ok := mc.mutation.CreateTime(); ok { + _spec.SetField(media.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } if nodes := mc.mutation.EpisodesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/media_update.go b/ent/media_update.go index 616234f..a3899b8 100644 --- a/ent/media_update.go +++ b/ent/media_update.go @@ -484,6 +484,9 @@ func (mu *MediaUpdate) sqlSave(ctx context.Context) (n int, err error) { if mu.mutation.AlternativeTitlesCleared() { _spec.ClearField(media.FieldAlternativeTitles, field.TypeJSON) } + if mu.mutation.CreateTimeCleared() { + _spec.ClearField(media.FieldCreateTime, field.TypeTime) + } if mu.mutation.EpisodesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -1032,6 +1035,9 @@ func (muo *MediaUpdateOne) sqlSave(ctx context.Context) (_node *Media, err error if muo.mutation.AlternativeTitlesCleared() { _spec.ClearField(media.FieldAlternativeTitles, field.TypeJSON) } + if muo.mutation.CreateTimeCleared() { + _spec.ClearField(media.FieldCreateTime, field.TypeTime) + } if muo.mutation.EpisodesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 6358b35..2a07465 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -35,6 +35,7 @@ var ( {Name: "remove_completed_downloads", Type: field.TypeBool, Default: true}, {Name: "remove_failed_downloads", Type: field.TypeBool, Default: true}, {Name: "tags", Type: field.TypeString, Default: ""}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, } // DownloadClientsTable holds the schema information for the "download_clients" table. DownloadClientsTable = &schema.Table{ @@ -53,6 +54,7 @@ var ( {Name: "status", Type: field.TypeEnum, Enums: []string{"missing", "downloading", "downloaded"}, Default: "missing"}, {Name: "monitored", Type: field.TypeBool, Default: false}, {Name: "target_file", Type: field.TypeString, Nullable: true}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, {Name: "media_id", Type: field.TypeInt, Nullable: true}, } // EpisodesTable holds the schema information for the "episodes" table. @@ -63,7 +65,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "episodes_media_episodes", - Columns: []*schema.Column{EpisodesColumns[9]}, + Columns: []*schema.Column{EpisodesColumns[10]}, RefColumns: []*schema.Column{MediaColumns[0]}, OnDelete: schema.SetNull, }, @@ -84,6 +86,7 @@ var ( {Name: "link", Type: field.TypeString, Nullable: true}, {Name: "hash", Type: field.TypeString, Nullable: true}, {Name: "status", Type: field.TypeEnum, Enums: []string{"running", "success", "fail", "uploading", "seeding", "removed"}}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, } // HistoriesTable holds the schema information for the "histories" table. HistoriesTable = &schema.Table{ @@ -122,6 +125,7 @@ var ( {Name: "api_key", Type: field.TypeString, Nullable: true}, {Name: "url", Type: field.TypeString, Nullable: true}, {Name: "synced", Type: field.TypeBool, Nullable: true, Default: false}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, } // IndexersTable holds the schema information for the "indexers" table. IndexersTable = &schema.Table{ @@ -148,6 +152,7 @@ var ( {Name: "limiter", Type: field.TypeJSON, Nullable: true}, {Name: "extras", Type: field.TypeJSON, Nullable: true}, {Name: "alternative_titles", Type: field.TypeJSON, Nullable: true}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, } // MediaTable holds the schema information for the "media" table. MediaTable = &schema.Table{ @@ -191,6 +196,7 @@ var ( {Name: "settings", Type: field.TypeString, Nullable: true}, {Name: "deleted", Type: field.TypeBool, Default: false}, {Name: "default", Type: field.TypeBool, Default: false}, + {Name: "create_time", Type: field.TypeTime, Nullable: true}, } // StoragesTable holds the schema information for the "storages" table. StoragesTable = &schema.Table{ diff --git a/ent/mutation.go b/ent/mutation.go index c953b19..d4d54f1 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -520,6 +520,7 @@ type DownloadClientsMutation struct { remove_completed_downloads *bool remove_failed_downloads *bool tags *string + create_time *time.Time clearedFields map[string]struct{} done bool oldValue func(context.Context) (*DownloadClients, error) @@ -1040,6 +1041,55 @@ func (m *DownloadClientsMutation) ResetTags() { m.tags = nil } +// SetCreateTime sets the "create_time" field. +func (m *DownloadClientsMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *DownloadClientsMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the DownloadClients entity. +// If the DownloadClients 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 *DownloadClientsMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *DownloadClientsMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[downloadclients.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *DownloadClientsMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[downloadclients.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *DownloadClientsMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, downloadclients.FieldCreateTime) +} + // Where appends a list predicates to the DownloadClientsMutation builder. func (m *DownloadClientsMutation) Where(ps ...predicate.DownloadClients) { m.predicates = append(m.predicates, ps...) @@ -1074,7 +1124,7 @@ func (m *DownloadClientsMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *DownloadClientsMutation) Fields() []string { - fields := make([]string, 0, 11) + fields := make([]string, 0, 12) if m.enable != nil { fields = append(fields, downloadclients.FieldEnable) } @@ -1108,6 +1158,9 @@ func (m *DownloadClientsMutation) Fields() []string { if m.tags != nil { fields = append(fields, downloadclients.FieldTags) } + if m.create_time != nil { + fields = append(fields, downloadclients.FieldCreateTime) + } return fields } @@ -1138,6 +1191,8 @@ func (m *DownloadClientsMutation) Field(name string) (ent.Value, bool) { return m.RemoveFailedDownloads() case downloadclients.FieldTags: return m.Tags() + case downloadclients.FieldCreateTime: + return m.CreateTime() } return nil, false } @@ -1169,6 +1224,8 @@ func (m *DownloadClientsMutation) OldField(ctx context.Context, name string) (en return m.OldRemoveFailedDownloads(ctx) case downloadclients.FieldTags: return m.OldTags(ctx) + case downloadclients.FieldCreateTime: + return m.OldCreateTime(ctx) } return nil, fmt.Errorf("unknown DownloadClients field %s", name) } @@ -1255,6 +1312,13 @@ func (m *DownloadClientsMutation) SetField(name string, value ent.Value) error { } m.SetTags(v) return nil + case downloadclients.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil } return fmt.Errorf("unknown DownloadClients field %s", name) } @@ -1299,7 +1363,11 @@ func (m *DownloadClientsMutation) AddField(name string, value ent.Value) error { // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *DownloadClientsMutation) ClearedFields() []string { - return nil + var fields []string + if m.FieldCleared(downloadclients.FieldCreateTime) { + fields = append(fields, downloadclients.FieldCreateTime) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was @@ -1312,6 +1380,11 @@ func (m *DownloadClientsMutation) FieldCleared(name string) bool { // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *DownloadClientsMutation) ClearField(name string) error { + switch name { + case downloadclients.FieldCreateTime: + m.ClearCreateTime() + return nil + } return fmt.Errorf("unknown DownloadClients nullable field %s", name) } @@ -1352,6 +1425,9 @@ func (m *DownloadClientsMutation) ResetField(name string) error { case downloadclients.FieldTags: m.ResetTags() return nil + case downloadclients.FieldCreateTime: + m.ResetCreateTime() + return nil } return fmt.Errorf("unknown DownloadClients field %s", name) } @@ -1420,6 +1496,7 @@ type EpisodeMutation struct { status *episode.Status monitored *bool target_file *string + create_time *time.Time clearedFields map[string]struct{} media *int clearedmedia bool @@ -1916,6 +1993,55 @@ func (m *EpisodeMutation) ResetTargetFile() { delete(m.clearedFields, episode.FieldTargetFile) } +// SetCreateTime sets the "create_time" field. +func (m *EpisodeMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *EpisodeMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Episode entity. +// If the Episode 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 *EpisodeMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *EpisodeMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[episode.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *EpisodeMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[episode.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *EpisodeMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, episode.FieldCreateTime) +} + // ClearMedia clears the "media" edge to the Media entity. func (m *EpisodeMutation) ClearMedia() { m.clearedmedia = true @@ -1977,7 +2103,7 @@ func (m *EpisodeMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *EpisodeMutation) Fields() []string { - fields := make([]string, 0, 9) + fields := make([]string, 0, 10) if m.media != nil { fields = append(fields, episode.FieldMediaID) } @@ -2005,6 +2131,9 @@ func (m *EpisodeMutation) Fields() []string { if m.target_file != nil { fields = append(fields, episode.FieldTargetFile) } + if m.create_time != nil { + fields = append(fields, episode.FieldCreateTime) + } return fields } @@ -2031,6 +2160,8 @@ func (m *EpisodeMutation) Field(name string) (ent.Value, bool) { return m.Monitored() case episode.FieldTargetFile: return m.TargetFile() + case episode.FieldCreateTime: + return m.CreateTime() } return nil, false } @@ -2058,6 +2189,8 @@ func (m *EpisodeMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldMonitored(ctx) case episode.FieldTargetFile: return m.OldTargetFile(ctx) + case episode.FieldCreateTime: + return m.OldCreateTime(ctx) } return nil, fmt.Errorf("unknown Episode field %s", name) } @@ -2130,6 +2263,13 @@ func (m *EpisodeMutation) SetField(name string, value ent.Value) error { } m.SetTargetFile(v) return nil + case episode.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil } return fmt.Errorf("unknown Episode field %s", name) } @@ -2193,6 +2333,9 @@ func (m *EpisodeMutation) ClearedFields() []string { if m.FieldCleared(episode.FieldTargetFile) { fields = append(fields, episode.FieldTargetFile) } + if m.FieldCleared(episode.FieldCreateTime) { + fields = append(fields, episode.FieldCreateTime) + } return fields } @@ -2213,6 +2356,9 @@ func (m *EpisodeMutation) ClearField(name string) error { case episode.FieldTargetFile: m.ClearTargetFile() return nil + case episode.FieldCreateTime: + m.ClearCreateTime() + return nil } return fmt.Errorf("unknown Episode nullable field %s", name) } @@ -2248,6 +2394,9 @@ func (m *EpisodeMutation) ResetField(name string) error { case episode.FieldTargetFile: m.ResetTargetFile() return nil + case episode.FieldCreateTime: + m.ResetCreateTime() + return nil } return fmt.Errorf("unknown Episode field %s", name) } @@ -2350,6 +2499,7 @@ type HistoryMutation struct { link *string hash *string status *history.Status + create_time *time.Time clearedFields map[string]struct{} done bool oldValue func(context.Context) (*History, error) @@ -3083,6 +3233,55 @@ func (m *HistoryMutation) ResetStatus() { m.status = nil } +// SetCreateTime sets the "create_time" field. +func (m *HistoryMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *HistoryMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the History entity. +// If the History 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 *HistoryMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *HistoryMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[history.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *HistoryMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[history.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *HistoryMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, history.FieldCreateTime) +} + // Where appends a list predicates to the HistoryMutation builder. func (m *HistoryMutation) Where(ps ...predicate.History) { m.predicates = append(m.predicates, ps...) @@ -3117,7 +3316,7 @@ func (m *HistoryMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *HistoryMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 13) if m.media_id != nil { fields = append(fields, history.FieldMediaID) } @@ -3154,6 +3353,9 @@ func (m *HistoryMutation) Fields() []string { if m.status != nil { fields = append(fields, history.FieldStatus) } + if m.create_time != nil { + fields = append(fields, history.FieldCreateTime) + } return fields } @@ -3186,6 +3388,8 @@ func (m *HistoryMutation) Field(name string) (ent.Value, bool) { return m.Hash() case history.FieldStatus: return m.Status() + case history.FieldCreateTime: + return m.CreateTime() } return nil, false } @@ -3219,6 +3423,8 @@ func (m *HistoryMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldHash(ctx) case history.FieldStatus: return m.OldStatus(ctx) + case history.FieldCreateTime: + return m.OldCreateTime(ctx) } return nil, fmt.Errorf("unknown History field %s", name) } @@ -3312,6 +3518,13 @@ func (m *HistoryMutation) SetField(name string, value ent.Value) error { } m.SetStatus(v) return nil + case history.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil } return fmt.Errorf("unknown History field %s", name) } @@ -3423,6 +3636,9 @@ func (m *HistoryMutation) ClearedFields() []string { if m.FieldCleared(history.FieldHash) { fields = append(fields, history.FieldHash) } + if m.FieldCleared(history.FieldCreateTime) { + fields = append(fields, history.FieldCreateTime) + } return fields } @@ -3455,6 +3671,9 @@ func (m *HistoryMutation) ClearField(name string) error { case history.FieldHash: m.ClearHash() return nil + case history.FieldCreateTime: + m.ClearCreateTime() + return nil } return fmt.Errorf("unknown History nullable field %s", name) } @@ -3499,6 +3718,9 @@ func (m *HistoryMutation) ResetField(name string) error { case history.FieldStatus: m.ResetStatus() return nil + case history.FieldCreateTime: + m.ResetCreateTime() + return nil } return fmt.Errorf("unknown History field %s", name) } @@ -4244,6 +4466,7 @@ type IndexersMutation struct { api_key *string url *string synced *bool + create_time *time.Time clearedFields map[string]struct{} done bool oldValue func(context.Context) (*Indexers, error) @@ -4925,6 +5148,55 @@ func (m *IndexersMutation) ResetSynced() { delete(m.clearedFields, indexers.FieldSynced) } +// SetCreateTime sets the "create_time" field. +func (m *IndexersMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *IndexersMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Indexers entity. +// If the Indexers 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 *IndexersMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *IndexersMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[indexers.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *IndexersMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[indexers.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *IndexersMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, indexers.FieldCreateTime) +} + // Where appends a list predicates to the IndexersMutation builder. func (m *IndexersMutation) Where(ps ...predicate.Indexers) { m.predicates = append(m.predicates, ps...) @@ -4959,7 +5231,7 @@ func (m *IndexersMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *IndexersMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 13) if m.name != nil { fields = append(fields, indexers.FieldName) } @@ -4996,6 +5268,9 @@ func (m *IndexersMutation) Fields() []string { if m.synced != nil { fields = append(fields, indexers.FieldSynced) } + if m.create_time != nil { + fields = append(fields, indexers.FieldCreateTime) + } return fields } @@ -5028,6 +5303,8 @@ func (m *IndexersMutation) Field(name string) (ent.Value, bool) { return m.URL() case indexers.FieldSynced: return m.Synced() + case indexers.FieldCreateTime: + return m.CreateTime() } return nil, false } @@ -5061,6 +5338,8 @@ func (m *IndexersMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldURL(ctx) case indexers.FieldSynced: return m.OldSynced(ctx) + case indexers.FieldCreateTime: + return m.OldCreateTime(ctx) } return nil, fmt.Errorf("unknown Indexers field %s", name) } @@ -5154,6 +5433,13 @@ func (m *IndexersMutation) SetField(name string, value ent.Value) error { } m.SetSynced(v) return nil + case indexers.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil } return fmt.Errorf("unknown Indexers field %s", name) } @@ -5235,6 +5521,9 @@ func (m *IndexersMutation) ClearedFields() []string { if m.FieldCleared(indexers.FieldSynced) { fields = append(fields, indexers.FieldSynced) } + if m.FieldCleared(indexers.FieldCreateTime) { + fields = append(fields, indexers.FieldCreateTime) + } return fields } @@ -5273,6 +5562,9 @@ func (m *IndexersMutation) ClearField(name string) error { case indexers.FieldSynced: m.ClearSynced() return nil + case indexers.FieldCreateTime: + m.ClearCreateTime() + return nil } return fmt.Errorf("unknown Indexers nullable field %s", name) } @@ -5317,6 +5609,9 @@ func (m *IndexersMutation) ResetField(name string) error { case indexers.FieldSynced: m.ResetSynced() return nil + case indexers.FieldCreateTime: + m.ResetCreateTime() + return nil } return fmt.Errorf("unknown Indexers field %s", name) } @@ -5394,6 +5689,7 @@ type MediaMutation struct { extras *schema.MediaExtras alternative_titles *[]schema.AlternativeTilte appendalternative_titles []schema.AlternativeTilte + create_time *time.Time clearedFields map[string]struct{} episodes map[int]struct{} removedepisodes map[int]struct{} @@ -6225,6 +6521,55 @@ func (m *MediaMutation) ResetAlternativeTitles() { delete(m.clearedFields, media.FieldAlternativeTitles) } +// SetCreateTime sets the "create_time" field. +func (m *MediaMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *MediaMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Media entity. +// If the Media 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 *MediaMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *MediaMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[media.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *MediaMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[media.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *MediaMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, media.FieldCreateTime) +} + // AddEpisodeIDs adds the "episodes" edge to the Episode entity by ids. func (m *MediaMutation) AddEpisodeIDs(ids ...int) { if m.episodes == nil { @@ -6313,7 +6658,7 @@ func (m *MediaMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *MediaMutation) Fields() []string { - fields := make([]string, 0, 16) + fields := make([]string, 0, 17) if m.tmdb_id != nil { fields = append(fields, media.FieldTmdbID) } @@ -6362,6 +6707,9 @@ func (m *MediaMutation) Fields() []string { if m.alternative_titles != nil { fields = append(fields, media.FieldAlternativeTitles) } + if m.create_time != nil { + fields = append(fields, media.FieldCreateTime) + } return fields } @@ -6402,6 +6750,8 @@ func (m *MediaMutation) Field(name string) (ent.Value, bool) { return m.Extras() case media.FieldAlternativeTitles: return m.AlternativeTitles() + case media.FieldCreateTime: + return m.CreateTime() } return nil, false } @@ -6443,6 +6793,8 @@ func (m *MediaMutation) OldField(ctx context.Context, name string) (ent.Value, e return m.OldExtras(ctx) case media.FieldAlternativeTitles: return m.OldAlternativeTitles(ctx) + case media.FieldCreateTime: + return m.OldCreateTime(ctx) } return nil, fmt.Errorf("unknown Media field %s", name) } @@ -6564,6 +6916,13 @@ func (m *MediaMutation) SetField(name string, value ent.Value) error { } m.SetAlternativeTitles(v) return nil + case media.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil } return fmt.Errorf("unknown Media field %s", name) } @@ -6642,6 +7001,9 @@ func (m *MediaMutation) ClearedFields() []string { if m.FieldCleared(media.FieldAlternativeTitles) { fields = append(fields, media.FieldAlternativeTitles) } + if m.FieldCleared(media.FieldCreateTime) { + fields = append(fields, media.FieldCreateTime) + } return fields } @@ -6677,6 +7039,9 @@ func (m *MediaMutation) ClearField(name string) error { case media.FieldAlternativeTitles: m.ClearAlternativeTitles() return nil + case media.FieldCreateTime: + m.ClearCreateTime() + return nil } return fmt.Errorf("unknown Media nullable field %s", name) } @@ -6733,6 +7098,9 @@ func (m *MediaMutation) ResetField(name string) error { case media.FieldAlternativeTitles: m.ResetAlternativeTitles() return nil + case media.FieldCreateTime: + m.ResetCreateTime() + return nil } return fmt.Errorf("unknown Media field %s", name) } @@ -7702,6 +8070,7 @@ type StorageMutation struct { settings *string deleted *bool _default *bool + create_time *time.Time clearedFields map[string]struct{} done bool oldValue func(context.Context) (*Storage, error) @@ -8097,6 +8466,55 @@ func (m *StorageMutation) ResetDefault() { m._default = nil } +// SetCreateTime sets the "create_time" field. +func (m *StorageMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *StorageMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Storage entity. +// If the Storage 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 *StorageMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ClearCreateTime clears the value of the "create_time" field. +func (m *StorageMutation) ClearCreateTime() { + m.create_time = nil + m.clearedFields[storage.FieldCreateTime] = struct{}{} +} + +// CreateTimeCleared returns if the "create_time" field was cleared in this mutation. +func (m *StorageMutation) CreateTimeCleared() bool { + _, ok := m.clearedFields[storage.FieldCreateTime] + return ok +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *StorageMutation) ResetCreateTime() { + m.create_time = nil + delete(m.clearedFields, storage.FieldCreateTime) +} + // Where appends a list predicates to the StorageMutation builder. func (m *StorageMutation) Where(ps ...predicate.Storage) { m.predicates = append(m.predicates, ps...) @@ -8131,7 +8549,7 @@ func (m *StorageMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *StorageMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 8) if m.name != nil { fields = append(fields, storage.FieldName) } @@ -8153,6 +8571,9 @@ func (m *StorageMutation) Fields() []string { if m._default != nil { fields = append(fields, storage.FieldDefault) } + if m.create_time != nil { + fields = append(fields, storage.FieldCreateTime) + } return fields } @@ -8175,6 +8596,8 @@ func (m *StorageMutation) Field(name string) (ent.Value, bool) { return m.Deleted() case storage.FieldDefault: return m.Default() + case storage.FieldCreateTime: + return m.CreateTime() } return nil, false } @@ -8198,6 +8621,8 @@ func (m *StorageMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldDeleted(ctx) case storage.FieldDefault: return m.OldDefault(ctx) + case storage.FieldCreateTime: + return m.OldCreateTime(ctx) } return nil, fmt.Errorf("unknown Storage field %s", name) } @@ -8256,6 +8681,13 @@ func (m *StorageMutation) SetField(name string, value ent.Value) error { } m.SetDefault(v) return nil + case storage.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil } return fmt.Errorf("unknown Storage field %s", name) } @@ -8295,6 +8727,9 @@ func (m *StorageMutation) ClearedFields() []string { if m.FieldCleared(storage.FieldSettings) { fields = append(fields, storage.FieldSettings) } + if m.FieldCleared(storage.FieldCreateTime) { + fields = append(fields, storage.FieldCreateTime) + } return fields } @@ -8318,6 +8753,9 @@ func (m *StorageMutation) ClearField(name string) error { case storage.FieldSettings: m.ClearSettings() return nil + case storage.FieldCreateTime: + m.ClearCreateTime() + return nil } return fmt.Errorf("unknown Storage nullable field %s", name) } @@ -8347,6 +8785,9 @@ func (m *StorageMutation) ResetField(name string) error { case storage.FieldDefault: m.ResetDefault() return nil + case storage.FieldCreateTime: + m.ResetCreateTime() + return nil } return fmt.Errorf("unknown Storage field %s", name) } diff --git a/ent/runtime.go b/ent/runtime.go index 07fe772..193d94e 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -57,18 +57,30 @@ func init() { downloadclientsDescTags := downloadclientsFields[10].Descriptor() // downloadclients.DefaultTags holds the default value on creation for the tags field. downloadclients.DefaultTags = downloadclientsDescTags.Default.(string) + // downloadclientsDescCreateTime is the schema descriptor for create_time field. + downloadclientsDescCreateTime := downloadclientsFields[11].Descriptor() + // downloadclients.DefaultCreateTime holds the default value on creation for the create_time field. + downloadclients.DefaultCreateTime = downloadclientsDescCreateTime.Default.(func() time.Time) episodeFields := schema.Episode{}.Fields() _ = episodeFields // episodeDescMonitored is the schema descriptor for monitored field. episodeDescMonitored := episodeFields[7].Descriptor() // episode.DefaultMonitored holds the default value on creation for the monitored field. episode.DefaultMonitored = episodeDescMonitored.Default.(bool) + // episodeDescCreateTime is the schema descriptor for create_time field. + episodeDescCreateTime := episodeFields[9].Descriptor() + // episode.DefaultCreateTime holds the default value on creation for the create_time field. + episode.DefaultCreateTime = episodeDescCreateTime.Default.(func() time.Time) historyFields := schema.History{}.Fields() _ = historyFields // historyDescSize is the schema descriptor for size field. historyDescSize := historyFields[6].Descriptor() // history.DefaultSize holds the default value on creation for the size field. history.DefaultSize = historyDescSize.Default.(int) + // historyDescCreateTime is the schema descriptor for create_time field. + historyDescCreateTime := historyFields[12].Descriptor() + // history.DefaultCreateTime holds the default value on creation for the create_time field. + history.DefaultCreateTime = historyDescCreateTime.Default.(func() time.Time) indexersFields := schema.Indexers{}.Fields() _ = indexersFields // indexersDescSettings is the schema descriptor for settings field. @@ -103,6 +115,10 @@ func init() { indexersDescSynced := indexersFields[11].Descriptor() // indexers.DefaultSynced holds the default value on creation for the synced field. indexers.DefaultSynced = indexersDescSynced.Default.(bool) + // indexersDescCreateTime is the schema descriptor for create_time field. + indexersDescCreateTime := indexersFields[12].Descriptor() + // indexers.DefaultCreateTime holds the default value on creation for the create_time field. + indexers.DefaultCreateTime = indexersDescCreateTime.Default.(func() time.Time) mediaFields := schema.Media{}.Fields() _ = mediaFields // mediaDescCreatedAt is the schema descriptor for created_at field. @@ -117,6 +133,10 @@ func init() { mediaDescDownloadHistoryEpisodes := mediaFields[12].Descriptor() // media.DefaultDownloadHistoryEpisodes holds the default value on creation for the download_history_episodes field. media.DefaultDownloadHistoryEpisodes = mediaDescDownloadHistoryEpisodes.Default.(bool) + // mediaDescCreateTime is the schema descriptor for create_time field. + mediaDescCreateTime := mediaFields[16].Descriptor() + // media.DefaultCreateTime holds the default value on creation for the create_time field. + media.DefaultCreateTime = mediaDescCreateTime.Default.(func() time.Time) notificationclientFields := schema.NotificationClient{}.Fields() _ = notificationclientFields // notificationclientDescEnabled is the schema descriptor for enabled field. @@ -133,4 +153,8 @@ func init() { storageDescDefault := storageFields[6].Descriptor() // storage.DefaultDefault holds the default value on creation for the default field. storage.DefaultDefault = storageDescDefault.Default.(bool) + // storageDescCreateTime is the schema descriptor for create_time field. + storageDescCreateTime := storageFields[7].Descriptor() + // storage.DefaultCreateTime holds the default value on creation for the create_time field. + storage.DefaultCreateTime = storageDescCreateTime.Default.(func() time.Time) } diff --git a/ent/schema/downloadclients.go b/ent/schema/downloadclients.go index fba74f8..9648ae2 100644 --- a/ent/schema/downloadclients.go +++ b/ent/schema/downloadclients.go @@ -2,6 +2,7 @@ package schema import ( "errors" + "time" "entgo.io/ent" "entgo.io/ent/schema/field" @@ -34,6 +35,7 @@ func (DownloadClients) Fields() []ent.Field { field.Bool("remove_completed_downloads").Default(true), field.Bool("remove_failed_downloads").Default(true), field.String("tags").Default(""), + field.Time("create_time").Optional().Default(time.Now).Immutable(), } } diff --git a/ent/schema/episode.go b/ent/schema/episode.go index 7bd1789..cdfe1e3 100644 --- a/ent/schema/episode.go +++ b/ent/schema/episode.go @@ -1,6 +1,8 @@ package schema import ( + "time" + "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" @@ -23,6 +25,7 @@ func (Episode) Fields() []ent.Field { field.Enum("status").Values("missing", "downloading", "downloaded").Default("missing"), field.Bool("monitored").Default(false).StructTag("json:\"monitored\""), //whether this episode is monitored field.String("target_file").Optional(), + field.Time("create_time").Optional().Default(time.Now).Immutable(), } } diff --git a/ent/schema/history.go b/ent/schema/history.go index 7f7e35d..2ebbae8 100644 --- a/ent/schema/history.go +++ b/ent/schema/history.go @@ -1,6 +1,8 @@ package schema import ( + "time" + "entgo.io/ent" "entgo.io/ent/schema/field" ) @@ -26,6 +28,7 @@ func (History) Fields() []ent.Field { field.String("link").Optional().Comment("deprecated, use hash instead"), //should be magnet link field.String("hash").Optional().Comment("torrent hash"), field.Enum("status").Values("running", "success", "fail", "uploading", "seeding", "removed"), + field.Time("create_time").Optional().Default(time.Now).Immutable(), //field.String("saved").Optional().Comment("deprecated"), //deprecated } } diff --git a/ent/schema/indexers.go b/ent/schema/indexers.go index 49041c1..9ff399e 100644 --- a/ent/schema/indexers.go +++ b/ent/schema/indexers.go @@ -1,6 +1,8 @@ package schema import ( + "time" + "entgo.io/ent" "entgo.io/ent/schema/field" ) @@ -25,6 +27,7 @@ func (Indexers) Fields() []ent.Field { field.String("api_key").Optional(), field.String("url").Optional(), field.Bool("synced").Optional().Default(false).Comment("synced from prowlarr"), + field.Time("create_time").Optional().Default(time.Now).Immutable(), } } diff --git a/ent/schema/media.go b/ent/schema/media.go index a9e09b1..916124f 100644 --- a/ent/schema/media.go +++ b/ent/schema/media.go @@ -32,6 +32,7 @@ func (Media) Fields() []ent.Field { field.JSON("limiter", MediaLimiter{}).Optional(), field.JSON("extras", MediaExtras{}).Optional(), field.JSON("alternative_titles", []AlternativeTilte{}).Optional(), + field.Time("create_time").Optional().Default(time.Now).Immutable(), } } diff --git a/ent/schema/storage.go b/ent/schema/storage.go index cae0cc3..c82e73e 100644 --- a/ent/schema/storage.go +++ b/ent/schema/storage.go @@ -1,6 +1,8 @@ package schema import ( + "time" + "entgo.io/ent" "entgo.io/ent/schema/field" ) @@ -20,6 +22,7 @@ func (Storage) Fields() []ent.Field { field.String("settings").Optional(), field.Bool("deleted").Default(false), field.Bool("default").Default(false), + field.Time("create_time").Optional().Default(time.Now).Immutable(), } } diff --git a/ent/storage.go b/ent/storage.go index 9a90f90..5dec235 100644 --- a/ent/storage.go +++ b/ent/storage.go @@ -6,6 +6,7 @@ import ( "fmt" "polaris/ent/storage" "strings" + "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -29,7 +30,9 @@ type Storage struct { // Deleted holds the value of the "deleted" field. Deleted bool `json:"deleted,omitempty"` // Default holds the value of the "default" field. - Default bool `json:"default,omitempty"` + Default bool `json:"default,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` selectValues sql.SelectValues } @@ -44,6 +47,8 @@ func (*Storage) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullInt64) case storage.FieldName, storage.FieldImplementation, storage.FieldTvPath, storage.FieldMoviePath, storage.FieldSettings: values[i] = new(sql.NullString) + case storage.FieldCreateTime: + values[i] = new(sql.NullTime) default: values[i] = new(sql.UnknownType) } @@ -107,6 +112,12 @@ func (s *Storage) assignValues(columns []string, values []any) error { } else if value.Valid { s.Default = value.Bool } + case storage.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + s.CreateTime = value.Time + } default: s.selectValues.Set(columns[i], values[i]) } @@ -163,6 +174,9 @@ func (s *Storage) String() string { builder.WriteString(", ") builder.WriteString("default=") builder.WriteString(fmt.Sprintf("%v", s.Default)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(s.CreateTime.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } diff --git a/ent/storage/storage.go b/ent/storage/storage.go index 3c977ac..d2111a5 100644 --- a/ent/storage/storage.go +++ b/ent/storage/storage.go @@ -4,6 +4,7 @@ package storage import ( "fmt" + "time" "entgo.io/ent/dialect/sql" ) @@ -27,6 +28,8 @@ const ( FieldDeleted = "deleted" // FieldDefault holds the string denoting the default field in the database. FieldDefault = "default" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" // Table holds the table name of the storage in the database. Table = "storages" ) @@ -41,6 +44,7 @@ var Columns = []string{ FieldSettings, FieldDeleted, FieldDefault, + FieldCreateTime, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -58,6 +62,8 @@ var ( DefaultDeleted bool // DefaultDefault holds the default value on creation for the "default" field. DefaultDefault bool + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time ) // Implementation defines the type for the "implementation" enum field. @@ -126,3 +132,8 @@ func ByDeleted(opts ...sql.OrderTermOption) OrderOption { func ByDefault(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDefault, opts...).ToFunc() } + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} diff --git a/ent/storage/where.go b/ent/storage/where.go index b06851d..536c763 100644 --- a/ent/storage/where.go +++ b/ent/storage/where.go @@ -4,6 +4,7 @@ package storage import ( "polaris/ent/predicate" + "time" "entgo.io/ent/dialect/sql" ) @@ -83,6 +84,11 @@ func Default(v bool) predicate.Storage { return predicate.Storage(sql.FieldEQ(FieldDefault, v)) } +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldEQ(FieldCreateTime, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Storage { return predicate.Storage(sql.FieldEQ(FieldName, v)) @@ -413,6 +419,56 @@ func DefaultNEQ(v bool) predicate.Storage { return predicate.Storage(sql.FieldNEQ(FieldDefault, v)) } +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Storage { + return predicate.Storage(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Storage { + return predicate.Storage(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Storage { + return predicate.Storage(sql.FieldLTE(FieldCreateTime, v)) +} + +// CreateTimeIsNil applies the IsNil predicate on the "create_time" field. +func CreateTimeIsNil() predicate.Storage { + return predicate.Storage(sql.FieldIsNull(FieldCreateTime)) +} + +// CreateTimeNotNil applies the NotNil predicate on the "create_time" field. +func CreateTimeNotNil() predicate.Storage { + return predicate.Storage(sql.FieldNotNull(FieldCreateTime)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Storage) predicate.Storage { return predicate.Storage(sql.AndPredicates(predicates...)) diff --git a/ent/storage_create.go b/ent/storage_create.go index 0b422e2..5c2f2bd 100644 --- a/ent/storage_create.go +++ b/ent/storage_create.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "polaris/ent/storage" + "time" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -101,6 +102,20 @@ func (sc *StorageCreate) SetNillableDefault(b *bool) *StorageCreate { return sc } +// SetCreateTime sets the "create_time" field. +func (sc *StorageCreate) SetCreateTime(t time.Time) *StorageCreate { + sc.mutation.SetCreateTime(t) + return sc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (sc *StorageCreate) SetNillableCreateTime(t *time.Time) *StorageCreate { + if t != nil { + sc.SetCreateTime(*t) + } + return sc +} + // Mutation returns the StorageMutation object of the builder. func (sc *StorageCreate) Mutation() *StorageMutation { return sc.mutation @@ -144,6 +159,10 @@ func (sc *StorageCreate) defaults() { v := storage.DefaultDefault sc.mutation.SetDefault(v) } + if _, ok := sc.mutation.CreateTime(); !ok { + v := storage.DefaultCreateTime() + sc.mutation.SetCreateTime(v) + } } // check runs all checks and user-defined validators on the builder. @@ -219,6 +238,10 @@ func (sc *StorageCreate) createSpec() (*Storage, *sqlgraph.CreateSpec) { _spec.SetField(storage.FieldDefault, field.TypeBool, value) _node.Default = value } + if value, ok := sc.mutation.CreateTime(); ok { + _spec.SetField(storage.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } return _node, _spec } diff --git a/ent/storage_update.go b/ent/storage_update.go index 2d1eaa5..0e710bc 100644 --- a/ent/storage_update.go +++ b/ent/storage_update.go @@ -227,6 +227,9 @@ func (su *StorageUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := su.mutation.Default(); ok { _spec.SetField(storage.FieldDefault, field.TypeBool, value) } + if su.mutation.CreateTimeCleared() { + _spec.ClearField(storage.FieldCreateTime, field.TypeTime) + } if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{storage.Label} @@ -477,6 +480,9 @@ func (suo *StorageUpdateOne) sqlSave(ctx context.Context) (_node *Storage, err e if value, ok := suo.mutation.Default(); ok { _spec.SetField(storage.FieldDefault, field.TypeBool, value) } + if suo.mutation.CreateTimeCleared() { + _spec.ClearField(storage.FieldCreateTime, field.TypeTime) + } _node = &Storage{config: suo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/go.mod b/go.mod index e4141db..59ad8e8 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/robfig/cron v1.2.0 go.uber.org/zap v1.27.0 - golang.org/x/net v0.38.0 + golang.org/x/net v0.39.0 ) require ( @@ -110,7 +110,7 @@ require ( go.opentelemetry.io/otel v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.28.0 // indirect go.opentelemetry.io/otel/trace v1.28.0 // indirect - golang.org/x/sync v0.12.0 // indirect + golang.org/x/sync v0.13.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/appengine v1.6.8 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect @@ -165,11 +165,11 @@ require ( github.com/ugorji/go/codec v1.2.12 // indirect github.com/zclconf/go-cty v1.8.0 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.36.0 + golang.org/x/crypto v0.37.0 golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 golang.org/x/mod v0.24.0 // indirect - golang.org/x/sys v0.31.0 - golang.org/x/text v0.23.0 // indirect + golang.org/x/sys v0.32.0 + golang.org/x/text v0.24.0 // indirect google.golang.org/protobuf v1.36.5 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index bce8d8c..67fd1cd 100644 --- a/go.sum +++ b/go.sum @@ -530,8 +530,8 @@ golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA= @@ -572,8 +572,8 @@ golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -589,8 +589,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -618,8 +618,8 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -643,8 +643,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=