Introduce persistent browser sessions model (#1408)
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
"""introduce persistent browser sessions
|
||||||
|
|
||||||
|
Revision ID: 282b0548d443
|
||||||
|
Revises: 411dd89f3df9
|
||||||
|
Create Date: 2024-12-17 18:41:30.400052+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "282b0548d443"
|
||||||
|
down_revision: Union[str, None] = "411dd89f3df9"
|
||||||
|
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.create_table(
|
||||||
|
"persistent_browser_sessions",
|
||||||
|
sa.Column("persistent_browser_session_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("organization_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("runnable_type", sa.String(), nullable=False),
|
||||||
|
sa.Column("runnable_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||||
|
sa.Column("modified_at", sa.DateTime(), nullable=False),
|
||||||
|
sa.Column("deleted_at", sa.DateTime(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(
|
||||||
|
["organization_id"],
|
||||||
|
["organizations.organization_id"],
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("persistent_browser_session_id"),
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table("persistent_browser_sessions")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -46,6 +46,7 @@ BITWARDEN_CREDIT_CARD_DATA_PARAMETER_PREFIX = "bccd"
|
|||||||
TASK_GENERATION_PREFIX = "tg"
|
TASK_GENERATION_PREFIX = "tg"
|
||||||
OBSERVER_CRUISE_ID = "oc"
|
OBSERVER_CRUISE_ID = "oc"
|
||||||
OBSERVER_THOUGHT_ID = "ot"
|
OBSERVER_THOUGHT_ID = "ot"
|
||||||
|
PERSISTENT_BROWSER_SESSION_ID = "pbs"
|
||||||
|
|
||||||
|
|
||||||
def generate_workflow_id() -> str:
|
def generate_workflow_id() -> str:
|
||||||
@@ -153,6 +154,11 @@ def generate_observer_thought_id() -> str:
|
|||||||
return f"{OBSERVER_THOUGHT_ID}_{int_id}"
|
return f"{OBSERVER_THOUGHT_ID}_{int_id}"
|
||||||
|
|
||||||
|
|
||||||
|
def generate_persistent_browser_session_id() -> str:
|
||||||
|
int_id = generate_id()
|
||||||
|
return f"{PERSISTENT_BROWSER_SESSION_ID}_{int_id}"
|
||||||
|
|
||||||
|
|
||||||
def generate_id() -> int:
|
def generate_id() -> int:
|
||||||
"""
|
"""
|
||||||
generate a 64-bit int ID
|
generate a 64-bit int ID
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from skyvern.forge.sdk.db.id import (
|
|||||||
generate_org_id,
|
generate_org_id,
|
||||||
generate_organization_auth_token_id,
|
generate_organization_auth_token_id,
|
||||||
generate_output_parameter_id,
|
generate_output_parameter_id,
|
||||||
|
generate_persistent_browser_session_id,
|
||||||
generate_step_id,
|
generate_step_id,
|
||||||
generate_task_generation_id,
|
generate_task_generation_id,
|
||||||
generate_task_id,
|
generate_task_id,
|
||||||
@@ -540,3 +541,15 @@ class ObserverThoughtModel(Base):
|
|||||||
|
|
||||||
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||||
modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)
|
modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)
|
||||||
|
|
||||||
|
|
||||||
|
class PersistentBrowserSessionModel(Base):
|
||||||
|
__tablename__ = "persistent_browser_sessions"
|
||||||
|
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user