Skip to content

Commit

Permalink
Add collection id to release, record, compiled_release: Stage 1
Browse files Browse the repository at this point in the history
Add columns and indexes, NULLABLE

#236
  • Loading branch information
odscjames committed Jan 9, 2020
1 parent d926f8f commit 8cfaba7
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""add-collection-id
Revision ID: bdfc23d8334c
Revises: 0fa56a3d3f90
Create Date: 2020-01-09 08:30:01.478751
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'bdfc23d8334c'
down_revision = '0fa56a3d3f90'
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
'record',
sa.Column('collection_id', sa.Integer,
sa.ForeignKey('collection.id', name='fk_record_collection_id'),
nullable=True))
op.add_column(
'release',
sa.Column('collection_id', sa.Integer,
sa.ForeignKey('collection.id', name='fk_release_collection_id'),
nullable=True))
op.add_column(
'compiled_release',
sa.Column('collection_id', sa.Integer,
sa.ForeignKey('collection.id', name='fk_compiled_release_collection_id'),
nullable=True))

op.create_index('record_collection_id_idx', 'record', ['collection_id'])
op.create_index('release_collection_id_idx', 'release', ['collection_id'])
op.create_index('compiled_release_collection_id_idx', 'compiled_release', ['collection_id'])


def downgrade():
op.drop_column('record', 'collection_id')
op.drop_column('release', 'collection_id')
op.drop_column('compiled_release', 'collection_id')

0 comments on commit 8cfaba7

Please sign in to comment.