"""phase10 annotations watches alerts Revision ID: 6b2d95ac3b46 Revises: b7e3d9f1a4c6 Create Date: 2026-05-29 22:14:49.426130 """ from collections.abc import Sequence import sqlalchemy as sa import sqlmodel from alembic import op from sqlalchemy.dialects import postgresql revision: str = "6b2d95ac3b46" down_revision: str | None = "b7e3d9f1a4c6" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None def upgrade() -> None: op.create_table( "annotations", sa.Column("id", sa.Integer(), nullable=False), sa.Column("account_id", sa.Integer(), nullable=False), sa.Column("chat_id", sa.BigInteger(), nullable=False), sa.Column("message_id", sa.BigInteger(), nullable=False), sa.Column("text", sqlmodel.sql.sqltypes.AutoString(), nullable=False), sa.Column( "created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.Column( "updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_annotations_chat_id"), "annotations", ["chat_id"], unique=False ) op.create_table( "watches", sa.Column("id", sa.Integer(), nullable=False), sa.Column("account_id", sa.Integer(), nullable=False), sa.Column("kind", sqlmodel.sql.sqltypes.AutoString(), nullable=False), sa.Column("params", postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.Column("enabled", sa.Boolean(), nullable=False), sa.Column( "created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.Column( "updated_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.PrimaryKeyConstraint("id"), ) op.create_table( "alerts", sa.Column("id", sa.Integer(), nullable=False), sa.Column("account_id", sa.Integer(), nullable=False), sa.Column("watch_id", sa.Integer(), nullable=False), sa.Column("ts", sa.DateTime(timezone=True), nullable=False), sa.Column("payload", postgresql.JSONB(astext_type=sa.Text()), nullable=False), sa.Column("seen", sa.Boolean(), nullable=False), sa.Column( "created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False, ), sa.ForeignKeyConstraint(["watch_id"], ["watches.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_index( op.f("ix_alerts_account_seen"), "alerts", ["account_id", "seen"], unique=False ) def downgrade() -> None: op.drop_index(op.f("ix_alerts_account_seen"), table_name="alerts") op.drop_table("alerts") op.drop_table("watches") op.drop_index(op.f("ix_annotations_chat_id"), table_name="annotations") op.drop_table("annotations")