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

Make runnable type and runnable id nullable #1495

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""make browser session runnable type and id nullable

Revision ID: d47a586d7036
Revises: 32e2f138f7fd
Create Date: 2025-01-06 12:14:00.216039+00:00

"""

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "d47a586d7036"
down_revision: Union[str, None] = "32e2f138f7fd"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("persistent_browser_sessions", sa.Column("browser_id", sa.String(), nullable=True))
op.alter_column("persistent_browser_sessions", "runnable_type", existing_type=sa.VARCHAR(), nullable=True)
op.alter_column("persistent_browser_sessions", "runnable_id", existing_type=sa.VARCHAR(), nullable=True)
# ### end Alembic commands ###


def downgrade() -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downgrade function does not handle existing null values for runnable_type and runnable_id. Consider adding a step to handle null values before altering the columns to be non-nullable.

# ### commands auto generated by Alembic - please adjust! ###
op.alter_column("persistent_browser_sessions", "runnable_id", existing_type=sa.VARCHAR(), nullable=False)
op.alter_column("persistent_browser_sessions", "runnable_type", existing_type=sa.VARCHAR(), nullable=False)
op.drop_column("persistent_browser_sessions", "browser_id")
# ### end Alembic commands ###
5 changes: 3 additions & 2 deletions skyvern/forge/sdk/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,9 @@ class PersistentBrowserSessionModel(Base):

persistent_browser_session_id = Column(String, primary_key=True, default=generate_persistent_browser_session_id)
organization_id = Column(String, ForeignKey("organizations.organization_id"), nullable=False)
runnable_type = Column(String, nullable=False)
runnable_id = Column(String, nullable=False)
runnable_type = Column(String, nullable=True)
runnable_id = Column(String, nullable=True)
browser_id = Column(String, nullable=True)
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)
deleted_at = Column(DateTime, nullable=True)
Loading