Skip to content

Commit 300d10c

Browse files
committed
add migrations
1 parent 0c27f04 commit 300d10c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE workspace_app_audit_sessions;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CREATE UNLOGGED TABLE workspace_app_audit_sessions (
2+
id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
3+
agent_id UUID NOT NULL,
4+
app_id UUID NULL,
5+
user_id UUID,
6+
ip inet,
7+
started_at TIMESTAMP WITH TIME ZONE NOT NULL,
8+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
9+
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
10+
FOREIGN KEY (agent_id) REFERENCES workspace_agents (id) ON DELETE CASCADE,
11+
FOREIGN KEY (app_id) REFERENCES workspace_apps (id) ON DELETE CASCADE
12+
);
13+
14+
COMMENT ON TABLE workspace_app_audit_sessions IS 'Audit sessions for workspace apps, the data in this table is ephemeral and is used to track the current session of a user in a workspace app.';
15+
COMMENT ON COLUMN workspace_app_audit_sessions.id IS 'Unique identifier for the workspace app audit session.';
16+
COMMENT ON COLUMN workspace_app_audit_sessions.user_id IS 'The user that is currently using the workspace app. This is nullable because the app may be public.';
17+
COMMENT ON COLUMN workspace_app_audit_sessions.ip IS 'The IP address of the user that is currently using the workspace app.';
18+
COMMENT ON COLUMN workspace_app_audit_sessions.agent_id IS 'The agent that is currently in the workspace app.';
19+
COMMENT ON COLUMN workspace_app_audit_sessions.app_id IS 'The app that is currently in the workspace app. This is nullable because ports are not associated with an app.';
20+
COMMENT ON COLUMN workspace_app_audit_sessions.started_at IS 'The time the user started the session.';
21+
COMMENT ON COLUMN workspace_app_audit_sessions.updated_at IS 'The time the session was last updated.';
22+
23+
CREATE INDEX workspace_app_audit_sessions_agent_id_app_id ON workspace_app_audit_sessions (agent_id, app_id);
24+
25+
COMMENT ON INDEX workspace_app_audit_sessions_agent_id_app_id IS 'Index for the agent_id and app_id columns to perform updates.';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
INSERT INTO workspace_app_audit_sessions
2+
(agent_id, app_id, user_id, ip, started_at, updated_at)
3+
VALUES
4+
('45e89705-e09d-4850-bcec-f9a937f5d78d', '36b65d0c-042b-4653-863a-655ee739861c', '30095c71-380b-457a-8995-97b8ee6e5307', '127.0.0.1', '2025-03-04 15:08:38.579772+02', '2025-03-04 15:06:48.755158+02'),
5+
('45e89705-e09d-4850-bcec-f9a937f5d78d', '36b65d0c-042b-4653-863a-655ee739861c', NULL, '127.0.0.1', '2025-03-04 15:08:44.411389+02', '2025-03-04 15:08:44.411389+02'),
6+
('45e89705-e09d-4850-bcec-f9a937f5d78d', NULL, NULL, '::1', '2025-03-04 15:25:55.555306+02', '2025-03-04 15:25:55.555306+02');

0 commit comments

Comments
 (0)