@@ -8,6 +8,13 @@ import (
88 "gopkg.in/guregu/null.v4"
99)
1010
11+ // TimeMetadata contains fields of when an object was created/added to the
12+ // database, and when any field was last updated.
13+ type TimeMetadata struct {
14+ UpdatedAt * time.Time `json:"updatedAt" format:"date-time" extensions:"x-nullable"`
15+ CreatedAt * time.Time `json:"createdAt" format:"date-time" extensions:"x-nullable"`
16+ }
17+
1118// ArtifactJSONFields holds the JSON field names for each field.
1219// Useful in ordering statements to map the correct field to the correct
1320// database column.
@@ -24,6 +31,7 @@ var ArtifactJSONFields = struct {
2431// Artifact holds the binary data as well as metadata about that binary such as
2532// the file name and which build it belongs to.
2633type Artifact struct {
34+ TimeMetadata
2735 ArtifactID uint `json:"artifactId" minimum:"0"`
2836 BuildID uint `json:"buildId" minimum:"0"`
2937 Name string `json:"name"`
@@ -32,12 +40,14 @@ type Artifact struct {
3240
3341// ArtifactMetadata contains the file name and artifact ID of an Artifact.
3442type ArtifactMetadata struct {
43+ TimeMetadata
3544 FileName string `json:"fileName"`
3645 ArtifactID uint `json:"artifactId" minimum:"0"`
3746}
3847
3948// Branch holds details about a project's branch.
4049type Branch struct {
50+ TimeMetadata
4151 BranchID uint `json:"branchId" minimum:"0"`
4252 ProjectID uint `json:"projectId" minimum:"0"`
4353 Name string `json:"name"`
@@ -78,6 +88,7 @@ var BuildJSONFields = struct {
7888// Build holds data about the state of a build. Which parameters was used to
7989// start it, what status it holds, et.al.
8090type Build struct {
91+ TimeMetadata
8192 BuildID uint `json:"buildId" minimum:"0"`
8293 StatusID int `json:"statusId" enums:"0,1,2,3"`
8394 Status BuildStatus `json:"status" enums:"Scheduling,Running,Completed,Failed"`
@@ -214,6 +225,7 @@ var ProjectJSONFields = struct {
214225
215226// Project holds details about a project.
216227type Project struct {
228+ TimeMetadata
217229 ProjectID uint `json:"projectId" minimum:"0"`
218230 RemoteProjectID string `json:"remoteProjectId"`
219231 Name string `json:"name"`
@@ -248,6 +260,7 @@ var ProviderJSONFields = struct {
248260// importance are the URL field of where to find the remote, and the token field
249261// used to authenticate.
250262type Provider struct {
263+ TimeMetadata
251264 ProviderID uint `json:"providerId" minimum:"0"`
252265 Name ProviderName `json:"name" enums:"azuredevops,gitlab,github"`
253266 URL string `json:"url"`
@@ -291,6 +304,7 @@ const (
291304
292305// TestResultDetail contains data about a single test in a test result file.
293306type TestResultDetail struct {
307+ TimeMetadata
294308 TestResultDetailID uint `json:"testResultDetailId" minimum:"0"`
295309 ArtifactID uint `json:"artifactId" minimum:"0"`
296310 BuildID uint `json:"buildId" minimum:"0"`
@@ -324,6 +338,7 @@ const (
324338
325339// TestResultSummary contains data about a single test result file.
326340type TestResultSummary struct {
341+ TimeMetadata
327342 TestResultSummaryID uint `json:"testResultSummaryId" minimum:"0"`
328343 FileName string `json:"fileName"`
329344 ArtifactID uint `json:"artifactId" minimum:"0"`
@@ -359,6 +374,7 @@ var TokenJSONFields = struct {
359374
360375// Token holds credentials for a remote provider.
361376type Token struct {
377+ TimeMetadata
362378 TokenID uint `json:"tokenId" minimum:"0"`
363379 Token string `json:"token" format:"password"`
364380 UserName string `json:"userName"`
0 commit comments