mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-07 22:50:53 +08:00
workspace database table updates
This commit is contained in:
@@ -7,6 +7,8 @@ CREATE TABLE workspace_templates
|
|||||||
namespace varchar(36) NOT NULL,
|
namespace varchar(36) NOT NULL,
|
||||||
is_archived boolean DEFAULT false,
|
is_archived boolean DEFAULT false,
|
||||||
|
|
||||||
|
workflow_template_id integer NOT NULL REFERENCES workflow_templates ON DELETE CASCADE,
|
||||||
|
|
||||||
-- auditing info
|
-- auditing info
|
||||||
created_at timestamp NOT NULL DEFAULT (NOW() at time zone 'utc'),
|
created_at timestamp NOT NULL DEFAULT (NOW() at time zone 'utc'),
|
||||||
modified_at timestamp
|
modified_at timestamp
|
||||||
|
@@ -73,6 +73,8 @@ func (c *Client) createWorkflowTemplate(namespace string, workflowTemplate *Work
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workflowTemplate.Version = versionUnix
|
||||||
|
|
||||||
return workflowTemplate, nil
|
return workflowTemplate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -339,36 +339,39 @@ func (c *Client) createWorkspaceTemplate(namespace string, workspaceTemplate *Wo
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
workspaceTemplate.Version = workspaceTemplate.WorkflowTemplate.Version
|
||||||
|
|
||||||
err = sb.Insert("workspace_templates").
|
err = sb.Insert("workspace_templates").
|
||||||
SetMap(sq.Eq{
|
SetMap(sq.Eq{
|
||||||
"uid": uid,
|
"uid": uid,
|
||||||
"name": workspaceTemplate.Name,
|
"name": workspaceTemplate.Name,
|
||||||
"namespace": namespace,
|
"namespace": namespace,
|
||||||
|
"workflow_template_id": workspaceTemplate.WorkflowTemplate.ID,
|
||||||
}).
|
}).
|
||||||
Suffix("RETURNING id").
|
Suffix("RETURNING id").
|
||||||
RunWith(tx).
|
RunWith(tx).
|
||||||
QueryRow().Scan(&workspaceTemplate.ID)
|
QueryRow().Scan(&workspaceTemplate.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
_, err := c.archiveWorkflowTemplate(namespace, workspaceTemplate.WorkflowTemplate.UID)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = sb.Insert("workspace_template_versions").
|
_, err = sb.Insert("workspace_template_versions").
|
||||||
SetMap(sq.Eq{
|
SetMap(sq.Eq{
|
||||||
"workspace_template_id": workspaceTemplate.ID,
|
"version": workspaceTemplate.Version,
|
||||||
"version": workspaceTemplate.WorkflowTemplate.Version,
|
|
||||||
"is_latest": true,
|
"is_latest": true,
|
||||||
"manifest": workspaceTemplate.Manifest,
|
"manifest": workspaceTemplate.Manifest,
|
||||||
|
"workspace_template_id": workspaceTemplate.ID,
|
||||||
}).
|
}).
|
||||||
RunWith(tx).
|
RunWith(tx).
|
||||||
Exec()
|
Exec()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
_, err := c.archiveWorkflowTemplate(namespace, workspaceTemplate.WorkflowTemplate.UID)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = tx.Commit(); err != nil {
|
if err = tx.Commit(); err != nil {
|
||||||
//if err := c.ArgoprojV1alpha1().WorkflowTemplates(namespace).Delete(workspaceTemplate.WorkflowTemplate.Name, &metav1.DeleteOptions{}); err != nil {
|
_, err := c.archiveWorkflowTemplate(namespace, workspaceTemplate.WorkflowTemplate.UID)
|
||||||
// log.Printf("Unable to delete argo workflow template")
|
|
||||||
//}
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user