diff --git a/model/ent/entc.go b/model/ent/entc.go index 93c55b5d..99d306e0 100644 --- a/model/ent/entc.go +++ b/model/ent/entc.go @@ -1,4 +1,4 @@ -// +build ignore +//go:build ignore package main diff --git a/model/ent/repo/repo.go b/model/ent/repo/repo.go index ac78e78e..64dbcbd0 100644 --- a/model/ent/repo/repo.go +++ b/model/ent/repo/repo.go @@ -116,4 +116,6 @@ var ( DefaultUpdatedAt func() time.Time // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. UpdateDefaultUpdatedAt func() time.Time + // DefaultLatestDeployedAt holds the default value on creation for the "latest_deployed_at" field. + DefaultLatestDeployedAt func() time.Time ) diff --git a/model/ent/repo_create.go b/model/ent/repo_create.go index 89d384e0..21107a8a 100644 --- a/model/ent/repo_create.go +++ b/model/ent/repo_create.go @@ -299,6 +299,10 @@ func (rc *RepoCreate) defaults() { v := repo.DefaultUpdatedAt() rc.mutation.SetUpdatedAt(v) } + if _, ok := rc.mutation.LatestDeployedAt(); !ok { + v := repo.DefaultLatestDeployedAt() + rc.mutation.SetLatestDeployedAt(v) + } } // check runs all checks and user-defined validators on the builder. diff --git a/model/ent/runtime.go b/model/ent/runtime.go index 43d4ffe0..7a80ec2b 100644 --- a/model/ent/runtime.go +++ b/model/ent/runtime.go @@ -154,6 +154,10 @@ func init() { repo.DefaultUpdatedAt = repoDescUpdatedAt.Default.(func() time.Time) // repo.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. repo.UpdateDefaultUpdatedAt = repoDescUpdatedAt.UpdateDefault.(func() time.Time) + // repoDescLatestDeployedAt is the schema descriptor for latest_deployed_at field. + repoDescLatestDeployedAt := repoFields[9].Descriptor() + // repo.DefaultLatestDeployedAt holds the default value on creation for the latest_deployed_at field. + repo.DefaultLatestDeployedAt = repoDescLatestDeployedAt.Default.(func() time.Time) reviewFields := schema.Review{}.Fields() _ = reviewFields // reviewDescCreatedAt is the schema descriptor for created_at field. diff --git a/model/ent/schema/repo.go b/model/ent/schema/repo.go index 0888b86c..02823580 100644 --- a/model/ent/schema/repo.go +++ b/model/ent/schema/repo.go @@ -34,6 +34,7 @@ func (Repo) Fields() []ent.Field { UpdateDefault(nowUTC), // Denormalization to sort with deployment. field.Time("latest_deployed_at"). + Default(zeroTime). Optional(), // The 'owner_id' field is the ID who activated the repository. field.Int64("owner_id"). diff --git a/model/ent/schema/shared.go b/model/ent/schema/shared.go index f2b765c3..1f723b4c 100644 --- a/model/ent/schema/shared.go +++ b/model/ent/schema/shared.go @@ -19,3 +19,7 @@ func generateHash() string { func nowUTC() time.Time { return time.Now().UTC() } + +func zeroTime() time.Time { + return time.Time{} +}