Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/persistence/sql/alembic/versions/8d910c8de8b6_use_largebinary_to_store_action_message.py: 80.00%

15 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-06-11 15:37 +0000

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""" 

22import sqlalchemy as sa 

23from alembic import op 

24 

25# revision identifiers, used by Alembic. 

26revision = "8d910c8de8b6" 

27down_revision = "2b49634f4459" 

28branch_labels = None 

29depends_on = None 

30 

31 

32def upgrade() -> None: 

33 with op.batch_alter_table("jobs") as batch_op: 

34 # Drop this column entirely rather than trying to migrate the content, 

35 # since anything there is likely to not be usefully recoverable. 

36 batch_op.drop_column("action") 

37 # `sa.LargeBinary` selects the actual column type based on the database 

38 # backend's preference for storing binary data. 

39 batch_op.add_column(sa.Column("action", sa.LargeBinary(), nullable=True)) 

40 

41 

42def downgrade() -> None: 

43 with op.batch_alter_table("jobs") as batch_op: 

44 batch_op.drop_column("action") 

45 batch_op.add_column(sa.Column("action", sa.String(), nullable=True))