index for created_at for multiple tables (#3526)
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
"""add created_at index for multiple tables
|
||||||
|
|
||||||
|
Revision ID: e0ccabc005af
|
||||||
|
Revises: 4925c34e8d58
|
||||||
|
Create Date: 2025-09-25 15:03:25.567938+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "e0ccabc005af"
|
||||||
|
down_revision: Union[str, None] = "4925c34e8d58"
|
||||||
|
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_index(
|
||||||
|
"ix_observer_cruises_org_created_at", "observer_cruises", ["organization_id", "created_at"], unique=False
|
||||||
|
)
|
||||||
|
op.create_index(
|
||||||
|
"ix_observer_thoughts_org_created_at", "observer_thoughts", ["organization_id", "created_at"], unique=False
|
||||||
|
)
|
||||||
|
op.create_index("ix_task_runs_org_created_at", "task_runs", ["organization_id", "created_at"], unique=False)
|
||||||
|
op.create_index("ix_totp_codes_org_created_at", "totp_codes", ["organization_id", "created_at"], unique=False)
|
||||||
|
op.create_index(
|
||||||
|
"ix_workflow_run_blocks_org_created_at", "workflow_run_blocks", ["organization_id", "created_at"], unique=False
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index("ix_workflow_run_blocks_org_created_at", table_name="workflow_run_blocks")
|
||||||
|
op.drop_index("ix_totp_codes_org_created_at", table_name="totp_codes")
|
||||||
|
op.drop_index("ix_task_runs_org_created_at", table_name="task_runs")
|
||||||
|
op.drop_index("ix_observer_thoughts_org_created_at", table_name="observer_thoughts")
|
||||||
|
op.drop_index("ix_observer_cruises_org_created_at", table_name="observer_cruises")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -573,6 +573,7 @@ class AISuggestionModel(Base):
|
|||||||
|
|
||||||
class TOTPCodeModel(Base):
|
class TOTPCodeModel(Base):
|
||||||
__tablename__ = "totp_codes"
|
__tablename__ = "totp_codes"
|
||||||
|
__table_args__ = (Index("ix_totp_codes_org_created_at", "organization_id", "created_at"),)
|
||||||
|
|
||||||
totp_code_id = Column(String, primary_key=True, default=generate_totp_code_id)
|
totp_code_id = Column(String, primary_key=True, default=generate_totp_code_id)
|
||||||
totp_identifier = Column(String, nullable=False, index=True)
|
totp_identifier = Column(String, nullable=False, index=True)
|
||||||
@@ -622,7 +623,10 @@ class ActionModel(Base):
|
|||||||
|
|
||||||
class WorkflowRunBlockModel(Base):
|
class WorkflowRunBlockModel(Base):
|
||||||
__tablename__ = "workflow_run_blocks"
|
__tablename__ = "workflow_run_blocks"
|
||||||
__table_args__ = (Index("wfrb_org_wfr_index", "organization_id", "workflow_run_id"),)
|
__table_args__ = (
|
||||||
|
Index("wfrb_org_wfr_index", "organization_id", "workflow_run_id"),
|
||||||
|
Index("ix_workflow_run_blocks_org_created_at", "organization_id", "created_at"),
|
||||||
|
)
|
||||||
|
|
||||||
workflow_run_block_id = Column(String, primary_key=True, default=generate_workflow_run_block_id)
|
workflow_run_block_id = Column(String, primary_key=True, default=generate_workflow_run_block_id)
|
||||||
workflow_run_id = Column(String, nullable=False)
|
workflow_run_id = Column(String, nullable=False)
|
||||||
@@ -672,7 +676,10 @@ class WorkflowRunBlockModel(Base):
|
|||||||
|
|
||||||
class TaskV2Model(Base):
|
class TaskV2Model(Base):
|
||||||
__tablename__ = "observer_cruises"
|
__tablename__ = "observer_cruises"
|
||||||
__table_args__ = (Index("oc_org_wfr_index", "organization_id", "workflow_run_id"),)
|
__table_args__ = (
|
||||||
|
Index("oc_org_wfr_index", "organization_id", "workflow_run_id"),
|
||||||
|
Index("ix_observer_cruises_org_created_at", "organization_id", "created_at"),
|
||||||
|
)
|
||||||
|
|
||||||
# observer_cruise_id is the task_id for task v2
|
# observer_cruise_id is the task_id for task v2
|
||||||
observer_cruise_id = Column(String, primary_key=True, default=generate_task_v2_id)
|
observer_cruise_id = Column(String, primary_key=True, default=generate_task_v2_id)
|
||||||
@@ -710,7 +717,10 @@ class TaskV2Model(Base):
|
|||||||
|
|
||||||
class ThoughtModel(Base):
|
class ThoughtModel(Base):
|
||||||
__tablename__ = "observer_thoughts"
|
__tablename__ = "observer_thoughts"
|
||||||
__table_args__ = (Index("observer_cruise_index", "organization_id", "observer_cruise_id"),)
|
__table_args__ = (
|
||||||
|
Index("observer_cruise_index", "organization_id", "observer_cruise_id"),
|
||||||
|
Index("ix_observer_thoughts_org_created_at", "organization_id", "created_at"),
|
||||||
|
)
|
||||||
|
|
||||||
observer_thought_id = Column(String, primary_key=True, default=generate_thought_id)
|
observer_thought_id = Column(String, primary_key=True, default=generate_thought_id)
|
||||||
organization_id = Column(String, nullable=True)
|
organization_id = Column(String, nullable=True)
|
||||||
@@ -763,6 +773,7 @@ class TaskRunModel(Base):
|
|||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
Index("task_run_org_url_index", "organization_id", "url_hash", "cached"),
|
Index("task_run_org_url_index", "organization_id", "url_hash", "cached"),
|
||||||
Index("task_run_org_run_id_index", "organization_id", "run_id"),
|
Index("task_run_org_run_id_index", "organization_id", "run_id"),
|
||||||
|
Index("ix_task_runs_org_created_at", "organization_id", "created_at"),
|
||||||
)
|
)
|
||||||
|
|
||||||
task_run_id = Column(String, primary_key=True, default=generate_task_run_id)
|
task_run_id = Column(String, primary_key=True, default=generate_task_run_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user