Skip to content

Commit f9a02f0

Browse files
mtojekmafredri
authored andcommitted
Implement database model
1 parent 34a1954 commit f9a02f0

19 files changed

+77
-11
lines changed

coderd/apidoc/docs.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbfake/databasefake.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,6 +2734,7 @@ func (q *fakeQuerier) InsertWorkspaceAgent(_ context.Context, arg database.Inser
27342734
TroubleshootingURL: arg.TroubleshootingURL,
27352735
MOTDFile: arg.MOTDFile,
27362736
LifecycleState: database.WorkspaceAgentLifecycleStateCreated,
2737+
ShutdownScript: arg.ShutdownScript,
27372738
}
27382739

27392740
q.workspaceAgents = append(q.workspaceAgents, agent)

coderd/database/dump.sql

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE workspace_agents DROP COLUMN shutdown_script;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE workspace_agents ADD COLUMN shutdown_script varchar(65534);
2+
3+
COMMENT ON COLUMN workspace_agents.shutdown_script IS 'Script that is executed before the agent is stopped.';

coderd/database/models.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceagents.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ INSERT INTO
5858
troubleshooting_url,
5959
motd_file,
6060
login_before_ready,
61-
startup_script_timeout_seconds
61+
startup_script_timeout_seconds,
62+
shutdown_script
6263
)
6364
VALUES
64-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19) RETURNING *;
65+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20) RETURNING *;
6566

6667
-- name: UpdateWorkspaceAgentConnectionByID :exec
6768
UPDATE

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,10 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
976976
MOTDFile: prAgent.GetMotdFile(),
977977
LoginBeforeReady: prAgent.GetLoginBeforeReady(),
978978
StartupScriptTimeoutSeconds: prAgent.GetStartupScriptTimeoutSeconds(),
979+
ShutdownScript: sql.NullString{
980+
String: prAgent.ShutdownScript,
981+
Valid: prAgent.ShutdownScript != "",
982+
},
979983
})
980984
if err != nil {
981985
return xerrors.Errorf("insert agent: %w", err)

0 commit comments

Comments
 (0)