mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-15 10:11:27 -06:00
Create NestedMutableList/JSON Alembic Migration
A commented out portion was added for a simpler add/drop column style. https://blog.miguelgrinberg.com/post/fixing-alter-table-errors-with-flask-migrate-and-sqlite
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Change votes to nested mutable list (JSON backed)
|
||||
|
||||
Revision ID: b26551e73407
|
||||
Revises: 43c1baca42a2
|
||||
Create Date: 2021-02-17 04:40:19.691104-06:00
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy_json import NestedMutableList
|
||||
|
||||
revision = 'b26551e73407'
|
||||
down_revision = '43c1baca42a2'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
with op.batch_alter_table('submission', schema=None) as batch_op:
|
||||
batch_op.alter_column("votes", type_=NestedMutableList.as_mutable(sa.JSON))
|
||||
# batch_op.drop_column('submission', 'votes')
|
||||
# batch_op.add_column('submission', sa.Column('votes', NestedMutableList.as_mutable(sa.JSON)))
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
with op.batch_alter_table('submission', schema=None) as batch_op:
|
||||
batch_op.alter_column("votes", type_=sa.Integer(), nullable=True)
|
||||
# batch_op.drop_column('votes')
|
||||
# batch_op.add_column('submission', sa.Column('votes', sa.Integer(), nullable=True))
|
||||
Reference in New Issue
Block a user