mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix: update template updated_at value (#2729)
* fix: update template updated_at value * use Go time for all updated_at updates
This commit is contained in:
@ -1830,6 +1830,7 @@ func (q *fakeQuerier) UpdateTemplateActiveVersionByID(_ context.Context, arg dat
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
template.ActiveVersionID = arg.ActiveVersionID
|
template.ActiveVersionID = arg.ActiveVersionID
|
||||||
|
template.UpdatedAt = arg.UpdatedAt
|
||||||
q.templates[index] = template
|
q.templates[index] = template
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1845,6 +1846,7 @@ func (q *fakeQuerier) UpdateTemplateDeletedByID(_ context.Context, arg database.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
template.Deleted = arg.Deleted
|
template.Deleted = arg.Deleted
|
||||||
|
template.UpdatedAt = arg.UpdatedAt
|
||||||
q.templates[index] = template
|
q.templates[index] = template
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1876,7 +1878,7 @@ func (q *fakeQuerier) UpdateTemplateVersionDescriptionByJobID(_ context.Context,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
templateVersion.Readme = arg.Readme
|
templateVersion.Readme = arg.Readme
|
||||||
templateVersion.UpdatedAt = database.Now()
|
templateVersion.UpdatedAt = arg.UpdatedAt
|
||||||
q.templateVersions[index] = templateVersion
|
q.templateVersions[index] = templateVersion
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1910,6 +1912,7 @@ func (q *fakeQuerier) UpdateWorkspaceAgentConnectionByID(_ context.Context, arg
|
|||||||
agent.FirstConnectedAt = arg.FirstConnectedAt
|
agent.FirstConnectedAt = arg.FirstConnectedAt
|
||||||
agent.LastConnectedAt = arg.LastConnectedAt
|
agent.LastConnectedAt = arg.LastConnectedAt
|
||||||
agent.DisconnectedAt = arg.DisconnectedAt
|
agent.DisconnectedAt = arg.DisconnectedAt
|
||||||
|
agent.UpdatedAt = arg.UpdatedAt
|
||||||
q.provisionerJobAgents[index] = agent
|
q.provisionerJobAgents[index] = agent
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1927,7 +1930,7 @@ func (q *fakeQuerier) UpdateWorkspaceAgentKeysByID(_ context.Context, arg databa
|
|||||||
|
|
||||||
agent.WireguardNodePublicKey = arg.WireguardNodePublicKey
|
agent.WireguardNodePublicKey = arg.WireguardNodePublicKey
|
||||||
agent.WireguardDiscoPublicKey = arg.WireguardDiscoPublicKey
|
agent.WireguardDiscoPublicKey = arg.WireguardDiscoPublicKey
|
||||||
agent.UpdatedAt = database.Now()
|
agent.UpdatedAt = arg.UpdatedAt
|
||||||
q.provisionerJobAgents[index] = agent
|
q.provisionerJobAgents[index] = agent
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -2063,7 +2063,8 @@ const updateTemplateActiveVersionByID = `-- name: UpdateTemplateActiveVersionByI
|
|||||||
UPDATE
|
UPDATE
|
||||||
templates
|
templates
|
||||||
SET
|
SET
|
||||||
active_version_id = $2
|
active_version_id = $2,
|
||||||
|
updated_at = $3
|
||||||
WHERE
|
WHERE
|
||||||
id = $1
|
id = $1
|
||||||
`
|
`
|
||||||
@ -2071,10 +2072,11 @@ WHERE
|
|||||||
type UpdateTemplateActiveVersionByIDParams struct {
|
type UpdateTemplateActiveVersionByIDParams struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
|
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *sqlQuerier) UpdateTemplateActiveVersionByID(ctx context.Context, arg UpdateTemplateActiveVersionByIDParams) error {
|
func (q *sqlQuerier) UpdateTemplateActiveVersionByID(ctx context.Context, arg UpdateTemplateActiveVersionByIDParams) error {
|
||||||
_, err := q.db.ExecContext(ctx, updateTemplateActiveVersionByID, arg.ID, arg.ActiveVersionID)
|
_, err := q.db.ExecContext(ctx, updateTemplateActiveVersionByID, arg.ID, arg.ActiveVersionID, arg.UpdatedAt)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2082,7 +2084,8 @@ const updateTemplateDeletedByID = `-- name: UpdateTemplateDeletedByID :exec
|
|||||||
UPDATE
|
UPDATE
|
||||||
templates
|
templates
|
||||||
SET
|
SET
|
||||||
deleted = $2
|
deleted = $2,
|
||||||
|
updated_at = $3
|
||||||
WHERE
|
WHERE
|
||||||
id = $1
|
id = $1
|
||||||
`
|
`
|
||||||
@ -2090,10 +2093,11 @@ WHERE
|
|||||||
type UpdateTemplateDeletedByIDParams struct {
|
type UpdateTemplateDeletedByIDParams struct {
|
||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *sqlQuerier) UpdateTemplateDeletedByID(ctx context.Context, arg UpdateTemplateDeletedByIDParams) error {
|
func (q *sqlQuerier) UpdateTemplateDeletedByID(ctx context.Context, arg UpdateTemplateDeletedByIDParams) error {
|
||||||
_, err := q.db.ExecContext(ctx, updateTemplateDeletedByID, arg.ID, arg.Deleted)
|
_, err := q.db.ExecContext(ctx, updateTemplateDeletedByID, arg.ID, arg.Deleted, arg.UpdatedAt)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2404,7 +2408,7 @@ UPDATE
|
|||||||
template_versions
|
template_versions
|
||||||
SET
|
SET
|
||||||
readme = $2,
|
readme = $2,
|
||||||
updated_at = now()
|
updated_at = $3
|
||||||
WHERE
|
WHERE
|
||||||
job_id = $1
|
job_id = $1
|
||||||
`
|
`
|
||||||
@ -2412,10 +2416,11 @@ WHERE
|
|||||||
type UpdateTemplateVersionDescriptionByJobIDParams struct {
|
type UpdateTemplateVersionDescriptionByJobIDParams struct {
|
||||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||||
Readme string `db:"readme" json:"readme"`
|
Readme string `db:"readme" json:"readme"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *sqlQuerier) UpdateTemplateVersionDescriptionByJobID(ctx context.Context, arg UpdateTemplateVersionDescriptionByJobIDParams) error {
|
func (q *sqlQuerier) UpdateTemplateVersionDescriptionByJobID(ctx context.Context, arg UpdateTemplateVersionDescriptionByJobIDParams) error {
|
||||||
_, err := q.db.ExecContext(ctx, updateTemplateVersionDescriptionByJobID, arg.JobID, arg.Readme)
|
_, err := q.db.ExecContext(ctx, updateTemplateVersionDescriptionByJobID, arg.JobID, arg.Readme, arg.UpdatedAt)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3160,10 +3165,10 @@ const updateWorkspaceAgentConnectionByID = `-- name: UpdateWorkspaceAgentConnect
|
|||||||
UPDATE
|
UPDATE
|
||||||
workspace_agents
|
workspace_agents
|
||||||
SET
|
SET
|
||||||
updated_at = now(),
|
|
||||||
first_connected_at = $2,
|
first_connected_at = $2,
|
||||||
last_connected_at = $3,
|
last_connected_at = $3,
|
||||||
disconnected_at = $4
|
disconnected_at = $4,
|
||||||
|
updated_at = $5
|
||||||
WHERE
|
WHERE
|
||||||
id = $1
|
id = $1
|
||||||
`
|
`
|
||||||
@ -3173,6 +3178,7 @@ type UpdateWorkspaceAgentConnectionByIDParams struct {
|
|||||||
FirstConnectedAt sql.NullTime `db:"first_connected_at" json:"first_connected_at"`
|
FirstConnectedAt sql.NullTime `db:"first_connected_at" json:"first_connected_at"`
|
||||||
LastConnectedAt sql.NullTime `db:"last_connected_at" json:"last_connected_at"`
|
LastConnectedAt sql.NullTime `db:"last_connected_at" json:"last_connected_at"`
|
||||||
DisconnectedAt sql.NullTime `db:"disconnected_at" json:"disconnected_at"`
|
DisconnectedAt sql.NullTime `db:"disconnected_at" json:"disconnected_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *sqlQuerier) UpdateWorkspaceAgentConnectionByID(ctx context.Context, arg UpdateWorkspaceAgentConnectionByIDParams) error {
|
func (q *sqlQuerier) UpdateWorkspaceAgentConnectionByID(ctx context.Context, arg UpdateWorkspaceAgentConnectionByIDParams) error {
|
||||||
@ -3181,6 +3187,7 @@ func (q *sqlQuerier) UpdateWorkspaceAgentConnectionByID(ctx context.Context, arg
|
|||||||
arg.FirstConnectedAt,
|
arg.FirstConnectedAt,
|
||||||
arg.LastConnectedAt,
|
arg.LastConnectedAt,
|
||||||
arg.DisconnectedAt,
|
arg.DisconnectedAt,
|
||||||
|
arg.UpdatedAt,
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -3189,9 +3196,9 @@ const updateWorkspaceAgentKeysByID = `-- name: UpdateWorkspaceAgentKeysByID :exe
|
|||||||
UPDATE
|
UPDATE
|
||||||
workspace_agents
|
workspace_agents
|
||||||
SET
|
SET
|
||||||
updated_at = now(),
|
|
||||||
wireguard_node_public_key = $2,
|
wireguard_node_public_key = $2,
|
||||||
wireguard_disco_public_key = $3
|
wireguard_disco_public_key = $3,
|
||||||
|
updated_at = $4
|
||||||
WHERE
|
WHERE
|
||||||
id = $1
|
id = $1
|
||||||
`
|
`
|
||||||
@ -3200,10 +3207,16 @@ type UpdateWorkspaceAgentKeysByIDParams struct {
|
|||||||
ID uuid.UUID `db:"id" json:"id"`
|
ID uuid.UUID `db:"id" json:"id"`
|
||||||
WireguardNodePublicKey dbtypes.NodePublic `db:"wireguard_node_public_key" json:"wireguard_node_public_key"`
|
WireguardNodePublicKey dbtypes.NodePublic `db:"wireguard_node_public_key" json:"wireguard_node_public_key"`
|
||||||
WireguardDiscoPublicKey dbtypes.DiscoPublic `db:"wireguard_disco_public_key" json:"wireguard_disco_public_key"`
|
WireguardDiscoPublicKey dbtypes.DiscoPublic `db:"wireguard_disco_public_key" json:"wireguard_disco_public_key"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *sqlQuerier) UpdateWorkspaceAgentKeysByID(ctx context.Context, arg UpdateWorkspaceAgentKeysByIDParams) error {
|
func (q *sqlQuerier) UpdateWorkspaceAgentKeysByID(ctx context.Context, arg UpdateWorkspaceAgentKeysByIDParams) error {
|
||||||
_, err := q.db.ExecContext(ctx, updateWorkspaceAgentKeysByID, arg.ID, arg.WireguardNodePublicKey, arg.WireguardDiscoPublicKey)
|
_, err := q.db.ExecContext(ctx, updateWorkspaceAgentKeysByID,
|
||||||
|
arg.ID,
|
||||||
|
arg.WireguardNodePublicKey,
|
||||||
|
arg.WireguardDiscoPublicKey,
|
||||||
|
arg.UpdatedAt,
|
||||||
|
)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,8 @@ VALUES
|
|||||||
UPDATE
|
UPDATE
|
||||||
templates
|
templates
|
||||||
SET
|
SET
|
||||||
active_version_id = $2
|
active_version_id = $2,
|
||||||
|
updated_at = $3
|
||||||
WHERE
|
WHERE
|
||||||
id = $1;
|
id = $1;
|
||||||
|
|
||||||
@ -81,7 +82,8 @@ WHERE
|
|||||||
UPDATE
|
UPDATE
|
||||||
templates
|
templates
|
||||||
SET
|
SET
|
||||||
deleted = $2
|
deleted = $2,
|
||||||
|
updated_at = $3
|
||||||
WHERE
|
WHERE
|
||||||
id = $1;
|
id = $1;
|
||||||
|
|
||||||
|
@ -89,6 +89,6 @@ UPDATE
|
|||||||
template_versions
|
template_versions
|
||||||
SET
|
SET
|
||||||
readme = $2,
|
readme = $2,
|
||||||
updated_at = now()
|
updated_at = $3
|
||||||
WHERE
|
WHERE
|
||||||
job_id = $1;
|
job_id = $1;
|
||||||
|
@ -65,10 +65,10 @@ VALUES
|
|||||||
UPDATE
|
UPDATE
|
||||||
workspace_agents
|
workspace_agents
|
||||||
SET
|
SET
|
||||||
updated_at = now(),
|
|
||||||
first_connected_at = $2,
|
first_connected_at = $2,
|
||||||
last_connected_at = $3,
|
last_connected_at = $3,
|
||||||
disconnected_at = $4
|
disconnected_at = $4,
|
||||||
|
updated_at = $5
|
||||||
WHERE
|
WHERE
|
||||||
id = $1;
|
id = $1;
|
||||||
|
|
||||||
@ -76,8 +76,8 @@ WHERE
|
|||||||
UPDATE
|
UPDATE
|
||||||
workspace_agents
|
workspace_agents
|
||||||
SET
|
SET
|
||||||
updated_at = now(),
|
|
||||||
wireguard_node_public_key = $2,
|
wireguard_node_public_key = $2,
|
||||||
wireguard_disco_public_key = $3
|
wireguard_disco_public_key = $3,
|
||||||
|
updated_at = $4
|
||||||
WHERE
|
WHERE
|
||||||
id = $1;
|
id = $1;
|
||||||
|
@ -387,6 +387,7 @@ func (server *provisionerdServer) UpdateJob(ctx context.Context, request *proto.
|
|||||||
err := server.Database.UpdateTemplateVersionDescriptionByJobID(ctx, database.UpdateTemplateVersionDescriptionByJobIDParams{
|
err := server.Database.UpdateTemplateVersionDescriptionByJobID(ctx, database.UpdateTemplateVersionDescriptionByJobIDParams{
|
||||||
JobID: job.ID,
|
JobID: job.ID,
|
||||||
Readme: string(request.Readme),
|
Readme: string(request.Readme),
|
||||||
|
UpdatedAt: database.Now(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("update template version description: %w", err)
|
return nil, xerrors.Errorf("update template version description: %w", err)
|
||||||
|
@ -98,6 +98,7 @@ func (api *API) deleteTemplate(rw http.ResponseWriter, r *http.Request) {
|
|||||||
err = api.Database.UpdateTemplateDeletedByID(r.Context(), database.UpdateTemplateDeletedByIDParams{
|
err = api.Database.UpdateTemplateDeletedByID(r.Context(), database.UpdateTemplateDeletedByIDParams{
|
||||||
ID: template.ID,
|
ID: template.ID,
|
||||||
Deleted: true,
|
Deleted: true,
|
||||||
|
UpdatedAt: database.Now(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
|
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
|
||||||
|
@ -564,6 +564,7 @@ func (api *API) patchActiveTemplateVersion(rw http.ResponseWriter, r *http.Reque
|
|||||||
err = store.UpdateTemplateActiveVersionByID(r.Context(), database.UpdateTemplateActiveVersionByIDParams{
|
err = store.UpdateTemplateActiveVersionByID(r.Context(), database.UpdateTemplateActiveVersionByIDParams{
|
||||||
ID: template.ID,
|
ID: template.ID,
|
||||||
ActiveVersionID: req.ID,
|
ActiveVersionID: req.ID,
|
||||||
|
UpdatedAt: database.Now(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("update active version: %w", err)
|
return xerrors.Errorf("update active version: %w", err)
|
||||||
|
@ -282,6 +282,7 @@ func (api *API) workspaceAgentListen(rw http.ResponseWriter, r *http.Request) {
|
|||||||
FirstConnectedAt: firstConnectedAt,
|
FirstConnectedAt: firstConnectedAt,
|
||||||
LastConnectedAt: lastConnectedAt,
|
LastConnectedAt: lastConnectedAt,
|
||||||
DisconnectedAt: disconnectedAt,
|
DisconnectedAt: disconnectedAt,
|
||||||
|
UpdatedAt: database.Now(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -491,6 +492,7 @@ func (api *API) postWorkspaceAgentKeys(rw http.ResponseWriter, r *http.Request)
|
|||||||
ID: workspaceAgent.ID,
|
ID: workspaceAgent.ID,
|
||||||
WireguardNodePublicKey: dbtypes.NodePublic(keys.Public),
|
WireguardNodePublicKey: dbtypes.NodePublic(keys.Public),
|
||||||
WireguardDiscoPublicKey: dbtypes.DiscoPublic(keys.Disco),
|
WireguardDiscoPublicKey: dbtypes.DiscoPublic(keys.Disco),
|
||||||
|
UpdatedAt: database.Now(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
|
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
|
||||||
|
Reference in New Issue
Block a user