Coverage for manila/db/migrations/alembic/versions/238720805ce1_add_messages_table.py: 82%
17 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 messages table
15Revision ID: 238720805ce1
16Revises: 31252d671ae5
17Create Date: 2017-02-02 08:38:55.134095
19"""
21# revision identifiers, used by Alembic.
22revision = '238720805ce1'
23down_revision = '31252d671ae5'
25from alembic import op
26from oslo_log import log
27from sqlalchemy import Column, DateTime
28from sqlalchemy import MetaData, String, Table
30LOG = log.getLogger(__name__)
33def upgrade():
34 meta = MetaData()
36 # New table
37 messages = Table(
38 'messages',
39 meta,
40 Column('id', String(36), primary_key=True, nullable=False),
41 Column('project_id', String(255), nullable=False),
42 Column('request_id', String(255), nullable=True),
43 Column('resource_type', String(255)),
44 Column('resource_id', String(36), nullable=True),
45 Column('action_id', String(10), nullable=False),
46 Column('detail_id', String(10), nullable=True),
47 Column('message_level', String(255), nullable=False),
48 Column('created_at', DateTime(timezone=False)),
49 Column('updated_at', DateTime(timezone=False)),
50 Column('deleted_at', DateTime(timezone=False)),
51 Column('deleted', String(36)),
52 Column('expires_at', DateTime(timezone=False)),
53 mysql_engine='InnoDB',
54 mysql_charset='utf8'
55 )
57 messages.create(op.get_bind())
60def downgrade():
61 try:
62 op.drop_table('messages')
63 except Exception:
64 LOG.error("messages table not dropped")
65 raise