Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5e8b150

Browse files
mtojekmafredri
authored andcommitted
Implement database model
1 parent 5455c58 commit 5e8b150

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
@@ -2856,6 +2856,7 @@ func (q *fakeQuerier) InsertWorkspaceAgent(_ context.Context, arg database.Inser
28562856
TroubleshootingURL: arg.TroubleshootingURL,
28572857
MOTDFile: arg.MOTDFile,
28582858
LifecycleState: database.WorkspaceAgentLifecycleStateCreated,
2859+
ShutdownScript: arg.ShutdownScript,
28592860
}
28602861

28612862
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
@@ -1144,6 +1144,10 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
11441144
MOTDFile: prAgent.GetMotdFile(),
11451145
LoginBeforeReady: prAgent.GetLoginBeforeReady(),
11461146
StartupScriptTimeoutSeconds: prAgent.GetStartupScriptTimeoutSeconds(),
1147+
ShutdownScript: sql.NullString{
1148+
String: prAgent.ShutdownScript,
1149+
Valid: prAgent.ShutdownScript != "",
1150+
},
11471151
})
11481152
if err != nil {
11491153
return xerrors.Errorf("insert agent: %w", err)

0 commit comments

Comments
 (0)