HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/buyercall/migrations/versions/a378e621db3e_create_channel_type.py
"""create channel type

Revision ID: a378e621db3e
Revises: 128f71033b03
Create Date: 2022-04-11 20:05:50.898648

"""

# revision identifiers, used by Alembic.
revision = 'a378e621db3e'
down_revision = '128f71033b03'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from buyercall.lib.util_sqlalchemy import AwareDateTime

def upgrade():
    op.create_table('channel_type',
    sa.Column('created_on', AwareDateTime(), nullable=False),
    sa.Column('updated_on', AwareDateTime(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sid', postgresql.UUID(as_uuid=True), nullable=True),
    sa.Column('name', sa.String(length=36), nullable=False),
    sa.Column('parent_type_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['parent_type_id'], ['channel_type.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_channel_type_parent_type_id'), 'channel_type', ['parent_type_id'], unique=False)
    op.create_index(op.f('ix_channel_type_sid'), 'channel_type', ['sid'], unique=True)

def downgrade():
    op.drop_index(op.f('ix_channel_updated_by'), table_name='channel')
    op.drop_index(op.f('ix_channel_source'), table_name='channel')
    op.drop_index(op.f('ix_channel_sid'), table_name='channel')
    op.drop_index(op.f('ix_channel_partnership_id'), table_name='channel')
    op.drop_index(op.f('ix_channel_partnership_account_id'), table_name='channel')
    op.drop_index(op.f('ix_channel_created_by'), table_name='channel')
    op.drop_table('channel')
    op.drop_index(op.f('ix_channel_type_sid'), table_name='channel_type')
    op.drop_index(op.f('ix_channel_type_parent_type_id'), table_name='channel_type')
    op.drop_table('channel_type')