This repository was archived by the owner on Jun 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Implement basic soft deletion for workspaces #657
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""add soft delete | ||
|
||
Revision ID: 8e4b4b8d1a88 | ||
Revises: 5c2f3eee5f90 | ||
Create Date: 2025-01-20 14:08:40.851647 | ||
|
||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "8e4b4b8d1a88" | ||
down_revision: Union[str, None] = "5c2f3eee5f90" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute( | ||
""" | ||
ALTER TABLE workspaces | ||
ADD COLUMN deleted_at DATETIME DEFAULT NULL; | ||
""" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.execute("ALTER TABLE workspaces DROP COLUMN deleted_at;") |
23 changes: 23 additions & 0 deletions
23
migrations/versions/e6227073183d_merging_system_prompt_and_soft_deletes.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""merging system prompt and soft-deletes | ||
|
||
Revision ID: e6227073183d | ||
Revises: 8e4b4b8d1a88, a692c8b52308 | ||
Create Date: 2025-01-20 16:08:40.645298 | ||
|
||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "e6227073183d" | ||
down_revision: Union[str, None] = ("8e4b4b8d1a88", "a692c8b52308") | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
pass | ||
|
||
|
||
def downgrade() -> None: | ||
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,6 +153,7 @@ def subcommands(self) -> Dict[str, Callable[[List[str]], Awaitable[str]]]: | |
"list": self._list_workspaces, | ||
"add": self._add_workspace, | ||
"activate": self._activate_workspace, | ||
"remove": self._remove_workspace, | ||
} | ||
|
||
async def _list_workspaces(self, flags: Dict[str, str], args: List[str]) -> str: | ||
|
@@ -211,6 +212,25 @@ async def _activate_workspace(self, flags: Dict[str, str], args: List[str]) -> s | |
return "An error occurred while activating the workspace" | ||
return f"Workspace **{workspace_name}** has been activated" | ||
|
||
async def _remove_workspace(self, flags: Dict[str, str], args: List[str]) -> str: | ||
""" | ||
Remove a workspace | ||
""" | ||
if args is None or len(args) == 0: | ||
return "Please provide a name. Use `codegate workspace remove workspace_name`" | ||
|
||
workspace_name = args[0] | ||
if not workspace_name: | ||
return "Please provide a name. Use `codegate workspace remove workspace_name`" | ||
|
||
try: | ||
await self.workspace_crud.soft_delete_workspace(workspace_name) | ||
except crud.WorkspaceDoesNotExistError: | ||
return f"Workspace **{workspace_name}** does not exist" | ||
except Exception: | ||
return "An error occurred while removing the workspace" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should give the user a clearer error message of what's going on. I got this when trying to delete the active workspace. It's ok to fix on a later PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you open a bug about this? I can fix it tomorrow. |
||
return f"Workspace **{workspace_name}** has been removed" | ||
|
||
@property | ||
def help(self) -> str: | ||
return ( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.