new_contents: """Added self-referential image parent
  
  Revision ID: f96f78987d58
  Revises: 698cc06661d6
  Create Date: 2016-03-20 19:21:05.651929
  
  """
  
  # revision identifiers, used by Alembic.
  revision = 'f96f78987d58'
  down_revision = '698cc06661d6'
  branch_labels = None
  depends_on = None
  
  from alembic import op
  import sqlalchemy as sa
  
  
  def upgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.add_column('images', sa.Column('parent_image_id', sa.Integer(), nullable=True))
      op.create_index(op.f('ix_images_imbo_id'), 'images', ['imbo_id'], unique=False)
      op.create_index(op.f('ix_images_parent_image_id'), 'images', ['parent_image_id'], unique=False)
      op.create_foreign_key(None, 'images', 'images', ['parent_image_id'], ['id'])
      op.create_index(op.f('ix_pages_sections_layout_settings_page_section_id'), 'pages_sections_layout_settings', ['page_section_id'], unique=False)
      op.drop_index('ix_sites_settings_site_id', table_name='sites_settings')
      ### end Alembic commands ###
  
  
  def downgrade():
      ### commands auto generated by Alembic - please adjust! ###
      op.create_index('ix_sites_settings_site_id', 'sites_settings', ['site_id'], unique=False)
      op.drop_index(op.f('ix_pages_sections_layout_settings_page_section_id'), table_name='pages_sections_layout_settings')
      op.drop_constraint(None, 'images', type_='foreignkey')
      op.drop_index(op.f('ix_images_parent_image_id'), table_name='images')
      op.drop_index(op.f('ix_images_imbo_id'), table_name='images')
      op.drop_column('images', 'parent_image_id')
      ### end Alembic commands ###
  
subject: Add DB migration for self referential images