Skip to content

Commit e2efd27

Browse files
Add database migration for ProjectModel.is_public
1 parent 9d04fc9 commit e2efd27

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Add ProjectModel.is_public
2+
3+
Revision ID: 35f732ee4cf5
4+
Revises: bca2fdf130bf
5+
Create Date: 2025-06-06 13:04:02.912032
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "35f732ee4cf5"
14+
down_revision = "bca2fdf130bf"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade() -> None:
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
# Add is_public column as nullable first
22+
with op.batch_alter_table("projects", schema=None) as batch_op:
23+
batch_op.add_column(sa.Column("is_public", sa.Boolean(), nullable=True))
24+
25+
# Set is_public to False for existing projects
26+
op.execute(sa.sql.text("UPDATE projects SET is_public = FALSE"))
27+
28+
# Make is_public non-nullable with default value
29+
with op.batch_alter_table("projects", schema=None) as batch_op:
30+
batch_op.alter_column("is_public", nullable=False, server_default=sa.false())
31+
# ### end Alembic commands ###
32+
33+
34+
def downgrade() -> None:
35+
# ### commands auto generated by Alembic - please adjust! ###
36+
# Remove is_public column
37+
with op.batch_alter_table("projects", schema=None) as batch_op:
38+
batch_op.drop_column("is_public")
39+
# ### end Alembic commands ###

src/dstack/_internal/server/services/projects.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ async def list_user_project_models(
277277
options = []
278278
if include_members:
279279
options.append(joinedload(ProjectModel.members))
280-
281280
res = await session.execute(
282281
select(ProjectModel)
283282
.where(
@@ -287,7 +286,6 @@ async def list_user_project_models(
287286
)
288287
.options(*options)
289288
)
290-
291289
return list(res.scalars().unique().all())
292290

293291

0 commit comments

Comments
 (0)