| 716 | } |
| 717 | |
| 718 | func (c *connection) InsertDeployment(ctx context.Context, opts *database.InsertDeploymentOptions) (*database.Deployment, error) { |
| 719 | if err := database.Validate(opts); err != nil { |
| 720 | return nil, err |
| 721 | } |
| 722 | |
| 723 | res := &database.Deployment{} |
| 724 | err := c.getDB(ctx).QueryRowxContext(ctx, ` |
| 725 | INSERT INTO deployments (project_id, owner_user_id, environment, branch, editable, runtime_host, runtime_instance_id, runtime_audience, status, status_message, desired_status, desired_status_updated_on) |
| 726 | VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, now()) RETURNING *`, |
| 727 | opts.ProjectID, opts.OwnerUserID, opts.Environment, opts.Branch, opts.Editable, opts.RuntimeHost, opts.RuntimeInstanceID, opts.RuntimeAudience, opts.Status, opts.StatusMessage, opts.DesiredStatus, |
| 728 | ).StructScan(res) |
| 729 | if err != nil { |
| 730 | return nil, parseErr("deployment", err) |
| 731 | } |
| 732 | return res, nil |
| 733 | } |
| 734 | |
| 735 | func (c *connection) DeleteDeployment(ctx context.Context, id string) error { |
| 736 | res, err := c.getDB(ctx).ExecContext(ctx, "DELETE FROM deployments WHERE id=$1", id) |