Skip to content

Commit 2f6dfd9

Browse files
Make unique workspaces name
1 parent c488ff3 commit 2f6dfd9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

migrations/versions/5c2f3eee5f90_introduce_workspaces.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def upgrade() -> None:
2424
CREATE TABLE workspaces (
2525
id TEXT PRIMARY KEY, -- UUID stored as TEXT
2626
name TEXT NOT NULL,
27-
is_active BOOLEAN NOT NULL DEFAULT 0
27+
is_active BOOLEAN NOT NULL DEFAULT 0,
28+
UNIQUE (name)
2829
);
2930
"""
3031
)
@@ -37,4 +38,9 @@ def upgrade() -> None:
3738

3839

3940
def downgrade() -> None:
40-
pass
41+
# Drop the index for workspace_id
42+
op.execute("DROP INDEX IF EXISTS idx_prompts_workspace_id;")
43+
# Remove the workspace_id column from prompts table
44+
op.execute("ALTER TABLE prompts DROP COLUMN workspace_id;")
45+
# Drop the workspaces table
46+
op.execute("DROP TABLE IF EXISTS workspaces;")

src/codegate/pipeline/workspace/workspace.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ async def _list_workspaces(self, *args):
2323
List all workspaces
2424
"""
2525
workspaces = await self._db_recorder.get_workspaces()
26-
print(workspaces)
2726
respond_str = ""
2827
for workspace in workspaces:
29-
respond_str += f"{workspace.id} - {workspace.name}"
28+
respond_str += f"- {workspace.name}"
3029
if workspace.is_active:
31-
respond_str += " (active)"
30+
respond_str += " **(active)**"
3231
respond_str += "\n"
3332
return respond_str
3433

@@ -52,7 +51,7 @@ async def parse_execute_cmd(self, last_user_message: str) -> str:
5251
Args:
5352
last_user_message (str): The last user message
5453
"""
55-
command_and_args = last_user_message.split("codegate-workspace ")[1]
54+
command_and_args = last_user_message.lower().split("codegate-workspace ")[1]
5655
command, *args = command_and_args.split(" ")
5756
return await self.execute(command, *args)
5857

0 commit comments

Comments
 (0)