Skip to content
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

Fix migration 82b32a135ea2 #1962

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
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
12 changes: 9 additions & 3 deletions src/dstack/_internal/server/migrations/versions/82b32a135ea2_.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ def upgrade() -> None:
# ### end Alembic commands ###

# update any existing volumes and set the user_id equal to the project_owner.id which created the volume
op.execute(
"UPDATE volumes SET user_id = (SELECT owner_id FROM projects JOIN volumes ON projects.id = volumes.project_id) WHERE user_id IS NULL"
)
op.execute("""
UPDATE volumes AS v
SET user_id = (
SELECT owner_id FROM projects
JOIN volumes ON projects.id = volumes.project_id
WHERE volumes.id = v.id
)
WHERE user_id IS NULL
""")

# set volumes.user_id to non-nullable
with op.batch_alter_table("volumes", schema=None) as batch_op:
Expand Down