-
Notifications
You must be signed in to change notification settings - Fork 81
feat: Initial migration for Workspaces and pipeline step #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
77b53a7
feat: Initial migration for Workspaces and pipeline step
aponcedeleonch c488ff3
Reformatting changes
aponcedeleonch 2f6dfd9
Make unique workspaces name
aponcedeleonch 370231e
Introduced Sessions table and added add and activate commands
aponcedeleonch c63788e
Formatting changes and unit tests
aponcedeleonch 29f99aa
Classes separation into a different file
aponcedeleonch 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,61 @@ | ||
"""introduce workspaces | ||
|
||
Revision ID: 5c2f3eee5f90 | ||
Revises: 30d0144e1a50 | ||
Create Date: 2025-01-15 19:27:08.230296 | ||
|
||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "5c2f3eee5f90" | ||
down_revision: Union[str, None] = "30d0144e1a50" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# Workspaces table | ||
op.execute( | ||
""" | ||
CREATE TABLE workspaces ( | ||
id TEXT PRIMARY KEY, -- UUID stored as TEXT | ||
name TEXT NOT NULL, | ||
UNIQUE (name) | ||
); | ||
""" | ||
) | ||
op.execute("INSERT INTO workspaces (id, name) VALUES ('1', 'default');") | ||
# Sessions table | ||
op.execute( | ||
""" | ||
CREATE TABLE sessions ( | ||
id TEXT PRIMARY KEY, -- UUID stored as TEXT | ||
active_workspace_id TEXT NOT NULL, | ||
last_update DATETIME NOT NULL, | ||
FOREIGN KEY (active_workspace_id) REFERENCES workspaces(id) | ||
); | ||
""" | ||
) | ||
# Alter table prompts | ||
op.execute("ALTER TABLE prompts ADD COLUMN workspace_id TEXT REFERENCES workspaces(id);") | ||
op.execute("UPDATE prompts SET workspace_id = '1';") | ||
# Create index for workspace_id | ||
op.execute("CREATE INDEX idx_prompts_workspace_id ON prompts (workspace_id);") | ||
# Create index for session_id | ||
op.execute("CREATE INDEX idx_sessions_workspace_id ON sessions (active_workspace_id);") | ||
|
||
|
||
def downgrade() -> None: | ||
# Drop the index for workspace_id | ||
op.execute("DROP INDEX IF EXISTS idx_prompts_workspace_id;") | ||
op.execute("DROP INDEX IF EXISTS idx_sessions_workspace_id;") | ||
# Remove the workspace_id column from prompts table | ||
op.execute("ALTER TABLE prompts DROP COLUMN workspace_id;") | ||
# Drop the sessions table | ||
op.execute("DROP TABLE IF EXISTS sessions;") | ||
# Drop the workspaces table | ||
op.execute("DROP TABLE IF EXISTS workspaces;") |
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
Oops, something went wrong.
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.