
import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = '573faf4ac644'
down_revision = '342fa3076650'


def upgrade():
    op.alter_column('event_index', 'start_date', nullable=False, schema='events')
    op.create_index('ix_start_date', 'event_index', ['start_date'], schema='events')

    op.add_column('event_index',
                  sa.Column('end_date', sa.DateTime(), nullable=False, server_default='now()'),
                  schema='events')
    op.alter_column('event_index', 'end_date', server_default=None, schema='events')
    op.create_index('ix_end_date', 'event_index', ['end_date'], schema='events')


def downgrade():
    op.alter_column('event_index', 'start_date', nullable=True, schema='events')
    op.drop_index('ix_start_date', table_name='event_index', schema='events')

    op.drop_column('event_index', 'end_date', schema='events')


import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = '573faf4ac644'
down_revision = '342fa3076650'


def upgrade():
    op.alter_column('event_index', 'start_date', nullable=False, schema='events')
    op.create_index('ix_events_event_index_start_date', 'event_index', ['start_date'], schema='events')

    op.add_column('event_index',
                  sa.Column('end_date', sa.DateTime(), nullable=False, server_default='now()'),
                  schema='events')
    op.alter_column('event_index', 'end_date', server_default=None, schema='events')
    op.create_index('ix_events_event_index_end_date', 'event_index', ['end_date'], schema='events')


def downgrade():
    op.alter_column('event_index', 'start_date', nullable=True, schema='events')
    op.drop_index('ix_events_event_index_start_date', table_name='event_index', schema='events')
    op.drop_column('event_index', 'end_date', schema='events')

Use index name matching the current naming schema
Use index name matching the current naming schema

  
  import sqlalchemy as sa
  from alembic import op
  
  
  # revision identifiers, used by Alembic.
  revision = '573faf4ac644'
  down_revision = '342fa3076650'
  
  
  def upgrade():
      op.alter_column('event_index', 'start_date', nullable=False, schema='events')
-     op.create_index('ix_start_date', 'event_index', ['start_date'], schema='events')
+     op.create_index('ix_events_event_index_start_date', 'event_index', ['start_date'], schema='events')
  
      op.add_column('event_index',
                    sa.Column('end_date', sa.DateTime(), nullable=False, server_default='now()'),
                    schema='events')
      op.alter_column('event_index', 'end_date', server_default=None, schema='events')
-     op.create_index('ix_end_date', 'event_index', ['end_date'], schema='events')
+     op.create_index('ix_events_event_index_end_date', 'event_index', ['end_date'], schema='events')
  
  
  def downgrade():
      op.alter_column('event_index', 'start_date', nullable=True, schema='events')
-     op.drop_index('ix_start_date', table_name='event_index', schema='events')
+     op.drop_index('ix_events_event_index_start_date', table_name='event_index', schema='events')
- 
      op.drop_column('event_index', 'end_date', schema='events')
  
Use index name matching the current naming schema
## Code Before:

import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = '573faf4ac644'
down_revision = '342fa3076650'


def upgrade():
    op.alter_column('event_index', 'start_date', nullable=False, schema='events')
    op.create_index('ix_start_date', 'event_index', ['start_date'], schema='events')

    op.add_column('event_index',
                  sa.Column('end_date', sa.DateTime(), nullable=False, server_default='now()'),
                  schema='events')
    op.alter_column('event_index', 'end_date', server_default=None, schema='events')
    op.create_index('ix_end_date', 'event_index', ['end_date'], schema='events')


def downgrade():
    op.alter_column('event_index', 'start_date', nullable=True, schema='events')
    op.drop_index('ix_start_date', table_name='event_index', schema='events')

    op.drop_column('event_index', 'end_date', schema='events')

## Instruction:
Use index name matching the current naming schema
## Code After:

import sqlalchemy as sa
from alembic import op


# revision identifiers, used by Alembic.
revision = '573faf4ac644'
down_revision = '342fa3076650'


def upgrade():
    op.alter_column('event_index', 'start_date', nullable=False, schema='events')
    op.create_index('ix_events_event_index_start_date', 'event_index', ['start_date'], schema='events')

    op.add_column('event_index',
                  sa.Column('end_date', sa.DateTime(), nullable=False, server_default='now()'),
                  schema='events')
    op.alter_column('event_index', 'end_date', server_default=None, schema='events')
    op.create_index('ix_events_event_index_end_date', 'event_index', ['end_date'], schema='events')


def downgrade():
    op.alter_column('event_index', 'start_date', nullable=True, schema='events')
    op.drop_index('ix_events_event_index_start_date', table_name='event_index', schema='events')
    op.drop_column('event_index', 'end_date', schema='events')
