Coverage for manila/db/migrations/alembic/versions/e6d88547b381_add_progress_field_to_share_instance.py: 75%

24 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Licensed under the Apache License, Version 2.0 (the "License"); you may 

2# not use this file except in compliance with the License. You may obtain 

3# a copy of the License at 

4# 

5# http://www.apache.org/licenses/LICENSE-2.0 

6# 

7# Unless required by applicable law or agreed to in writing, software 

8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

10# License for the specific language governing permissions and limitations 

11# under the License. 

12 

13"""add-progress-field-to-share-instance 

14 

15Revision ID: e6d88547b381 

16Revises: 805685098bd2 

17Create Date: 2020-01-31 14:06:15.952747 

18 

19""" 

20 

21# revision identifiers, used by Alembic. 

22revision = 'e6d88547b381' 

23down_revision = '805685098bd2' 

24 

25from alembic import op 

26from manila.common import constants 

27from manila.db.migrations import utils 

28from oslo_log import log 

29import sqlalchemy as sa 

30 

31 

32LOG = log.getLogger(__name__) 

33 

34 

35def upgrade(): 

36 

37 try: 

38 connection = op.get_bind() 

39 op.add_column('share_instances', 

40 sa.Column('progress', sa.String(32), nullable=True, 

41 default=None)) 

42 share_instances_table = utils.load_table('share_instances', connection) 

43 

44 updated_data = {'progress': '100%'} 

45 

46 # pylint: disable=no-value-for-parameter 

47 op.execute( 

48 share_instances_table.update().where( 

49 share_instances_table.c.status == constants.STATUS_AVAILABLE, 

50 ).values(updated_data) 

51 ) 

52 except Exception: 

53 LOG.error("Column share_instances.progress not created.") 

54 raise 

55 

56 

57def downgrade(): 

58 try: 

59 op.drop_column('share_instances', 'progress') 

60 except Exception: 

61 LOG.error("Column share_instances.progress not dropped.") 

62 raise