Alembic migrations for all SQL script revisions
This commit adds * An alembic environment for running database migrations * Alembic database migrations for all revisions of the legacy SQL script currently being used to set up the Monasca database. * The get_all_metadata() function for exposing full data model metadata. This function is needed generating migrations from the current state of the model and should be kept up to date as the model is being extended. Change-Id: I41b4577d8334791f712177348cadfe9b07b62ef1 Story: 2001654 Task: 14339
This commit is contained in:
parent
2e078cdd87
commit
39d5bbbb0a
|
@ -1,6 +1,7 @@
|
|||
# Copyright 2015 Robin Hood
|
||||
# Copyright 2016 FUJITSU LIMITED
|
||||
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
||||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -23,9 +24,35 @@ from sqlalchemy import Column
|
|||
from sqlalchemy.ext import compiler
|
||||
from sqlalchemy.sql import expression
|
||||
from sqlalchemy import String, DateTime, Boolean, Integer, Binary, Float
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import Table
|
||||
|
||||
|
||||
def get_all_metadata():
|
||||
"""Return metadata for full data model
|
||||
|
||||
This metadata is used for autogenerating a complete (works on an empty
|
||||
database) schema migration. To ensure this mechanism keeps working please
|
||||
invoke any new model creation methods you add from this function as well.
|
||||
|
||||
"""
|
||||
metadata = MetaData()
|
||||
create_a_model(metadata)
|
||||
create_aa_model(metadata)
|
||||
create_ad_model(metadata)
|
||||
create_am_model(metadata)
|
||||
create_nm_model(metadata)
|
||||
create_md_model(metadata)
|
||||
create_mde_model(metadata)
|
||||
create_mdd_model(metadata)
|
||||
create_sa_model(metadata)
|
||||
create_sad_model(metadata)
|
||||
create_sadd_model(metadata)
|
||||
create_nmt_model(metadata)
|
||||
|
||||
return metadata
|
||||
|
||||
|
||||
def create_a_model(metadata=None):
|
||||
return Table('alarm', metadata,
|
||||
Column('id', String(36)),
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
This directory contains the plumbing for the Alembic migrations that modify the
|
||||
Monasca database.
|
||||
|
||||
If you need to add a new migration, run
|
||||
|
||||
alembic revision -m '<revision message>'
|
||||
|
||||
in this directory, where <revision message> is a short description for what
|
||||
your migration does such as 'Add volume field to alarm'. Alembic will then
|
||||
create a revision script in the alembic/versions/ directory. You will need to
|
||||
edit this script to add upwards and downwards migrations for the change you
|
||||
want to make.
|
|
@ -0,0 +1,74 @@
|
|||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# path to migration scripts
|
||||
script_location = %(here)s/alembic
|
||||
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# timezone to use when rendering the date
|
||||
# within the migration file as well as the filename.
|
||||
# string value is passed to dateutil.tz.gettz()
|
||||
# leave blank for localtime
|
||||
# timezone =
|
||||
|
||||
# max length of characters to apply to the
|
||||
# "slug" field
|
||||
#truncate_slug_length = 40
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
# set to 'true' to allow .pyc and .pyo files without
|
||||
# a source .py file to be detected as revisions in the
|
||||
# versions/ directory
|
||||
# sourceless = false
|
||||
|
||||
# version location specification; this defaults
|
||||
# to alembic/versions. When using multiple version
|
||||
# directories, initial revisions must be specified with --version-path
|
||||
# version_locations = %(here)s/bar %(here)s/bat alembic/versions
|
||||
|
||||
# the output encoding used when revision files
|
||||
# are written from script.py.mako
|
||||
# output_encoding = utf-8
|
||||
|
||||
# sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
|
@ -0,0 +1,89 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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 __future__ import with_statement
|
||||
|
||||
import monasca_api.config
|
||||
import os
|
||||
|
||||
from alembic import config as alembic_config
|
||||
from alembic import context
|
||||
from logging.config import fileConfig
|
||||
|
||||
from monasca_api.common.repositories.sqla import models
|
||||
from monasca_api.common.repositories.sqla import sql_repository
|
||||
|
||||
ini_file_path = os.path.join(os.path.dirname(__file__), '..', 'alembic.ini')
|
||||
|
||||
# This indicates whether we are running with a viable Alembic
|
||||
# context (necessary to do skip run_migrations_online() below
|
||||
# if sphinx imports this file without a viable Alembic
|
||||
# context)
|
||||
have_context = True
|
||||
|
||||
try:
|
||||
config = context.config
|
||||
# FIXME: Move this to the monasca_db entry point later.
|
||||
# Load monasca-api config (from files only)
|
||||
monasca_api.config.parse_args(argv=[])
|
||||
except AttributeError:
|
||||
config = alembic_config.Config(ini_file_path)
|
||||
have_context = False
|
||||
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# Model metadata. This is needed for 'autogenerate' support. If you add new
|
||||
# tables, you will need to add them to the get_all_metadata() method as well.
|
||||
target_metadata = models.get_all_metadata()
|
||||
|
||||
nc = {"ix": "ix_%(column_0_label)s",
|
||||
"uq": "uq_%(table_name)s_%(column_0_name)s",
|
||||
"fk": "fk_%(table_name)s_%(column_0_name)s",
|
||||
"pk": "pk_%(table_name)s"}
|
||||
|
||||
target_metadata.naming_convention = nc
|
||||
|
||||
|
||||
def run_migrations_online():
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
engine = sql_repository.get_engine()
|
||||
|
||||
with engine.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def fingerprint_db():
|
||||
return
|
||||
|
||||
|
||||
def stamp_db():
|
||||
return
|
||||
|
||||
|
||||
if have_context:
|
||||
run_migrations_online()
|
|
@ -0,0 +1,24 @@
|
|||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
|
@ -0,0 +1,590 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Initial migration for full schema (Git revision 00597b5c8325664c2c534625525f59232d243d66).
|
||||
|
||||
Revision ID: 00597b5c8325
|
||||
Revises: N/A
|
||||
Create Date: 2018-04-12 09:09:48.212206
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '00597b5c8325'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# Enum tables (will be prepopulated with values through bulk_insert)
|
||||
|
||||
alarm_states = op.create_table('alarm_state',
|
||||
sa.Column('name',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('name'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci'
|
||||
)
|
||||
|
||||
op.bulk_insert(alarm_states,
|
||||
[{'name': 'UNDETERMINED'},
|
||||
{'name': 'OK'},
|
||||
{'name': 'ALARM'}])
|
||||
|
||||
ad_severities = op.create_table(
|
||||
'alarm_definition_severity',
|
||||
sa.Column('name',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('name'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.bulk_insert(ad_severities,
|
||||
[{'name': 'LOW'},
|
||||
{'name': 'MEDIUM'},
|
||||
{'name': 'HIGH'},
|
||||
{'name': 'CRITICAL'}])
|
||||
|
||||
nm_types = op.create_table(
|
||||
'notification_method_type',
|
||||
sa.Column('name',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('name'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.bulk_insert(nm_types,
|
||||
[{'name': 'EMAIL'},
|
||||
{'name': 'WEBHOOK'},
|
||||
{'name': 'PAGERDUTY'}])
|
||||
|
||||
stream_action_types = op.create_table(
|
||||
'stream_actions_action_type',
|
||||
sa.Column('name',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('name'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.bulk_insert(stream_action_types,
|
||||
[{'name': 'FIRE'},
|
||||
{'name': 'EXPIRE'}])
|
||||
|
||||
op.create_table(
|
||||
'alarm_definition',
|
||||
sa.Column('id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('name',
|
||||
sa.String(length=255),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('description',
|
||||
sa.String(length=255),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('expression',
|
||||
sa.dialects.mysql.LONGTEXT(),
|
||||
nullable=False),
|
||||
sa.Column('severity',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.Column('match_by',
|
||||
sa.String(length=255),
|
||||
nullable=True,
|
||||
server_default=''),
|
||||
sa.Column('actions_enabled',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='1'),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('deleted_at',
|
||||
sa.DateTime(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.Index('tenant_id', 'tenant_id'),
|
||||
sa.Index('deleted_at', 'deleted_at'),
|
||||
sa.Index('fk_alarm_definition_severity', 'severity'),
|
||||
sa.ForeignKeyConstraint(['severity'],
|
||||
['alarm_definition_severity.name']),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'alarm',
|
||||
sa.Column('id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('alarm_definition_id',
|
||||
sa.String(length=36),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('state',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.Column('lifecycle_state',
|
||||
sa.String(length=50, collation=False),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('link',
|
||||
sa.String(length=512, collation=False),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('state_updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=True),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.Index('alarm_definition_id', 'alarm_definition_id'),
|
||||
sa.Index('fk_alarm_alarm_state', 'state'),
|
||||
sa.ForeignKeyConstraint(['alarm_definition_id'],
|
||||
['alarm_definition.id'],
|
||||
name='fk_alarm_definition_id',
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['state'],
|
||||
['alarm_state.name'],
|
||||
name='fk_alarm_alarm_state'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'notification_method',
|
||||
sa.Column('id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('name',
|
||||
sa.String(length=250),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('type',
|
||||
sa.String(length=20),
|
||||
# Note: the typo below is deliberate since we need to match
|
||||
# the constraint name from the SQL script where it is
|
||||
# misspelled as well.
|
||||
sa.ForeignKey('notification_method_type.name',
|
||||
name='fk_alarm_noticication_method_type'),
|
||||
nullable=False),
|
||||
sa.Column('address',
|
||||
sa.String(length=512),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'alarm_action',
|
||||
sa.Column('alarm_definition_id',
|
||||
sa.String(length=36),
|
||||
nullable=False,),
|
||||
sa.Column('alarm_state',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.Column('action_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('alarm_definition_id', 'alarm_state',
|
||||
'action_id'),
|
||||
sa.ForeignKeyConstraint(['action_id'],
|
||||
['notification_method.id'],
|
||||
name='fk_alarm_action_notification_method_id',
|
||||
ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['alarm_state'],
|
||||
['alarm_state.name']),
|
||||
sa.ForeignKeyConstraint(['alarm_definition_id'],
|
||||
['alarm_definition.id'],
|
||||
ondelete='CASCADE'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'alarm_metric',
|
||||
sa.Column('alarm_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('metric_definition_dimensions_id',
|
||||
sa.BINARY(20),
|
||||
nullable=False,
|
||||
server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
|
||||
sa.PrimaryKeyConstraint('alarm_id', 'metric_definition_dimensions_id'),
|
||||
sa.Index('alarm_id', 'alarm_id'),
|
||||
sa.Index('metric_definition_dimensions_id', 'metric_definition_dimensions_id'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
# For some mysterious alembic/sqlalchemy reason this foreign key constraint
|
||||
# ends up missing when specified upon table creation. Hence we need to add
|
||||
# it through an ALTER TABLE operation:
|
||||
op.create_foreign_key('fk_alarm_id',
|
||||
'alarm_metric',
|
||||
'alarm',
|
||||
['alarm_id'],
|
||||
['id'], ondelete='CASCADE')
|
||||
|
||||
op.create_table(
|
||||
'metric_definition',
|
||||
sa.Column('id',
|
||||
sa.BINARY(20),
|
||||
nullable=False,
|
||||
server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
|
||||
sa.Column('name',
|
||||
sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('region',
|
||||
sa.String(length=255),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'metric_definition_dimensions',
|
||||
sa.Column('id',
|
||||
sa.BINARY(20),
|
||||
nullable=False,
|
||||
server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
|
||||
sa.Column('metric_definition_id',
|
||||
sa.BINARY(20),
|
||||
nullable=False,
|
||||
server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
|
||||
sa.Column('metric_dimension_set_id',
|
||||
sa.BINARY(20),
|
||||
nullable=False,
|
||||
server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.Index('metric_definition_id', 'metric_definition_id'),
|
||||
sa.Index('metric_dimension_set_id', 'metric_dimension_set_id'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
# mysql limits the size of a unique key to 767 bytes. The utf8mb4 charset
|
||||
# requires 4 bytes to be allocated for each character while the utf8
|
||||
# charset requires 3 bytes. The utf8 charset should be sufficient for any
|
||||
# reasonable characters, see the definition of supplementary characters for
|
||||
# what it doesn't support. Even with utf8, the unique key length would be
|
||||
# 785 bytes so only a subset of the name is used. Potentially the size of
|
||||
# the name should be limited to 250 characters which would resolve this
|
||||
# issue.
|
||||
#
|
||||
# The unique key is required to allow high performance inserts without
|
||||
# doing a select by using the "insert into metric_dimension ... on
|
||||
# duplicate key update dimension_set_id=dimension_set_id syntax
|
||||
|
||||
op.create_table(
|
||||
'metric_dimension',
|
||||
sa.Column('dimension_set_id',
|
||||
sa.BINARY(20),
|
||||
nullable=False,
|
||||
server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
|
||||
sa.Column('name',
|
||||
sa.String(length=255),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('value',
|
||||
sa.String(length=255),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Index('metric_dimension_key',
|
||||
'dimension_set_id', 'name',
|
||||
unique=True,
|
||||
mysql_length={'name': 252}),
|
||||
sa.Index('dimension_set_id', 'dimension_set_id'),
|
||||
mysql_charset='utf8',
|
||||
mysql_collate='utf8_unicode_ci',
|
||||
mysql_comment='PRIMARY KEY (`id`)')
|
||||
|
||||
op.create_table(
|
||||
'sub_alarm_definition',
|
||||
sa.Column('id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('alarm_definition_id',
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey('alarm_definition.id', ondelete='CASCADE',
|
||||
name='fk_sub_alarm_definition'),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('function',
|
||||
sa.String(length=10),
|
||||
nullable=False),
|
||||
sa.Column('metric_name',
|
||||
sa.String(length=100),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('operator',
|
||||
sa.String(length=5),
|
||||
nullable=False),
|
||||
sa.Column('threshold',
|
||||
sa.dialects.mysql.DOUBLE(),
|
||||
nullable=False),
|
||||
sa.Column('period',
|
||||
sa.Integer(),
|
||||
nullable=False),
|
||||
sa.Column('periods',
|
||||
sa.Integer(),
|
||||
nullable=False),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'sub_alarm_definition_dimension',
|
||||
sa.Column('sub_alarm_definition_id',
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey('sub_alarm_definition.id', ondelete='CASCADE',
|
||||
name='fk_sub_alarm_definition_dimension'),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('dimension_name',
|
||||
sa.String(length=255),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('value',
|
||||
sa.String(length=255),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'sub_alarm',
|
||||
sa.Column('id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('alarm_id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
sa.ForeignKey('alarm.id', ondelete='CASCADE',
|
||||
name='fk_sub_alarm'),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('sub_expression_id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
sa.ForeignKey('sub_alarm_definition.id',
|
||||
name='fk_sub_alarm_expr'),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('expression',
|
||||
sa.dialects.mysql.LONGTEXT(charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='latin1')
|
||||
|
||||
op.create_table(
|
||||
'schema_migrations',
|
||||
sa.Column('version',
|
||||
sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.UniqueConstraint('version', name='unique_schema_migrations'),
|
||||
mysql_charset='latin1')
|
||||
|
||||
op.create_table(
|
||||
'stream_definition',
|
||||
sa.Column('id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('name',
|
||||
sa.String(length=190),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('description',
|
||||
sa.String(length=255),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('select_by',
|
||||
sa.dialects.mysql.LONGTEXT(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('group_by',
|
||||
sa.dialects.mysql.LONGTEXT(length=20),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('fire_criteria',
|
||||
sa.dialects.mysql.LONGTEXT(length=20),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('expiration',
|
||||
sa.dialects.mysql.INTEGER(display_width=10,
|
||||
unsigned=True),
|
||||
nullable=True,
|
||||
server_default='0'),
|
||||
sa.Column('actions_enabled',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='1'),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('deleted_at',
|
||||
sa.DateTime(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('tenant_id', 'name', name='tenant_name'),
|
||||
sa.Index('name', 'name'),
|
||||
sa.Index('tenant_id', 'tenant_id'),
|
||||
sa.Index('deleted_at', 'deleted_at'),
|
||||
sa.Index('created_at', 'created_at'),
|
||||
sa.Index('updated_at', 'updated_at'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'stream_actions',
|
||||
sa.Column('stream_definition_id',
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey
|
||||
('stream_definition.id',
|
||||
name='fk_stream_action_stream_definition_id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False),
|
||||
sa.Column('action_id',
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey('notification_method.id',
|
||||
name='fk_stream_action_notification_method_id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False),
|
||||
sa.Column('action_type',
|
||||
sa.String(length=20),
|
||||
sa.ForeignKey('stream_actions_action_type.name'),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('stream_definition_id', 'action_id',
|
||||
'action_type'),
|
||||
sa.Index('stream_definition_id', 'stream_definition_id'),
|
||||
sa.Index('action_type', 'action_type'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'event_transform',
|
||||
sa.Column('id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('name',
|
||||
sa.dialects.mysql.VARCHAR(length=64, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('description',
|
||||
sa.dialects.mysql.VARCHAR(length=250, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('specification',
|
||||
sa.dialects.mysql.LONGTEXT(charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('enabled',
|
||||
sa.Boolean(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('deleted_at',
|
||||
sa.DateTime(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.Index('name', 'name'),
|
||||
sa.Index('tenant_id', 'tenant_id'),
|
||||
sa.Index('deleted_at', 'deleted_at'),
|
||||
sa.Index('created_at', 'created_at'),
|
||||
sa.Index('updated_at', 'updated_at'),
|
||||
sa.UniqueConstraint('tenant_id', 'name', name='tenant_name'),
|
||||
mysql_charset='utf8mb4')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('alarm_state')
|
||||
op.drop_table('alarm_definition_severity')
|
||||
op.drop_table('notification_method_type')
|
||||
op.drop_table('stream_actions_action_type')
|
||||
op.drop_table('alarm_definition')
|
||||
op.drop_table('alarm')
|
||||
op.drop_table('notification_method')
|
||||
op.drop_table('alarm_action')
|
||||
op.drop_table('alarm_metric')
|
||||
op.drop_table('metric_definition')
|
||||
op.drop_table('metric_definition_dimensions')
|
||||
op.drop_table('metric_dimension')
|
||||
op.drop_table('sub_alarm_definition')
|
||||
op.drop_table('sub_alarm_definition_dimension')
|
||||
op.drop_table('sub_alarm')
|
||||
op.drop_table('schema_migrations')
|
||||
op.drop_table('stream_definition')
|
||||
op.drop_table('stream_actions')
|
||||
op.drop_table('event_transform')
|
|
@ -0,0 +1,42 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
""" Add flag for deterministic alarms (Git revision 0cce983d957a3d780b6d206ad25df1271a812b4a).
|
||||
|
||||
Revision ID: 0cce983d957a
|
||||
Revises: 00597b5c8325
|
||||
Create Date: 2018-04-23 13:57:32.951669
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0cce983d957a'
|
||||
down_revision = '00597b5c8325'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('sub_alarm_definition',
|
||||
sa.Column('is_deterministic',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='0'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('sub_alarm_definition', 'is_deterministic')
|
|
@ -0,0 +1,176 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Remove event related tables and schema_migrations table (git revision
|
||||
30181b42434bdde0c40abd086e903600b24e9684)
|
||||
|
||||
Revision ID: 30181b42434b
|
||||
Revises: c2f85438d6f3
|
||||
Create Date: 2018-04-24 09:54:50.024470
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '30181b42434b'
|
||||
down_revision = 'c2f85438d6f3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_table('event_transform')
|
||||
op.drop_table('schema_migrations')
|
||||
op.drop_table('stream_actions')
|
||||
op.drop_table('stream_definition')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.create_table(
|
||||
'event_transform',
|
||||
sa.Column('id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('name',
|
||||
sa.dialects.mysql.VARCHAR(length=64, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('description',
|
||||
sa.dialects.mysql.VARCHAR(length=250, charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('specification',
|
||||
sa.dialects.mysql.LONGTEXT(charset='utf8mb4',
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
nullable=False),
|
||||
sa.Column('enabled',
|
||||
sa.Boolean(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('deleted_at',
|
||||
sa.DateTime(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.Index('name', 'name'),
|
||||
sa.Index('tenant_id', 'tenant_id'),
|
||||
sa.Index('deleted_at', 'deleted_at'),
|
||||
sa.Index('created_at', 'created_at'),
|
||||
sa.Index('updated_at', 'updated_at'),
|
||||
sa.UniqueConstraint('tenant_id', 'name', name='tenant_name'),
|
||||
mysql_charset='utf8mb4')
|
||||
|
||||
op.create_table(
|
||||
'schema_migrations',
|
||||
sa.Column('version',
|
||||
sa.String(length=255),
|
||||
nullable=False),
|
||||
sa.UniqueConstraint('version', name='unique_schema_migrations'),
|
||||
mysql_charset='latin1')
|
||||
|
||||
op.create_table(
|
||||
'stream_actions',
|
||||
sa.Column('stream_definition_id',
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey
|
||||
('stream_definition.id',
|
||||
name='fk_stream_action_stream_definition_id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False),
|
||||
sa.Column('action_id',
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey('notification_method.id',
|
||||
name='fk_stream_action_notification_method_id',
|
||||
ondelete='CASCADE'),
|
||||
nullable=False),
|
||||
sa.Column('action_type',
|
||||
sa.String(length=20),
|
||||
sa.ForeignKey('stream_actions_action_type.name'),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('stream_definition_id', 'action_id',
|
||||
'action_type'),
|
||||
sa.Index('stream_definition_id', 'stream_definition_id'),
|
||||
sa.Index('action_type', 'action_type'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'stream_definition',
|
||||
sa.Column('id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('tenant_id',
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('name',
|
||||
sa.String(length=190),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('description',
|
||||
sa.String(length=255),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('select_by',
|
||||
sa.dialects.mysql.LONGTEXT(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('group_by',
|
||||
sa.dialects.mysql.LONGTEXT(length=20),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('fire_criteria',
|
||||
sa.dialects.mysql.LONGTEXT(length=20),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.Column('expiration',
|
||||
sa.dialects.mysql.INTEGER(display_width=10,
|
||||
unsigned=True),
|
||||
nullable=True,
|
||||
server_default='0'),
|
||||
sa.Column('actions_enabled',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='1'),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.Column('deleted_at',
|
||||
sa.DateTime(),
|
||||
nullable=True,
|
||||
server_default=None),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('tenant_id', 'name', name='tenant_name'),
|
||||
sa.Index('name', 'name'),
|
||||
sa.Index('tenant_id', 'tenant_id'),
|
||||
sa.Index('deleted_at', 'deleted_at'),
|
||||
sa.Index('created_at', 'created_at'),
|
||||
sa.Index('updated_at', 'updated_at'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
|
@ -0,0 +1,45 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Add sub alarm state (Git revision 6b2b88f3cab46cd442369b22da3624611b871169)
|
||||
|
||||
Revision ID: 6b2b88f3cab4
|
||||
Revises: 30181b42434b
|
||||
Create Date: 2018-04-24 12:16:15.812274
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6b2b88f3cab4'
|
||||
down_revision = '30181b42434b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column(
|
||||
'sub_alarm',
|
||||
sa.Column('state',
|
||||
sa.dialects.mysql.VARCHAR(length=20,
|
||||
collate='utf8mb4_unicode_ci'),
|
||||
sa.ForeignKey('alarm_state.name'),
|
||||
nullable=False,
|
||||
server_default='OK'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('sub_alarm', 'state')
|
|
@ -0,0 +1,48 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Add inhibited and silenced to alarms (Git revision 8781a256f0c19662b81f04b014e2b769e625bd6b)
|
||||
|
||||
Revision ID: 8781a256f0c1
|
||||
Revises: d8b801498850
|
||||
Create Date: 2018-04-24 13:16:04.157977
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '8781a256f0c1'
|
||||
down_revision = 'd8b801498850'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('alarm',
|
||||
sa.Column('inhibited',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='0'))
|
||||
op.add_column('alarm',
|
||||
sa.Column('silenced',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='0'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('alarm', 'inhibited')
|
||||
op.drop_column('alarm', 'silenced')
|
|
@ -0,0 +1,42 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Add period to notifications (Git revision c2f85438d6f3b0fd2e1f86d84eee6e9967025eb6)
|
||||
|
||||
Revision ID: c2f85438d6f3
|
||||
Revises: 0cce983d957a
|
||||
Create Date: 2018-04-23 14:47:49.413502
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c2f85438d6f3'
|
||||
down_revision = '0cce983d957a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('notification_method',
|
||||
sa.Column('period',
|
||||
sa.Integer(),
|
||||
nullable=False,
|
||||
server_default='0'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('notification_method', 'period')
|
|
@ -0,0 +1,49 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Remove stream action types (Git revision d8b80149885016ede0ee403cf9bb07f9b7253297)
|
||||
|
||||
Revision ID: d8b801498850
|
||||
Revises: 6b2b88f3cab4
|
||||
Create Date: 2018-04-24 12:53:02.342849
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd8b801498850'
|
||||
down_revision = '6b2b88f3cab4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_table('stream_actions_action_type')
|
||||
|
||||
|
||||
def downgrade():
|
||||
stream_action_types = op.create_table(
|
||||
'stream_actions_action_type',
|
||||
sa.Column('name',
|
||||
sa.String(length=20),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('name'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.bulk_insert(stream_action_types,
|
||||
[{'name': 'FIRE'},
|
||||
{'name': 'EXPIRE'}])
|
|
@ -0,0 +1,48 @@
|
|||
# Copyright 2018 SUSE Linux GmbH
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Remove inhibited and silenced from alarms (Git revision f69cb3152a76e7c586dcc9a03600d1d4ed32c4e6)
|
||||
|
||||
Revision ID: f69cb3152a76
|
||||
Revises: 8781a256f0c1
|
||||
Create Date: 2018-04-24 13:16:04.157977
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f69cb3152a76'
|
||||
down_revision = '8781a256f0c1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_column('alarm', 'inhibited')
|
||||
op.drop_column('alarm', 'silenced')
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.add_column('alarm',
|
||||
sa.Column('inhibited',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='0'))
|
||||
op.add_column('alarm',
|
||||
sa.Column('silenced',
|
||||
sa.Boolean(),
|
||||
nullable=False,
|
||||
server_default='0'))
|
Loading…
Reference in New Issue