1# Copyright (C) 2020 Bloomberg LP
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# <http://www.apache.org/licenses/LICENSE-2.0>
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Use LargeBinary to store Action message
16
17Revision ID: 8d910c8de8b6
18Revises: 2b49634f4459
19Create Date: 2020-11-26 16:40:52.682830
20
21"""
22from alembic import op
23import sqlalchemy as sa
24
25
26# revision identifiers, used by Alembic.
27revision = '8d910c8de8b6'
28down_revision = '2b49634f4459'
29branch_labels = None
30depends_on = None
31
32
33def upgrade():
34 with op.batch_alter_table('jobs') as batch_op:
35 # Drop this column entirely rather than trying to migrate the content,
36 # since anything there is likely to not be usefully recoverable.
37 batch_op.drop_column('action')
38 # `sa.LargeBinary` selects the actual column type based on the database
39 # backend's preference for storing binary data.
40 batch_op.add_column(sa.Column('action', sa.LargeBinary(), nullable=True))
41
42
43def downgrade():
44 with op.batch_alter_table('jobs') as batch_op:
45 batch_op.drop_column('action')
46 batch_op.add_column(sa.Column('action', sa.String(), nullable=True))