52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
|
"""user collections
|
||
|
|
||
|
Revision ID: 21750f5bbab1
|
||
|
Revises: cdd471f48b0d
|
||
|
Create Date: 2024-02-24 22:47:05.197801
|
||
|
|
||
|
"""
|
||
|
from alembic import op
|
||
|
import sqlalchemy as sa
|
||
|
|
||
|
|
||
|
# revision identifiers, used by Alembic.
|
||
|
revision = '21750f5bbab1'
|
||
|
down_revision = 'cdd471f48b0d'
|
||
|
branch_labels = None
|
||
|
depends_on = None
|
||
|
|
||
|
|
||
|
def upgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
op.create_table('collection',
|
||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||
|
sa.PrimaryKeyConstraint('id')
|
||
|
)
|
||
|
with op.batch_alter_table('task', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('collection_id', sa.Integer(), nullable=True))
|
||
|
batch_op.create_foreign_key(None, 'collection', ['collection_id'], ['id'])
|
||
|
|
||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('collection_id', sa.Integer(), nullable=True))
|
||
|
batch_op.drop_constraint('user_session_id_fkey', type_='foreignkey')
|
||
|
batch_op.create_foreign_key(None, 'collection', ['collection_id'], ['id'])
|
||
|
batch_op.drop_column('session_id')
|
||
|
|
||
|
# ### end Alembic commands ###
|
||
|
|
||
|
|
||
|
def downgrade():
|
||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||
|
batch_op.add_column(sa.Column('session_id', sa.INTEGER(), autoincrement=False, nullable=True))
|
||
|
batch_op.drop_constraint(None, type_='foreignkey')
|
||
|
batch_op.create_foreign_key('user_session_id_fkey', 'session', ['session_id'], ['id'])
|
||
|
batch_op.drop_column('collection_id')
|
||
|
|
||
|
with op.batch_alter_table('task', schema=None) as batch_op:
|
||
|
batch_op.drop_constraint(None, type_='foreignkey')
|
||
|
batch_op.drop_column('collection_id')
|
||
|
|
||
|
op.drop_table('collection')
|
||
|
# ### end Alembic commands ###
|