Coverage for manila/db/migrations/alembic/versions/1e2d600bf972_add_transfers.py: 71%
21 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_transfers
15Revision ID: 1e2d600bf972
16Revises: c476aeb186ec
17Create Date: 2022-05-30 16:37:18.325464
19"""
21# revision identifiers, used by Alembic.
22revision = '1e2d600bf972'
23down_revision = 'c476aeb186ec'
25from alembic import op
26from oslo_log import log
27import sqlalchemy as sa
29LOG = log.getLogger(__name__)
32def upgrade():
33 context = op.get_context()
34 mysql_dl = context.bind.dialect.name == 'mysql'
35 datetime_type = (sa.dialects.mysql.DATETIME(fsp=6)
36 if mysql_dl else sa.DateTime)
38 try:
39 op.create_table(
40 'transfers',
41 sa.Column('id', sa.String(36), primary_key=True, nullable=False),
42 sa.Column('created_at', datetime_type),
43 sa.Column('updated_at', datetime_type),
44 sa.Column('deleted_at', datetime_type),
45 sa.Column('deleted', sa.String(36), default='False'),
46 sa.Column('resource_id', sa.String(36), nullable=False),
47 sa.Column('resource_type', sa.String(255), nullable=False),
48 sa.Column('display_name', sa.String(255)),
49 sa.Column('salt', sa.String(255)),
50 sa.Column('crypt_hash', sa.String(255)),
51 sa.Column('expires_at', datetime_type),
52 sa.Column('source_project_id', sa.String(255), nullable=True),
53 sa.Column('destination_project_id', sa.String(255), nullable=True),
54 sa.Column('accepted', sa.Boolean, default=False),
55 mysql_engine='InnoDB',
56 mysql_charset='utf8',
57 )
58 except Exception:
59 LOG.error("Table |%s| not created!", 'transfers')
60 raise
63def downgrade():
64 try:
65 op.drop_table('transfers')
66 except Exception:
67 LOG.error("transfers table not dropped")
68 raise