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