text: """Add StreamPhotometry table
  
  Revision ID: 0595e877f471
  Revises: c867ada3e0c4
  Create Date: 2021-04-23 10:34:12.985368
  
  """
  from alembic import op
  import sqlalchemy as sa
  
  
  # revision identifiers, used by Alembic.
  revision = '0595e877f471'
  down_revision = 'c867ada3e0c4'
  branch_labels = None
  depends_on = None
  
  
  def upgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.create_table(
          'stream_photometry',
          sa.Column('created_at', sa.DateTime(), nullable=False),
          sa.Column('modified', sa.DateTime(), nullable=False),
          sa.Column('id', sa.Integer(), nullable=False),
          sa.Column('stream_id', sa.Integer(), nullable=False),
          sa.Column('photometr_id', sa.Integer(), nullable=False),
          sa.ForeignKeyConstraint(
              ['photometr_id'], ['photometry.id'], ondelete='CASCADE'
          ),
          sa.ForeignKeyConstraint(['stream_id'], ['streams.id'], ondelete='CASCADE'),
          sa.PrimaryKeyConstraint('id'),
      )
      op.create_index(
          op.f('ix_stream_photometry_created_at'),
          'stream_photometry',
          ['created_at'],
          unique=False,
      )
      op.create_index(
          'stream_photometry_forward_ind',
          'stream_photometry',
          ['stream_id', 'photometr_id'],
          unique=True,
      )
      op.create_index(
          'stream_photometry_reverse_ind',
          'stream_photometry',
          ['photometr_id', 'stream_id'],
          unique=False,
      )
      # ### end Alembic commands ###
  
  
  def downgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.drop_index('stream_photometry_reverse_ind', table_name='stream_photometry')
      op.drop_index('stream_photometry_forward_ind', table_name='stream_photometry')
      op.drop_index(
          op.f('ix_stream_photometry_created_at'), table_name='stream_photometry'
      )
      op.drop_table('stream_photometry')
      # ### end Alembic commands ###
  