Coverage for manila/db/migrations/alembic/versions/ac0620cbe74d_add_share_network_subnet_metadata.py: 73%
22 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« 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.
13"""Add share network subnet metadata
15Revision ID: ac0620cbe74d
16Revises: 1e2d600bf972
17Create Date: 2023-01-07 14:13:25.525968
19"""
21# revision identifiers, used by Alembic.
22revision = 'ac0620cbe74d'
23down_revision = '1e2d600bf972'
25from alembic import op
26from oslo_log import log
27import sqlalchemy as sql
29LOG = log.getLogger(__name__)
31share_network_subnet_metadata_table_name = 'share_network_subnet_metadata'
34def upgrade():
35 context = op.get_context()
36 mysql_dl = context.bind.dialect.name == 'mysql'
37 datetime_type = (sql.dialects.mysql.DATETIME(fsp=6)
38 if mysql_dl else sql.DateTime)
39 try:
40 op.create_table(
41 share_network_subnet_metadata_table_name,
42 sql.Column('deleted', sql.String(36), default='False'),
43 sql.Column('created_at', datetime_type),
44 sql.Column('updated_at', datetime_type),
45 sql.Column('deleted_at', datetime_type),
46 sql.Column('share_network_subnet_id', sql.String(36),
47 sql.ForeignKey('share_network_subnets.id'),
48 nullable=False),
49 sql.Column('key', sql.String(255), nullable=False),
50 sql.Column('value', sql.String(1023), nullable=False),
51 sql.Column('id', sql.Integer, primary_key=True, nullable=False),
52 mysql_engine='InnoDB',
53 mysql_charset='utf8'
54 )
55 except Exception:
56 LOG.error("Table |%s| not created!",
57 share_network_subnet_metadata_table_name)
58 raise
61def downgrade():
62 try:
63 op.drop_table(share_network_subnet_metadata_table_name)
64 except Exception:
65 LOG.error("Table |%s| not dropped!",
66 share_network_subnet_metadata_table_name)
67 raise