From 730c7d33c10c2d6ed6fd544e0d4965b8c97812f6 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sun, 30 Mar 2025 07:52:48 +0000 Subject: [PATCH] Add migration for Exception --- ...250330_075234_7497ef41_create_exception.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 alembic/versions/20250330_075234_7497ef41_create_exception.py diff --git a/alembic/versions/20250330_075234_7497ef41_create_exception.py b/alembic/versions/20250330_075234_7497ef41_create_exception.py new file mode 100644 index 0000000..8618582 --- /dev/null +++ b/alembic/versions/20250330_075234_7497ef41_create_exception.py @@ -0,0 +1,36 @@ +"""create exceptions table + +Revision ID: a2b3c4d5e6f7 +Revises: 0001 +Create Date: 2024-03-26 12:00:00.000000 +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects.postgresql import UUID +from sqlalchemy.sql import func + +# revision identifiers +revision = 'a2b3c4d5e6f7' +down_revision = '0001' +branch_labels = None +depends_on = None + +def upgrade(): + op.create_table( + 'exceptions', + sa.Column('id', UUID(as_uuid=True), primary_key=True), + sa.Column('error_code', sa.String(50), nullable=False), + sa.Column('message', sa.String(255), nullable=False), + sa.Column('details', sa.Text, nullable=True), + sa.Column('stack_trace', sa.Text, nullable=True), + sa.Column('source', sa.String(100), nullable=False), + sa.Column('created_at', sa.DateTime, server_default=sa.func.now()), + sa.Column('updated_at', sa.DateTime, server_default=sa.func.now(), onupdate=sa.func.now()) + ) + + # Create index on error_code for faster lookups + op.create_index('ix_exceptions_error_code', 'exceptions', ['error_code']) + +def downgrade(): + op.drop_index('ix_exceptions_error_code') + op.drop_table('exceptions') \ No newline at end of file