open-law/migrations/versions/a8184a265190_version_user_id.py
2023-06-14 14:10:29 +03:00

35 lines
935 B
Python

"""version_user_id
Revision ID: a8184a265190
Revises: ef2254f9bc92
Create Date: 2023-06-14 14:04:38.690202
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a8184a265190'
down_revision = 'ef2254f9bc92'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('book_versions', schema=None) as batch_op:
batch_op.add_column(sa.Column('user_id', sa.Integer(), nullable=True))
batch_op.create_foreign_key(None, 'users', ['user_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('book_versions', schema=None) as batch_op:
batch_op.drop_constraint(None, type_='foreignkey')
batch_op.drop_column('user_id')
# ### end Alembic commands ###