old_contents: """add column title in PageChunk
  
  Revision ID: bb087e4e53
  Revises: 38331aa4875
  Create Date: 2015-08-10 13:29:19.578492
  
  """
  
  # revision identifiers, used by Alembic.
  revision = 'bb087e4e53'
  down_revision = '38331aa4875'
  
  from alembic import op
  import sqlalchemy as sa
  
  
  def upgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.add_column('pagechunks', sa.Column('title', sa.Text(), nullable=True))
      op.alter_column('pagechunks', 'name',
                 existing_type=sa.TEXT(),
                 nullable=False)
      op.create_unique_constraint('pagechunks_title_key', 'pagechunks', ['title'])
      op.execute(
          'update pagechunks set title = name'
      )
      op.alter_column('pagechunks', 'title', nullable=False)
      ### end Alembic commands ###
  
  
  def downgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.drop_constraint('pagechunks_title_key', 'pagechunks', type_='unique')
      op.alter_column('pagechunks', 'name',
                 existing_type=sa.TEXT(),
                 nullable=True)
      op.drop_column('pagechunks', 'title')
      ### end Alembic commands ###
  
new_contents: """add column title in PageChunk
  
  Revision ID: bb087e4e53
  Revises: 38331aa4875
  Create Date: 2015-08-10 13:29:19.578492
  
  """
  
  # revision identifiers, used by Alembic.
  revision = 'bb087e4e53'
  down_revision = '12fe8d110f7'
  
  from alembic import op
  import sqlalchemy as sa
  
  
  def upgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.add_column('pagechunks', sa.Column('title', sa.Text(), nullable=True))
      op.alter_column('pagechunks', 'name',
                 existing_type=sa.TEXT(),
                 nullable=False)
      op.create_unique_constraint('pagechunks_title_key', 'pagechunks', ['title'])
      op.execute(
          'update pagechunks set title = name'
      )
      op.alter_column('pagechunks', 'title', nullable=False)
      ### end Alembic commands ###
  
  
  def downgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.drop_constraint('pagechunks_title_key', 'pagechunks', type_='unique')
      op.alter_column('pagechunks', 'name',
                 existing_type=sa.TEXT(),
                 nullable=True)
      op.drop_column('pagechunks', 'title')
      ### end Alembic commands ###
  
subject: fix migration