restore long uuid data type

partial revert of Iffd6001c337fa692cc3925778eeb98dda46b2c78.
we are not able to revert the patch to support those chasing trunk.
this patch makes original migration a noop for future cases and
adds a follow up script to revert migration if already applied.

it does not revert ids that are under the domain of ceilometer and
are known to be within 128 char length, specifically:

- message_id
- message_signature
- event_id (alarm)
- alarm_id

Change-Id: I8c191adb897f27a1ce0f199ed35253324a5c3809
Closes-Bug: 1468916
This commit is contained in:
gordon chung 2015-06-26 14:59:59 -04:00
parent d9b04cd19c
commit 898a0a8741
3 changed files with 51 additions and 32 deletions

View File

@ -10,28 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import MetaData
from sqlalchemy import String
from sqlalchemy import Table
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
resource = Table('resource', meta, autoload=True)
resource.c.user_id.alter(type=String(128))
resource.c.project_id.alter(type=String(128))
resource.c.resource_id.alter(type=String(128))
resource.c.source_id.alter(type=String(128))
sample = Table('sample', meta, autoload=True)
sample.c.message_signature.alter(type=String(64))
sample.c.message_id.alter(type=String(128))
alarm = Table('alarm', meta, autoload=True)
alarm.c.alarm_id.alter(type=String(128))
alarm.c.user_id.alter(type=String(128))
alarm.c.project_id.alter(type=String(128))
alarm_history = Table('alarm_history', meta, autoload=True)
alarm_history.c.alarm_id.alter(type=String(128))
alarm_history.c.user_id.alter(type=String(128))
alarm_history.c.project_id.alter(type=String(128))
alarm_history.c.event_id.alter(type=String(128))
alarm_history.c.on_behalf_of.alter(type=String(128))
# NOTE(gordc): this is a noop script to handle bug1468916
# previous lowering of id length will fail if db contains data longer.
# this skips migration for those failing. the next script will resize
# if this original migration passed.
pass

View File

@ -0,0 +1,37 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import MetaData
from sqlalchemy import String
from sqlalchemy import Table
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
resource = Table('resource', meta, autoload=True)
resource.c.user_id.alter(type=String(255))
resource.c.project_id.alter(type=String(255))
resource.c.resource_id.alter(type=String(255))
resource.c.source_id.alter(type=String(255))
sample = Table('sample', meta, autoload=True)
sample.c.message_signature.alter(type=String(64))
sample.c.message_id.alter(type=String(128))
alarm = Table('alarm', meta, autoload=True)
alarm.c.alarm_id.alter(type=String(128))
alarm.c.user_id.alter(type=String(255))
alarm.c.project_id.alter(type=String(255))
alarm_history = Table('alarm_history', meta, autoload=True)
alarm_history.c.alarm_id.alter(type=String(128))
alarm_history.c.user_id.alter(type=String(255))
alarm_history.c.project_id.alter(type=String(255))
alarm_history.c.event_id.alter(type=String(128))
alarm_history.c.on_behalf_of.alter(type=String(255))

View File

@ -177,10 +177,10 @@ class Resource(Base):
)
internal_id = Column(Integer, primary_key=True)
user_id = Column(String(128))
project_id = Column(String(128))
source_id = Column(String(128))
resource_id = Column(String(128), nullable=False)
user_id = Column(String(255))
project_id = Column(String(255))
source_id = Column(String(255))
resource_id = Column(String(255), nullable=False)
resource_metadata = deferred(Column(JSONEncodedDict()))
metadata_hash = deferred(Column(String(32)))
samples = relationship("Sample", backref="resource")
@ -261,8 +261,8 @@ class Alarm(Base):
description = Column(Text)
timestamp = Column(PreciseTimestamp, default=lambda: timeutils.utcnow())
user_id = Column(String(128))
project_id = Column(String(128))
user_id = Column(String(255))
project_id = Column(String(255))
state = Column(String(255))
state_timestamp = Column(PreciseTimestamp,
@ -285,9 +285,9 @@ class AlarmChange(Base):
)
event_id = Column(String(128), primary_key=True)
alarm_id = Column(String(128))
on_behalf_of = Column(String(128))
project_id = Column(String(128))
user_id = Column(String(128))
on_behalf_of = Column(String(255))
project_id = Column(String(255))
user_id = Column(String(255))
type = Column(String(20))
detail = Column(Text)
timestamp = Column(PreciseTimestamp, default=lambda: timeutils.utcnow())