Files
resolutionflow/backend/alembic/versions/060_add_psa_post_log.py
Michael Chihlas 7059969d05 feat(psa): add PsaPostLog model and migration
Audit trail for notes posted to PSA systems. Tracks session ID,
ticket ID, note type, content, status (success/failed), and any
status changes made alongside the note post.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 23:28:21 -04:00

58 lines
1.7 KiB
Python

"""Add psa_post_log table for PSA note posting audit trail.
Revision ID: 060
Revises: 059
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = "060"
down_revision = "059"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"psa_post_log",
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
sa.Column(
"session_id",
postgresql.UUID(as_uuid=True),
sa.ForeignKey("sessions.id", ondelete="CASCADE"),
nullable=False,
index=True,
),
sa.Column(
"psa_connection_id",
postgresql.UUID(as_uuid=True),
sa.ForeignKey("psa_connections.id", ondelete="SET NULL"),
nullable=True,
),
sa.Column("ticket_id", sa.String(100), nullable=False),
sa.Column("note_type", sa.String(50), nullable=False),
sa.Column("content_posted", sa.Text(), nullable=False),
sa.Column("external_note_id", sa.String(100), nullable=True),
sa.Column("status", sa.String(20), nullable=False),
sa.Column("error_message", sa.Text(), nullable=True),
sa.Column("status_changed_from", sa.String(100), nullable=True),
sa.Column("status_changed_to", sa.String(100), nullable=True),
sa.Column(
"posted_by",
postgresql.UUID(as_uuid=True),
sa.ForeignKey("users.id"),
nullable=False,
),
sa.Column(
"posted_at",
sa.DateTime(timezone=True),
nullable=False,
server_default=sa.func.now(),
),
)
def downgrade() -> None:
op.drop_table("psa_post_log")