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/193609692158_missing_indexes.py
"""missing indexes

Revision ID: 193609692158
Revises: 7a6e74d145a
Create Date: 2016-11-18 11:18:51.705638

"""

# revision identifiers, used by Alembic.
revision = '193609692158'
down_revision = '7a6e74d145a'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from sqlalchemy.dialects import postgresql

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.execute("UPDATE agent_schedules SET created_on='1970-01-01' WHERE created_on IS NULL")
    op.alter_column('agent_schedules', 'created_on',
               existing_type=postgresql.TIMESTAMP(timezone=True),
               nullable=False)
    op.execute("UPDATE agent_schedules SET updated_on='1970-01-01' WHERE updated_on IS NULL")
    op.alter_column('agent_schedules', 'updated_on',
               existing_type=postgresql.TIMESTAMP(timezone=True),
               nullable=False)
    op.create_index(op.f('ix_agent_schedules_day'), 'agent_schedules', ['day'], unique=False)
    op.create_index(op.f('ix_agent_schedules_user_id'), 'agent_schedules', ['user_id'], unique=False)
    op.drop_index('agent_schedule_agent_id_index', table_name='agent_schedules')
    op.drop_index('agent_schedule_id_index', table_name='agent_schedules')
    op.drop_index('agent_schedule_user_id_index', table_name='agent_schedules')
    #op.drop_index('uq_widgets_guid', table_name='widgets')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    #op.create_index('uq_widgets_guid', 'widgets', ['guid'], unique=True)
    op.create_index('agent_schedule_user_id_index', 'agent_schedules', ['user_id'], unique=False)
    op.create_index('agent_schedule_id_index', 'agent_schedules', ['id'], unique=True)
    op.create_index('agent_schedule_agent_id_index', 'agent_schedules', ['agent_id'], unique=False)
    op.drop_index(op.f('ix_agent_schedules_user_id'), table_name='agent_schedules')
    op.drop_index(op.f('ix_agent_schedules_day'), table_name='agent_schedules')
    op.alter_column('agent_schedules', 'updated_on',
               existing_type=postgresql.TIMESTAMP(timezone=True),
               nullable=True)
    op.alter_column('agent_schedules', 'created_on',
               existing_type=postgresql.TIMESTAMP(timezone=True),
               nullable=True)
    ### end Alembic commands ###