Add unique constraint for session id
This commit is contained in:
27
services/ingest-service/alembic/script.py.mako
Normal file
27
services/ingest-service/alembic/script.py.mako
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
"""${message}
|
||||||
|
|
||||||
|
Revision ID: ${up_revision}
|
||||||
|
Revises: ${down_revision | comma,n}
|
||||||
|
Create Date: ${create_date}
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
${imports if imports else ""}
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = ${repr(up_revision)}
|
||||||
|
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||||
|
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
${downgrades if downgrades else "pass"}
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
"""add_unique_constraint_to_call_session_id
|
||||||
|
|
||||||
|
Revision ID: 9163176d6848
|
||||||
|
Revises: a7e5c5ef6bc1
|
||||||
|
Create Date: 2025-11-20 23:28:40.770696
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '9163176d6848'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = 'a7e5c5ef6bc1'
|
||||||
|
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.drop_index(op.f('ix_call_events_call_session_id'), table_name='call_events')
|
||||||
|
op.create_index(op.f('ix_call_events_call_session_id'), 'call_events', ['call_session_id'], unique=True)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index(op.f('ix_call_events_call_session_id'), table_name='call_events')
|
||||||
|
op.create_index(op.f('ix_call_events_call_session_id'), 'call_events', ['call_session_id'], unique=False)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ class CallEvent(Base):
|
|||||||
__tablename__ = "call_events"
|
__tablename__ = "call_events"
|
||||||
|
|
||||||
id = Column(PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, index=True)
|
id = Column(PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, index=True)
|
||||||
call_session_id = Column(BigInteger, nullable=False, index=True)
|
call_session_id = Column(BigInteger, nullable=False, unique=True, index=True)
|
||||||
direction = Column(String, nullable=False)
|
direction = Column(String, nullable=False)
|
||||||
notification_mnemonic = Column(String, nullable=False)
|
notification_mnemonic = Column(String, nullable=False)
|
||||||
last_answered_employee_full_name = Column(String, nullable=True)
|
last_answered_employee_full_name = Column(String, nullable=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user