Bckn funcion
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
"""add_ticket_issues
|
||||
|
||||
Revision ID: b2dcb926e091
|
||||
Revises: 46bccd948688
|
||||
Create Date: 2026-03-17 16:25:34.452826
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = 'b2dcb926e091'
|
||||
down_revision = '46bccd948688'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
conn = op.get_bind()
|
||||
inspector = sa.inspect(conn)
|
||||
existing_tables = inspector.get_table_names()
|
||||
|
||||
if 'ticket_issues' not in existing_tables:
|
||||
op.create_table(
|
||||
'ticket_issues',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('tenant_id', sa.UUID(), nullable=False),
|
||||
sa.Column('ticket_id', sa.UUID(), nullable=False),
|
||||
sa.Column('created_by', sa.UUID(), nullable=False),
|
||||
sa.Column('content', sa.Text(), nullable=False),
|
||||
sa.Column(
|
||||
'priority',
|
||||
postgresql.ENUM('LOW', 'MEDIUM', 'HIGH', 'URGENT',
|
||||
name='ticket_priority_enum', create_type=False),
|
||||
nullable=False,
|
||||
),
|
||||
sa.Column('attachment_path', sa.String(500), nullable=True),
|
||||
sa.Column('attachment_filename', sa.String(255), nullable=True),
|
||||
sa.Column('attachment_mime_type', sa.String(100), nullable=True),
|
||||
sa.Column('created_at', postgresql.TIMESTAMP(timezone=True),
|
||||
server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', postgresql.TIMESTAMP(timezone=True),
|
||||
server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['ticket_id'], ['tickets.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['created_by'], ['users.id']),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
)
|
||||
|
||||
if 'ticket_issue_tagged_users' not in existing_tables:
|
||||
op.create_table(
|
||||
'ticket_issue_tagged_users',
|
||||
sa.Column('issue_id', sa.UUID(), nullable=False),
|
||||
sa.Column('user_id', sa.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['issue_id'], ['ticket_issues.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('issue_id', 'user_id'),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table('ticket_issue_tagged_users')
|
||||
op.drop_table('ticket_issues')
|
||||
Reference in New Issue
Block a user