Coverage for manila/db/migrations/alembic/versions/11ee96se625f3_add_metadata_for_access.py: 68%

19 statements  

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

1# Copyright 2018 Huawei Corporation. 

2# All Rights Reserved. 

3# 

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

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

6# a copy of the License at 

7# 

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

9# 

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

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

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

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16"""add metadata for access rule 

17 

18Revision ID: 11ee96se625f3 

19Revises: 097fad24d2fc 

20Create Date: 2018-06-16 03:07:15.548947 

21 

22""" 

23 

24# revision identifiers, used by Alembic. 

25revision = '11ee96se625f3' 

26down_revision = '097fad24d2fc' 

27 

28from alembic import op 

29from oslo_log import log 

30import sqlalchemy as sql 

31 

32LOG = log.getLogger(__name__) 

33 

34access_metadata_table_name = 'share_access_rules_metadata' 

35 

36 

37def upgrade(): 

38 try: 

39 op.create_table( 

40 access_metadata_table_name, 

41 sql.Column('created_at', sql.DateTime(timezone=False)), 

42 sql.Column('updated_at', sql.DateTime(timezone=False)), 

43 sql.Column('deleted_at', sql.DateTime(timezone=False)), 

44 sql.Column('deleted', sql.String(36), default='False'), 

45 sql.Column('access_id', sql.String(36), 

46 sql.ForeignKey('share_access_map.id'), nullable=False), 

47 sql.Column('key', sql.String(255), nullable=False), 

48 sql.Column('value', sql.String(1023), nullable=False), 

49 sql.Column('id', sql.Integer, primary_key=True, nullable=False), 

50 mysql_engine='InnoDB', 

51 mysql_charset='utf8' 

52 ) 

53 except Exception: 

54 LOG.error("Table |%s| not created!", 

55 access_metadata_table_name) 

56 raise 

57 

58 

59def downgrade(): 

60 try: 

61 op.drop_table(access_metadata_table_name) 

62 except Exception: 

63 LOG.error("%s table not dropped", access_metadata_table_name) 

64 raise