From 0431fbd4223765e96e1042ce9bfe18c7f74ca72a Mon Sep 17 00:00:00 2001 From: Miguel Martinez Date: Thu, 7 Aug 2025 23:06:38 +0200 Subject: [PATCH] fix: group updated at Signed-off-by: Miguel Martinez --- .../ent/migrate/migrations/20250807205444.sql | 3 + .../pkg/data/ent/migrate/migrations/atlas.sum | 3 +- .../pkg/data/ent/migrate/schema.go | 7 +- app/controlplane/pkg/data/ent/mutation.go | 56 +++++++++++++++- app/controlplane/pkg/data/ent/project.go | 13 +++- .../pkg/data/ent/project/project.go | 10 +++ .../pkg/data/ent/project/where.go | 45 +++++++++++++ .../pkg/data/ent/project_create.go | 65 +++++++++++++++++++ .../pkg/data/ent/project_update.go | 34 ++++++++++ app/controlplane/pkg/data/ent/runtime.go | 4 ++ app/controlplane/pkg/data/ent/schema-viz.html | 2 +- .../pkg/data/ent/schema/project.go | 3 + app/controlplane/pkg/data/group.go | 1 + 13 files changed, 239 insertions(+), 7 deletions(-) create mode 100644 app/controlplane/pkg/data/ent/migrate/migrations/20250807205444.sql diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/20250807205444.sql b/app/controlplane/pkg/data/ent/migrate/migrations/20250807205444.sql new file mode 100644 index 000000000..6825d217c --- /dev/null +++ b/app/controlplane/pkg/data/ent/migrate/migrations/20250807205444.sql @@ -0,0 +1,3 @@ +-- Modify "projects" table +ALTER TABLE "projects" ADD COLUMN "updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP; +UPDATE "projects" SET "updated_at" = "created_at"; diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum index 0ad8edd77..ce7d78473 100644 --- a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum +++ b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:IWmhHm1HHN+aqWErXZaZcoJKrFm50tAr0P/n5PwyMLM= +h1:TJzgJ1Ip6wy+vyhg/jxa0t1ap48n+Nw2C/6wavoC/Jo= 20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M= 20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g= 20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI= @@ -102,3 +102,4 @@ h1:IWmhHm1HHN+aqWErXZaZcoJKrFm50tAr0P/n5PwyMLM= 20250723171233.sql h1:Aq4IUr4ForrwmK9jMPPtwl4V8e2plYff/IcSgIc0XFo= 20250728123421.sql h1:VaxxLhVF2PXQ6Vjv4nSWHQjHLM8O9anMxgDMnCkL21I= 20250805225449.sql h1:L1M7mR2PuAVoT7bDo9rAoy+eUN7C25sm5Yj1o+zlvhk= +20250807205444.sql h1:NUcfS9KBU6RXl0cOFBlEUP51qh5XBzlmDyedTlaY4Lc= diff --git a/app/controlplane/pkg/data/ent/migrate/schema.go b/app/controlplane/pkg/data/ent/migrate/schema.go index 24d3fafb6..c1c4efa9d 100644 --- a/app/controlplane/pkg/data/ent/migrate/schema.go +++ b/app/controlplane/pkg/data/ent/migrate/schema.go @@ -429,6 +429,7 @@ var ( {Name: "name", Type: field.TypeString}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "created_at", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"}, + {Name: "updated_at", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"}, {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, {Name: "organization_id", Type: field.TypeUUID}, } @@ -440,7 +441,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "projects_organizations_projects", - Columns: []*schema.Column{ProjectsColumns[5]}, + Columns: []*schema.Column{ProjectsColumns[6]}, RefColumns: []*schema.Column{OrganizationsColumns[0]}, OnDelete: schema.Cascade, }, @@ -449,7 +450,7 @@ var ( { Name: "project_name_organization_id", Unique: true, - Columns: []*schema.Column{ProjectsColumns[1], ProjectsColumns[5]}, + Columns: []*schema.Column{ProjectsColumns[1], ProjectsColumns[6]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, @@ -457,7 +458,7 @@ var ( { Name: "project_organization_id", Unique: false, - Columns: []*schema.Column{ProjectsColumns[5]}, + Columns: []*schema.Column{ProjectsColumns[6]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, diff --git a/app/controlplane/pkg/data/ent/mutation.go b/app/controlplane/pkg/data/ent/mutation.go index 4aec5d80b..02787cf95 100644 --- a/app/controlplane/pkg/data/ent/mutation.go +++ b/app/controlplane/pkg/data/ent/mutation.go @@ -9599,6 +9599,7 @@ type ProjectMutation struct { name *string description *string created_at *time.Time + updated_at *time.Time deleted_at *time.Time clearedFields map[string]struct{} organization *uuid.UUID @@ -9839,6 +9840,42 @@ func (m *ProjectMutation) ResetCreatedAt() { m.created_at = nil } +// SetUpdatedAt sets the "updated_at" field. +func (m *ProjectMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *ProjectMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the Project entity. +// If the Project 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 *ProjectMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *ProjectMutation) ResetUpdatedAt() { + m.updated_at = nil +} + // SetDeletedAt sets the "deleted_at" field. func (m *ProjectMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t @@ -10093,7 +10130,7 @@ func (m *ProjectMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ProjectMutation) Fields() []string { - fields := make([]string, 0, 5) + fields := make([]string, 0, 6) if m.name != nil { fields = append(fields, project.FieldName) } @@ -10103,6 +10140,9 @@ func (m *ProjectMutation) Fields() []string { if m.created_at != nil { fields = append(fields, project.FieldCreatedAt) } + if m.updated_at != nil { + fields = append(fields, project.FieldUpdatedAt) + } if m.deleted_at != nil { fields = append(fields, project.FieldDeletedAt) } @@ -10123,6 +10163,8 @@ func (m *ProjectMutation) Field(name string) (ent.Value, bool) { return m.Description() case project.FieldCreatedAt: return m.CreatedAt() + case project.FieldUpdatedAt: + return m.UpdatedAt() case project.FieldDeletedAt: return m.DeletedAt() case project.FieldOrganizationID: @@ -10142,6 +10184,8 @@ func (m *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldDescription(ctx) case project.FieldCreatedAt: return m.OldCreatedAt(ctx) + case project.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) case project.FieldDeletedAt: return m.OldDeletedAt(ctx) case project.FieldOrganizationID: @@ -10176,6 +10220,13 @@ func (m *ProjectMutation) SetField(name string, value ent.Value) error { } m.SetCreatedAt(v) return nil + case project.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil case project.FieldDeletedAt: v, ok := value.(time.Time) if !ok { @@ -10263,6 +10314,9 @@ func (m *ProjectMutation) ResetField(name string) error { case project.FieldCreatedAt: m.ResetCreatedAt() return nil + case project.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil case project.FieldDeletedAt: m.ResetDeletedAt() return nil diff --git a/app/controlplane/pkg/data/ent/project.go b/app/controlplane/pkg/data/ent/project.go index 57890818d..2e1474596 100644 --- a/app/controlplane/pkg/data/ent/project.go +++ b/app/controlplane/pkg/data/ent/project.go @@ -25,6 +25,8 @@ type Project struct { Description string `json:"description,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt time.Time `json:"created_at,omitempty"` + // UpdatedAt holds the value of the "updated_at" field. + UpdatedAt time.Time `json:"updated_at,omitempty"` // DeletedAt holds the value of the "deleted_at" field. DeletedAt time.Time `json:"deleted_at,omitempty"` // OrganizationID holds the value of the "organization_id" field. @@ -84,7 +86,7 @@ func (*Project) scanValues(columns []string) ([]any, error) { switch columns[i] { case project.FieldName, project.FieldDescription: values[i] = new(sql.NullString) - case project.FieldCreatedAt, project.FieldDeletedAt: + case project.FieldCreatedAt, project.FieldUpdatedAt, project.FieldDeletedAt: values[i] = new(sql.NullTime) case project.FieldID, project.FieldOrganizationID: values[i] = new(uuid.UUID) @@ -127,6 +129,12 @@ func (pr *Project) assignValues(columns []string, values []any) error { } else if value.Valid { pr.CreatedAt = value.Time } + case project.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field updated_at", values[i]) + } else if value.Valid { + pr.UpdatedAt = value.Time + } case project.FieldDeletedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) @@ -199,6 +207,9 @@ func (pr *Project) String() string { builder.WriteString("created_at=") builder.WriteString(pr.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") + builder.WriteString("updated_at=") + builder.WriteString(pr.UpdatedAt.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("deleted_at=") builder.WriteString(pr.DeletedAt.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/app/controlplane/pkg/data/ent/project/project.go b/app/controlplane/pkg/data/ent/project/project.go index ed3bf6189..65a6d0db2 100644 --- a/app/controlplane/pkg/data/ent/project/project.go +++ b/app/controlplane/pkg/data/ent/project/project.go @@ -21,6 +21,8 @@ const ( FieldDescription = "description" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" + // FieldUpdatedAt holds the string denoting the updated_at field in the database. + FieldUpdatedAt = "updated_at" // FieldDeletedAt holds the string denoting the deleted_at field in the database. FieldDeletedAt = "deleted_at" // FieldOrganizationID holds the string denoting the organization_id field in the database. @@ -62,6 +64,7 @@ var Columns = []string{ FieldName, FieldDescription, FieldCreatedAt, + FieldUpdatedAt, FieldDeletedAt, FieldOrganizationID, } @@ -81,6 +84,8 @@ var ( NameValidator func(string) error // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time + // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. + DefaultUpdatedAt func() time.Time // DefaultID holds the default value on creation for the "id" field. DefaultID func() uuid.UUID ) @@ -108,6 +113,11 @@ func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } +// ByUpdatedAt orders the results by the updated_at field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} + // ByDeletedAt orders the results by the deleted_at field. func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() diff --git a/app/controlplane/pkg/data/ent/project/where.go b/app/controlplane/pkg/data/ent/project/where.go index 546a3240e..499863bd7 100644 --- a/app/controlplane/pkg/data/ent/project/where.go +++ b/app/controlplane/pkg/data/ent/project/where.go @@ -71,6 +71,11 @@ func CreatedAt(v time.Time) predicate.Project { return predicate.Project(sql.FieldEQ(FieldCreatedAt, v)) } +// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v time.Time) predicate.Project { + return predicate.Project(sql.FieldEQ(FieldUpdatedAt, v)) +} + // DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. func DeletedAt(v time.Time) predicate.Project { return predicate.Project(sql.FieldEQ(FieldDeletedAt, v)) @@ -261,6 +266,46 @@ func CreatedAtLTE(v time.Time) predicate.Project { return predicate.Project(sql.FieldLTE(FieldCreatedAt, v)) } +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.Project { + return predicate.Project(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.Project { + return predicate.Project(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.Project { + return predicate.Project(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.Project { + return predicate.Project(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.Project { + return predicate.Project(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.Project { + return predicate.Project(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.Project { + return predicate.Project(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.Project { + return predicate.Project(sql.FieldLTE(FieldUpdatedAt, v)) +} + // DeletedAtEQ applies the EQ predicate on the "deleted_at" field. func DeletedAtEQ(v time.Time) predicate.Project { return predicate.Project(sql.FieldEQ(FieldDeletedAt, v)) diff --git a/app/controlplane/pkg/data/ent/project_create.go b/app/controlplane/pkg/data/ent/project_create.go index 9f3483885..8bf5da8b1 100644 --- a/app/controlplane/pkg/data/ent/project_create.go +++ b/app/controlplane/pkg/data/ent/project_create.go @@ -61,6 +61,20 @@ func (pc *ProjectCreate) SetNillableCreatedAt(t *time.Time) *ProjectCreate { return pc } +// SetUpdatedAt sets the "updated_at" field. +func (pc *ProjectCreate) SetUpdatedAt(t time.Time) *ProjectCreate { + pc.mutation.SetUpdatedAt(t) + return pc +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (pc *ProjectCreate) SetNillableUpdatedAt(t *time.Time) *ProjectCreate { + if t != nil { + pc.SetUpdatedAt(*t) + } + return pc +} + // SetDeletedAt sets the "deleted_at" field. func (pc *ProjectCreate) SetDeletedAt(t time.Time) *ProjectCreate { pc.mutation.SetDeletedAt(t) @@ -169,6 +183,10 @@ func (pc *ProjectCreate) defaults() { v := project.DefaultCreatedAt() pc.mutation.SetCreatedAt(v) } + if _, ok := pc.mutation.UpdatedAt(); !ok { + v := project.DefaultUpdatedAt() + pc.mutation.SetUpdatedAt(v) + } if _, ok := pc.mutation.ID(); !ok { v := project.DefaultID() pc.mutation.SetID(v) @@ -188,6 +206,9 @@ func (pc *ProjectCreate) check() error { if _, ok := pc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Project.created_at"`)} } + if _, ok := pc.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Project.updated_at"`)} + } if _, ok := pc.mutation.OrganizationID(); !ok { return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Project.organization_id"`)} } @@ -242,6 +263,10 @@ func (pc *ProjectCreate) createSpec() (*Project, *sqlgraph.CreateSpec) { _spec.SetField(project.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } + if value, ok := pc.mutation.UpdatedAt(); ok { + _spec.SetField(project.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } if value, ok := pc.mutation.DeletedAt(); ok { _spec.SetField(project.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = value @@ -365,6 +390,18 @@ func (u *ProjectUpsert) ClearDescription() *ProjectUpsert { return u } +// SetUpdatedAt sets the "updated_at" field. +func (u *ProjectUpsert) SetUpdatedAt(v time.Time) *ProjectUpsert { + u.Set(project.FieldUpdatedAt, v) + return u +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ProjectUpsert) UpdateUpdatedAt() *ProjectUpsert { + u.SetExcluded(project.FieldUpdatedAt) + return u +} + // SetDeletedAt sets the "deleted_at" field. func (u *ProjectUpsert) SetDeletedAt(v time.Time) *ProjectUpsert { u.Set(project.FieldDeletedAt, v) @@ -461,6 +498,20 @@ func (u *ProjectUpsertOne) ClearDescription() *ProjectUpsertOne { }) } +// SetUpdatedAt sets the "updated_at" field. +func (u *ProjectUpsertOne) SetUpdatedAt(v time.Time) *ProjectUpsertOne { + return u.Update(func(s *ProjectUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ProjectUpsertOne) UpdateUpdatedAt() *ProjectUpsertOne { + return u.Update(func(s *ProjectUpsert) { + s.UpdateUpdatedAt() + }) +} + // SetDeletedAt sets the "deleted_at" field. func (u *ProjectUpsertOne) SetDeletedAt(v time.Time) *ProjectUpsertOne { return u.Update(func(s *ProjectUpsert) { @@ -727,6 +778,20 @@ func (u *ProjectUpsertBulk) ClearDescription() *ProjectUpsertBulk { }) } +// SetUpdatedAt sets the "updated_at" field. +func (u *ProjectUpsertBulk) SetUpdatedAt(v time.Time) *ProjectUpsertBulk { + return u.Update(func(s *ProjectUpsert) { + s.SetUpdatedAt(v) + }) +} + +// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. +func (u *ProjectUpsertBulk) UpdateUpdatedAt() *ProjectUpsertBulk { + return u.Update(func(s *ProjectUpsert) { + s.UpdateUpdatedAt() + }) +} + // SetDeletedAt sets the "deleted_at" field. func (u *ProjectUpsertBulk) SetDeletedAt(v time.Time) *ProjectUpsertBulk { return u.Update(func(s *ProjectUpsert) { diff --git a/app/controlplane/pkg/data/ent/project_update.go b/app/controlplane/pkg/data/ent/project_update.go index c80422fd4..f563ea521 100644 --- a/app/controlplane/pkg/data/ent/project_update.go +++ b/app/controlplane/pkg/data/ent/project_update.go @@ -52,6 +52,20 @@ func (pu *ProjectUpdate) ClearDescription() *ProjectUpdate { return pu } +// SetUpdatedAt sets the "updated_at" field. +func (pu *ProjectUpdate) SetUpdatedAt(t time.Time) *ProjectUpdate { + pu.mutation.SetUpdatedAt(t) + return pu +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (pu *ProjectUpdate) SetNillableUpdatedAt(t *time.Time) *ProjectUpdate { + if t != nil { + pu.SetUpdatedAt(*t) + } + return pu +} + // SetDeletedAt sets the "deleted_at" field. func (pu *ProjectUpdate) SetDeletedAt(t time.Time) *ProjectUpdate { pu.mutation.SetDeletedAt(t) @@ -208,6 +222,9 @@ func (pu *ProjectUpdate) sqlSave(ctx context.Context) (n int, err error) { if pu.mutation.DescriptionCleared() { _spec.ClearField(project.FieldDescription, field.TypeString) } + if value, ok := pu.mutation.UpdatedAt(); ok { + _spec.SetField(project.FieldUpdatedAt, field.TypeTime, value) + } if value, ok := pu.mutation.DeletedAt(); ok { _spec.SetField(project.FieldDeletedAt, field.TypeTime, value) } @@ -346,6 +363,20 @@ func (puo *ProjectUpdateOne) ClearDescription() *ProjectUpdateOne { return puo } +// SetUpdatedAt sets the "updated_at" field. +func (puo *ProjectUpdateOne) SetUpdatedAt(t time.Time) *ProjectUpdateOne { + puo.mutation.SetUpdatedAt(t) + return puo +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (puo *ProjectUpdateOne) SetNillableUpdatedAt(t *time.Time) *ProjectUpdateOne { + if t != nil { + puo.SetUpdatedAt(*t) + } + return puo +} + // SetDeletedAt sets the "deleted_at" field. func (puo *ProjectUpdateOne) SetDeletedAt(t time.Time) *ProjectUpdateOne { puo.mutation.SetDeletedAt(t) @@ -532,6 +563,9 @@ func (puo *ProjectUpdateOne) sqlSave(ctx context.Context) (_node *Project, err e if puo.mutation.DescriptionCleared() { _spec.ClearField(project.FieldDescription, field.TypeString) } + if value, ok := puo.mutation.UpdatedAt(); ok { + _spec.SetField(project.FieldUpdatedAt, field.TypeTime, value) + } if value, ok := puo.mutation.DeletedAt(); ok { _spec.SetField(project.FieldDeletedAt, field.TypeTime, value) } diff --git a/app/controlplane/pkg/data/ent/runtime.go b/app/controlplane/pkg/data/ent/runtime.go index ddead0d38..a30d2da45 100644 --- a/app/controlplane/pkg/data/ent/runtime.go +++ b/app/controlplane/pkg/data/ent/runtime.go @@ -209,6 +209,10 @@ func init() { projectDescCreatedAt := projectFields[3].Descriptor() // project.DefaultCreatedAt holds the default value on creation for the created_at field. project.DefaultCreatedAt = projectDescCreatedAt.Default.(func() time.Time) + // projectDescUpdatedAt is the schema descriptor for updated_at field. + projectDescUpdatedAt := projectFields[4].Descriptor() + // project.DefaultUpdatedAt holds the default value on creation for the updated_at field. + project.DefaultUpdatedAt = projectDescUpdatedAt.Default.(func() time.Time) // projectDescID is the schema descriptor for id field. projectDescID := projectFields[0].Descriptor() // project.DefaultID holds the default value on creation for the id field. diff --git a/app/controlplane/pkg/data/ent/schema-viz.html b/app/controlplane/pkg/data/ent/schema-viz.html index ee23b963c..91e1fac7b 100644 --- a/app/controlplane/pkg/data/ent/schema-viz.html +++ b/app/controlplane/pkg/data/ent/schema-viz.html @@ -70,7 +70,7 @@ } - const entGraph = JSON.parse("{\"nodes\":[{\"id\":\"APIToken\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"expires_at\",\"type\":\"time.Time\"},{\"name\":\"revoked_at\",\"type\":\"time.Time\"},{\"name\":\"last_used_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Attestation\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"bundle\",\"type\":\"[]byte\"},{\"name\":\"workflowrun_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"CASBackend\",\"fields\":[{\"name\":\"location\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"provider\",\"type\":\"biz.CASBackendProvider\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"validation_status\",\"type\":\"biz.CASBackendValidationStatus\"},{\"name\":\"validated_at\",\"type\":\"time.Time\"},{\"name\":\"default\",\"type\":\"bool\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"fallback\",\"type\":\"bool\"},{\"name\":\"max_blob_size_bytes\",\"type\":\"int64\"}]},{\"id\":\"CASMapping\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"workflow_run_id\",\"type\":\"uuid.UUID\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Group\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"member_count\",\"type\":\"int\"}]},{\"id\":\"GroupMembership\",\"fields\":[{\"name\":\"group_id\",\"type\":\"uuid.UUID\"},{\"name\":\"user_id\",\"type\":\"uuid.UUID\"},{\"name\":\"maintainer\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"Integration\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"IntegrationAttachment\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"workflow_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Membership\",\"fields\":[{\"name\":\"current\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"role\",\"type\":\"authz.Role\"},{\"name\":\"membership_type\",\"type\":\"authz.MembershipType\"},{\"name\":\"member_id\",\"type\":\"uuid.UUID\"},{\"name\":\"resource_type\",\"type\":\"authz.ResourceType\"},{\"name\":\"resource_id\",\"type\":\"uuid.UUID\"},{\"name\":\"parent_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"OrgInvitation\",\"fields\":[{\"name\":\"receiver_email\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"biz.OrgInvitationStatus\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"sender_id\",\"type\":\"uuid.UUID\"},{\"name\":\"role\",\"type\":\"authz.Role\"},{\"name\":\"context\",\"type\":\"biz.OrgInvitationContext\"}]},{\"id\":\"Organization\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"block_on_policy_violation\",\"type\":\"bool\"}]},{\"id\":\"Project\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"ProjectVersion\",\"fields\":[{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"},{\"name\":\"prerelease\",\"type\":\"bool\"},{\"name\":\"workflow_run_count\",\"type\":\"int\"},{\"name\":\"released_at\",\"type\":\"time.Time\"},{\"name\":\"latest\",\"type\":\"bool\"}]},{\"id\":\"Referrer\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"downloadable\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"metadata\",\"type\":\"map[string]string\"},{\"name\":\"annotations\",\"type\":\"map[string]string\"}]},{\"id\":\"RobotAccount\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"revoked_at\",\"type\":\"time.Time\"}]},{\"id\":\"User\",\"fields\":[{\"name\":\"email\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"has_restricted_access\",\"type\":\"bool\"},{\"name\":\"first_name\",\"type\":\"string\"},{\"name\":\"last_name\",\"type\":\"string\"}]},{\"id\":\"Workflow\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"project_old\",\"type\":\"string\"},{\"name\":\"team\",\"type\":\"string\"},{\"name\":\"runs_count\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"public\",\"type\":\"bool\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"},{\"name\":\"latest_run\",\"type\":\"uuid.UUID\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"metadata\",\"type\":\"map[string]interface {}\"}]},{\"id\":\"WorkflowContract\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"scoped_resource_type\",\"type\":\"biz.ContractScope\"},{\"name\":\"scoped_resource_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"WorkflowContractVersion\",\"fields\":[{\"name\":\"body\",\"type\":\"[]byte\"},{\"name\":\"raw_body\",\"type\":\"[]byte\"},{\"name\":\"raw_body_format\",\"type\":\"unmarshal.RawFormat\"},{\"name\":\"revision\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"WorkflowRun\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"finished_at\",\"type\":\"time.Time\"},{\"name\":\"state\",\"type\":\"biz.WorkflowRunStatus\"},{\"name\":\"reason\",\"type\":\"string\"},{\"name\":\"run_url\",\"type\":\"string\"},{\"name\":\"runner_type\",\"type\":\"string\"},{\"name\":\"attestation\",\"type\":\"*dsse.Envelope\"},{\"name\":\"attestation_digest\",\"type\":\"string\"},{\"name\":\"attestation_state\",\"type\":\"[]byte\"},{\"name\":\"contract_revision_used\",\"type\":\"int\"},{\"name\":\"contract_revision_latest\",\"type\":\"int\"},{\"name\":\"version_id\",\"type\":\"uuid.UUID\"},{\"name\":\"workflow_id\",\"type\":\"uuid.UUID\"}]}],\"edges\":[{\"from\":\"APIToken\",\"to\":\"Project\",\"label\":\"project\"},{\"from\":\"CASMapping\",\"to\":\"CASBackend\",\"label\":\"cas_backend\"},{\"from\":\"CASMapping\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"CASMapping\",\"to\":\"Project\",\"label\":\"project\"},{\"from\":\"GroupMembership\",\"to\":\"Group\",\"label\":\"group\"},{\"from\":\"GroupMembership\",\"to\":\"User\",\"label\":\"user\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Integration\",\"label\":\"integration\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Workflow\",\"label\":\"workflow\"},{\"from\":\"Membership\",\"to\":\"Membership\",\"label\":\"children\"},{\"from\":\"OrgInvitation\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"OrgInvitation\",\"to\":\"User\",\"label\":\"sender\"},{\"from\":\"Organization\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Organization\",\"to\":\"WorkflowContract\",\"label\":\"workflow_contracts\"},{\"from\":\"Organization\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"Organization\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"},{\"from\":\"Organization\",\"to\":\"Integration\",\"label\":\"integrations\"},{\"from\":\"Organization\",\"to\":\"APIToken\",\"label\":\"api_tokens\"},{\"from\":\"Organization\",\"to\":\"Project\",\"label\":\"projects\"},{\"from\":\"Organization\",\"to\":\"Group\",\"label\":\"groups\"},{\"from\":\"Project\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"Project\",\"to\":\"ProjectVersion\",\"label\":\"versions\"},{\"from\":\"ProjectVersion\",\"to\":\"WorkflowRun\",\"label\":\"runs\"},{\"from\":\"Referrer\",\"to\":\"Referrer\",\"label\":\"references\"},{\"from\":\"Referrer\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"User\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Workflow\",\"to\":\"RobotAccount\",\"label\":\"robotaccounts\"},{\"from\":\"Workflow\",\"to\":\"WorkflowRun\",\"label\":\"workflowruns\"},{\"from\":\"Workflow\",\"to\":\"WorkflowContract\",\"label\":\"contract\"},{\"from\":\"Workflow\",\"to\":\"WorkflowRun\",\"label\":\"latest_workflow_run\"},{\"from\":\"WorkflowContract\",\"to\":\"WorkflowContractVersion\",\"label\":\"versions\"},{\"from\":\"WorkflowRun\",\"to\":\"WorkflowContractVersion\",\"label\":\"contract_version\"},{\"from\":\"WorkflowRun\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"},{\"from\":\"WorkflowRun\",\"to\":\"Attestation\",\"label\":\"attestation_bundle\"}]}"); + const entGraph = JSON.parse("{\"nodes\":[{\"id\":\"APIToken\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"expires_at\",\"type\":\"time.Time\"},{\"name\":\"revoked_at\",\"type\":\"time.Time\"},{\"name\":\"last_used_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Attestation\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"bundle\",\"type\":\"[]byte\"},{\"name\":\"workflowrun_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"CASBackend\",\"fields\":[{\"name\":\"location\",\"type\":\"string\"},{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"provider\",\"type\":\"biz.CASBackendProvider\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"validation_status\",\"type\":\"biz.CASBackendValidationStatus\"},{\"name\":\"validated_at\",\"type\":\"time.Time\"},{\"name\":\"default\",\"type\":\"bool\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"fallback\",\"type\":\"bool\"},{\"name\":\"max_blob_size_bytes\",\"type\":\"int64\"}]},{\"id\":\"CASMapping\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"workflow_run_id\",\"type\":\"uuid.UUID\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Group\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"member_count\",\"type\":\"int\"}]},{\"id\":\"GroupMembership\",\"fields\":[{\"name\":\"group_id\",\"type\":\"uuid.UUID\"},{\"name\":\"user_id\",\"type\":\"uuid.UUID\"},{\"name\":\"maintainer\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"Integration\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"IntegrationAttachment\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"workflow_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Membership\",\"fields\":[{\"name\":\"current\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"role\",\"type\":\"authz.Role\"},{\"name\":\"membership_type\",\"type\":\"authz.MembershipType\"},{\"name\":\"member_id\",\"type\":\"uuid.UUID\"},{\"name\":\"resource_type\",\"type\":\"authz.ResourceType\"},{\"name\":\"resource_id\",\"type\":\"uuid.UUID\"},{\"name\":\"parent_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"OrgInvitation\",\"fields\":[{\"name\":\"receiver_email\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"biz.OrgInvitationStatus\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"sender_id\",\"type\":\"uuid.UUID\"},{\"name\":\"role\",\"type\":\"authz.Role\"},{\"name\":\"context\",\"type\":\"biz.OrgInvitationContext\"}]},{\"id\":\"Organization\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"block_on_policy_violation\",\"type\":\"bool\"}]},{\"id\":\"Project\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"ProjectVersion\",\"fields\":[{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"},{\"name\":\"prerelease\",\"type\":\"bool\"},{\"name\":\"workflow_run_count\",\"type\":\"int\"},{\"name\":\"released_at\",\"type\":\"time.Time\"},{\"name\":\"latest\",\"type\":\"bool\"}]},{\"id\":\"Referrer\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"downloadable\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"metadata\",\"type\":\"map[string]string\"},{\"name\":\"annotations\",\"type\":\"map[string]string\"}]},{\"id\":\"RobotAccount\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"revoked_at\",\"type\":\"time.Time\"}]},{\"id\":\"User\",\"fields\":[{\"name\":\"email\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"has_restricted_access\",\"type\":\"bool\"},{\"name\":\"first_name\",\"type\":\"string\"},{\"name\":\"last_name\",\"type\":\"string\"}]},{\"id\":\"Workflow\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"project_old\",\"type\":\"string\"},{\"name\":\"team\",\"type\":\"string\"},{\"name\":\"runs_count\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"public\",\"type\":\"bool\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"project_id\",\"type\":\"uuid.UUID\"},{\"name\":\"latest_run\",\"type\":\"uuid.UUID\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"metadata\",\"type\":\"map[string]interface {}\"}]},{\"id\":\"WorkflowContract\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"scoped_resource_type\",\"type\":\"biz.ContractScope\"},{\"name\":\"scoped_resource_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"WorkflowContractVersion\",\"fields\":[{\"name\":\"body\",\"type\":\"[]byte\"},{\"name\":\"raw_body\",\"type\":\"[]byte\"},{\"name\":\"raw_body_format\",\"type\":\"unmarshal.RawFormat\"},{\"name\":\"revision\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"WorkflowRun\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"finished_at\",\"type\":\"time.Time\"},{\"name\":\"state\",\"type\":\"biz.WorkflowRunStatus\"},{\"name\":\"reason\",\"type\":\"string\"},{\"name\":\"run_url\",\"type\":\"string\"},{\"name\":\"runner_type\",\"type\":\"string\"},{\"name\":\"attestation\",\"type\":\"*dsse.Envelope\"},{\"name\":\"attestation_digest\",\"type\":\"string\"},{\"name\":\"attestation_state\",\"type\":\"[]byte\"},{\"name\":\"contract_revision_used\",\"type\":\"int\"},{\"name\":\"contract_revision_latest\",\"type\":\"int\"},{\"name\":\"version_id\",\"type\":\"uuid.UUID\"},{\"name\":\"workflow_id\",\"type\":\"uuid.UUID\"}]}],\"edges\":[{\"from\":\"APIToken\",\"to\":\"Project\",\"label\":\"project\"},{\"from\":\"CASMapping\",\"to\":\"CASBackend\",\"label\":\"cas_backend\"},{\"from\":\"CASMapping\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"CASMapping\",\"to\":\"Project\",\"label\":\"project\"},{\"from\":\"GroupMembership\",\"to\":\"Group\",\"label\":\"group\"},{\"from\":\"GroupMembership\",\"to\":\"User\",\"label\":\"user\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Integration\",\"label\":\"integration\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Workflow\",\"label\":\"workflow\"},{\"from\":\"Membership\",\"to\":\"Membership\",\"label\":\"children\"},{\"from\":\"OrgInvitation\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"OrgInvitation\",\"to\":\"User\",\"label\":\"sender\"},{\"from\":\"Organization\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Organization\",\"to\":\"WorkflowContract\",\"label\":\"workflow_contracts\"},{\"from\":\"Organization\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"Organization\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"},{\"from\":\"Organization\",\"to\":\"Integration\",\"label\":\"integrations\"},{\"from\":\"Organization\",\"to\":\"APIToken\",\"label\":\"api_tokens\"},{\"from\":\"Organization\",\"to\":\"Project\",\"label\":\"projects\"},{\"from\":\"Organization\",\"to\":\"Group\",\"label\":\"groups\"},{\"from\":\"Project\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"Project\",\"to\":\"ProjectVersion\",\"label\":\"versions\"},{\"from\":\"ProjectVersion\",\"to\":\"WorkflowRun\",\"label\":\"runs\"},{\"from\":\"Referrer\",\"to\":\"Referrer\",\"label\":\"references\"},{\"from\":\"Referrer\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"User\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Workflow\",\"to\":\"RobotAccount\",\"label\":\"robotaccounts\"},{\"from\":\"Workflow\",\"to\":\"WorkflowRun\",\"label\":\"workflowruns\"},{\"from\":\"Workflow\",\"to\":\"WorkflowContract\",\"label\":\"contract\"},{\"from\":\"Workflow\",\"to\":\"WorkflowRun\",\"label\":\"latest_workflow_run\"},{\"from\":\"WorkflowContract\",\"to\":\"WorkflowContractVersion\",\"label\":\"versions\"},{\"from\":\"WorkflowRun\",\"to\":\"WorkflowContractVersion\",\"label\":\"contract_version\"},{\"from\":\"WorkflowRun\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"},{\"from\":\"WorkflowRun\",\"to\":\"Attestation\",\"label\":\"attestation_bundle\"}]}"); const nodes = new vis.DataSet((entGraph.nodes || []).map(n => ({ id: n.id, diff --git a/app/controlplane/pkg/data/ent/schema/project.go b/app/controlplane/pkg/data/ent/schema/project.go index 1f63fd4b5..b32e5cde4 100644 --- a/app/controlplane/pkg/data/ent/schema/project.go +++ b/app/controlplane/pkg/data/ent/schema/project.go @@ -44,6 +44,9 @@ func (Project) Fields() []ent.Field { Annotations(&entsql.Annotation{ Default: "CURRENT_TIMESTAMP", }), + field.Time("updated_at"). + Default(time.Now). + Annotations(&entsql.Annotation{Default: "CURRENT_TIMESTAMP"}), field.Time("deleted_at").Optional(), field.UUID("organization_id", uuid.UUID{}).Immutable(), } diff --git a/app/controlplane/pkg/data/group.go b/app/controlplane/pkg/data/group.go index 64175f9e8..3326fbcd0 100644 --- a/app/controlplane/pkg/data/group.go +++ b/app/controlplane/pkg/data/group.go @@ -351,6 +351,7 @@ func (g GroupRepo) Update(ctx context.Context, orgID uuid.UUID, groupID uuid.UUI entGroup, err := g.data.DB.Group.UpdateOneID(groupID). SetNillableName(opts.NewName). SetNillableDescription(opts.NewDescription). + SetUpdatedAt(time.Now()). Where(group.OrganizationIDEQ(orgID), group.DeletedAtIsNil()). Save(ctx) if err != nil {