Skip to content

Commit

Permalink
Fix missing migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
r4victor committed Feb 19, 2024
1 parent 89ce675 commit edda1d7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Added fail reason for InstanceModel
Revision ID: 9eea6af28e10
Revises: 29c08c6a8cb3
Create Date: 2024-02-19 11:39:30.572999
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "9eea6af28e10"
down_revision = "29c08c6a8cb3"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("instances", schema=None) as batch_op:
batch_op.add_column(
sa.Column("fail_count", sa.Integer(), server_default=sa.text("0"), nullable=False)
)
batch_op.add_column(sa.Column("fail_reason", sa.String(length=4000), nullable=True))

# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("instances", schema=None) as batch_op:
batch_op.drop_column("fail_reason")
batch_op.drop_column("fail_count")

# ### end Alembic commands ###

This file was deleted.

3 changes: 2 additions & 1 deletion src/dstack/_internal/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
String,
Text,
UniqueConstraint,
text,
)
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from sqlalchemy.sql import false
Expand Down Expand Up @@ -292,7 +293,7 @@ class InstanceModel(BaseModel):
)

# connection fail handling
fail_count: Mapped[int] = mapped_column(Integer, default=0)
fail_count: Mapped[int] = mapped_column(Integer, server_default=text("0"))
fail_reason: Mapped[Optional[str]] = mapped_column(String(4000))

# backend
Expand Down

0 comments on commit edda1d7

Please sign in to comment.