mirror of
https://github.com/coder/coder.git
synced 2026-09-23 14:03:57 +08:00
This models restart as durable orchestration of existing stop and start workspace builds instead of adding a new restart transition. Keeping restart as two existing transitions preserves the current build/provisioner model. The child start build is created only after the parent stop build succeeds, rather than being inserted immediately in a pending state. That keeps `workspace_builds` aligned with actual provisioner-ready work and avoids introducing a second pending-build lifecycle that the provisioner and build acquisition paths would need to understand. Refs: https://linear.app/codercom/issue/PLAT-143
33 lines
846 B
Go
33 lines
846 B
Go
package dbtestutil
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
"github.com/coder/coder/v2/coderd/database"
|
|
)
|
|
|
|
// GetWorkspaceBuildOrchestrationByParentBuildID reads a workspace
|
|
// build orchestration row directly from the database for tests.
|
|
//
|
|
// It scans into the struct by column name so new columns are picked up
|
|
// automatically without updating this helper.
|
|
func GetWorkspaceBuildOrchestrationByParentBuildID(
|
|
ctx context.Context,
|
|
sqlDB *sql.DB,
|
|
parentBuildID uuid.UUID,
|
|
) (database.WorkspaceBuildOrchestration, error) {
|
|
db := sqlx.NewDb(sqlDB, "postgres")
|
|
var orchestration database.WorkspaceBuildOrchestration
|
|
err := db.GetContext(
|
|
ctx,
|
|
&orchestration,
|
|
`SELECT * FROM workspace_build_orchestrations WHERE parent_build_id = $1`,
|
|
parentBuildID,
|
|
)
|
|
return orchestration, err
|
|
}
|