Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Fixes on migration ON_DELETE_CASCADE #708

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added transaction explicitly to migration
  • Loading branch information
aponcedeleonch committed Jan 22, 2025
commit d88b05a057ba3bb8be91b86b6362ec6219c9d82a
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@


def upgrade() -> None:
# Begin transaction
op.execute("BEGIN TRANSACTION;")

# To add ON DELETE CASCADE to the foreign key constraint, we need to
# rename the table, create a new table with the constraint, and copy
# the data over.
Expand Down Expand Up @@ -101,6 +104,9 @@ def upgrade() -> None:
op.execute("CREATE INDEX idx_prompts_workspace_id ON prompts (workspace_id);")
op.execute("CREATE INDEX idx_sessions_workspace_id ON sessions (active_workspace_id);")

# Finish transaction
op.execute("COMMIT;")


def downgrade() -> None:
# Settings table
Expand Down