contentdb/migrations/versions/aa6d7b595a94_.py

36 lines
1.1 KiB
Python

"""empty message
Revision ID: aa6d7b595a94
Revises: aa6d21889d22
Create Date: 2018-05-29 20:09:56.647358
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import text
# revision identifiers, used by Alembic.
revision = 'aa6d7b595a94'
down_revision = 'aa6d21889d22'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('package', sa.Column('media_license_id', sa.Integer()))
op.execute(text('UPDATE package SET media_license_id=license_id'))
op.alter_column('package', 'media_license_id', nullable=False)
op.alter_column('package', 'license_id', existing_type=sa.INTEGER(), nullable=False)
op.create_foreign_key(None, 'package', 'license', ['media_license_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('package', 'license_id',
existing_type=sa.INTEGER(),
nullable=True)
op.drop_column('package', 'media_license_id')
# ### end Alembic commands ###