diff --git a/alembic/versions/b26551e73407_change_votes_to_nested_mutable_list_.py b/alembic/versions/b26551e73407_change_votes_to_nested_mutable_list_.py new file mode 100644 index 0000000..05aab3a --- /dev/null +++ b/alembic/versions/b26551e73407_change_votes_to_nested_mutable_list_.py @@ -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))