From 57eb9e904aacae166d7265a914960415c57cd133 Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Tue, 8 Oct 2013 14:29:47 +0100 Subject: [PATCH] Change alarm_history.detail to text type The existing alarm_history.detail column size is 255 chars, which is not enough for some large JSON payloads. Change to Text column to make sure we store all detail. Change-Id: I1b4ebee33954acc1f41a4cf0d0b991055b7d4fe9 Closes-Bug: #1236861 Signed-off-by: Stephen Gran --- .../019_alarm_history_detail_is_text.py | 38 +++++++++++++++++++ ceilometer/storage/sqlalchemy/models.py | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 ceilometer/storage/sqlalchemy/migrate_repo/versions/019_alarm_history_detail_is_text.py diff --git a/ceilometer/storage/sqlalchemy/migrate_repo/versions/019_alarm_history_detail_is_text.py b/ceilometer/storage/sqlalchemy/migrate_repo/versions/019_alarm_history_detail_is_text.py new file mode 100644 index 000000000..bfb5d68b6 --- /dev/null +++ b/ceilometer/storage/sqlalchemy/migrate_repo/versions/019_alarm_history_detail_is_text.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- + +# Copyright 2013 OpenStack Foundation +# All Rights Reserved. +# Copyright 2013 IBM Corp. +# +# 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 String +from sqlalchemy import Text +from sqlalchemy import MetaData +from sqlalchemy import Table + + +meta = MetaData() + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + alm_hist = Table('alarm_history', meta, autoload=True) + alm_hist.c.detail.alter(type=Text) + + +def downgrade(migrate_engine): + meta.bind = migrate_engine + alm_hist = Table('alarm_history', meta, autoload=True) + alm_hist.c.detail.alter(type=String(255)) diff --git a/ceilometer/storage/sqlalchemy/models.py b/ceilometer/storage/sqlalchemy/models.py index 7d3f6524b..45f98cb59 100644 --- a/ceilometer/storage/sqlalchemy/models.py +++ b/ceilometer/storage/sqlalchemy/models.py @@ -237,7 +237,7 @@ class AlarmChange(Base): project_id = Column(String(255), ForeignKey('project.id')) user_id = Column(String(255), ForeignKey('user.id')) type = Column(String(20)) - detail = Column(String(255)) + detail = Column(Text) timestamp = Column(DateTime, default=timeutils.utcnow)