Coverage for manila/db/migrations/alembic/versions/4a482571410f_add_backends_info_table.py: 68%

19 statements  

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

1# Copyright 2017 Huawei inc. 

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_backend_info_table 

17 

18Revision ID: 4a482571410f 

19Revises: 27cb96d991fa 

20Create Date: 2017-05-18 14:47:38.201658 

21 

22""" 

23 

24# revision identifiers, used by Alembic. 

25revision = '4a482571410f' 

26down_revision = '27cb96d991fa' 

27 

28from alembic import op 

29from oslo_log import log 

30import sqlalchemy as sql 

31 

32LOG = log.getLogger(__name__) 

33 

34backend_info_table_name = 'backend_info' 

35 

36 

37def upgrade(): 

38 try: 

39 op.create_table( 

40 backend_info_table_name, 

41 sql.Column('created_at', sql.DateTime), 

42 sql.Column('updated_at', sql.DateTime), 

43 sql.Column('deleted_at', sql.DateTime), 

44 sql.Column('deleted', sql.Integer, default=0), 

45 sql.Column('host', sql.String(255), 

46 nullable=False, primary_key=True), 

47 sql.Column('info_hash', sql.String(255), 

48 nullable=False), 

49 mysql_engine='InnoDB', 

50 mysql_charset='utf8', 

51 ) 

52 except Exception: 

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

54 backend_info_table_name) 

55 raise 

56 

57 

58def downgrade(): 

59 try: 

60 op.drop_table(backend_info_table_name) 

61 except Exception: 

62 LOG.error("%s table not dropped", backend_info_table_name) 

63 raise