Skip to content

Commit 635c38d

Browse files
[Internal] Add an index for user email (#3409)
1 parent 616fa31 commit 635c38d

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Added email index
2+
3+
Revision ID: 1aa9638ad963
4+
Revises: 22d74df9897e
5+
Create Date: 2025-12-21 22:08:27.331645
6+
7+
"""
8+
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "1aa9638ad963"
13+
down_revision = "22d74df9897e"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade() -> None:
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
with op.batch_alter_table("users", schema=None) as batch_op:
21+
batch_op.create_index(batch_op.f("ix_users_email"), ["email"], unique=False)
22+
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade() -> None:
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
with op.batch_alter_table("users", schema=None) as batch_op:
29+
batch_op.drop_index(batch_op.f("ix_users_email"))
30+
31+
# ### end Alembic commands ###

src/dstack/_internal/server/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class UserModel(BaseModel):
201201
ssh_private_key: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
202202
ssh_public_key: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
203203

204-
email: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
204+
email: Mapped[Optional[str]] = mapped_column(String(200), nullable=True, index=True)
205205

206206
projects_quota: Mapped[int] = mapped_column(
207207
Integer, default=settings.USER_PROJECT_DEFAULT_QUOTA

0 commit comments

Comments
 (0)