Make the db migration scripts complete
The current db migration scripts cannot reflect the db model we used. This patch adds migration scripts for service related db and some alterations on device and device attribute tables. Change-Id: I3a44c05280c4fa0b6bdb9737ec32200d641f2ac0 Closes-bug: 1518072
This commit is contained in:
parent
eeeb37ab2c
commit
543c1edd60
|
@ -0,0 +1,108 @@
|
|||
# Copyright 2015 OpenStack Foundation
|
||||
#
|
||||
# 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 Service related dbs
|
||||
|
||||
Revision ID: 12a57080b277
|
||||
Revises: 5958429bcb3c
|
||||
Create Date: 2015-11-26 15:18:19.623170
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '12a57080b277'
|
||||
down_revision = '5958429bcb3c'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table(
|
||||
'servicetypes',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('template_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('service_type', sa.String(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(['template_id'], ['devicetemplates.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_table(
|
||||
'deviceservicecontexts',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('device_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('network_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('subnet_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('port_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('role', sa.String(length=255), nullable=True),
|
||||
sa.Column('index', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['device_id'], ['devices.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_table(
|
||||
'serviceinstances',
|
||||
sa.Column('tenant_id', sa.String(length=255), nullable=True),
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('service_type_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('service_table_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('managed_by_user', sa.Boolean(), nullable=True),
|
||||
sa.Column('mgmt_driver', sa.String(length=255), nullable=True),
|
||||
sa.Column('mgmt_url', sa.String(length=255), nullable=True),
|
||||
sa.Column('status', sa.String(length=255), nullable=False),
|
||||
sa.ForeignKeyConstraint(['service_type_id'], ['servicetypes.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_table(
|
||||
'servicecontexts',
|
||||
sa.Column('id', sa.String(length=36), nullable=False),
|
||||
sa.Column('service_instance_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('network_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('subnet_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('port_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('router_id', sa.String(length=36), nullable=True),
|
||||
sa.Column('role', sa.String(length=255), nullable=True),
|
||||
sa.Column('index', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['service_instance_id'],
|
||||
['serviceinstances.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_table(
|
||||
'servicedevicebindings',
|
||||
sa.Column('service_instance_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('device_id', sa.String(length=36), nullable=False),
|
||||
sa.ForeignKeyConstraint(['device_id'], ['devices.id'], ),
|
||||
sa.ForeignKeyConstraint(['service_instance_id'],
|
||||
['serviceinstances.id'], ),
|
||||
sa.PrimaryKeyConstraint('service_instance_id', 'device_id'),
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('servicedevicebindings')
|
||||
op.drop_table('servicecontexts')
|
||||
op.drop_table('serviceinstances')
|
||||
op.drop_table('deviceservicecontexts')
|
||||
op.drop_table('servicetypes')
|
||||
### end Alembic commands ###
|
|
@ -0,0 +1,51 @@
|
|||
# Copyright 2015 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
""" Alter devices
|
||||
|
||||
Revision ID: 12a57080b278
|
||||
Revises: 12a57080b277
|
||||
Create Date: 2015-11-26 15:18:19.623170
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '12a57080b278'
|
||||
down_revision = '12a57080b277'
|
||||
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(u'deviceattributes', 'device_id',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
nullable=False)
|
||||
op.alter_column(u'devices', 'status',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade(active_plugins=None, options=None):
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column(u'devices', 'status',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
nullable=True)
|
||||
op.alter_column(u'deviceattributes', 'device_id',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
nullable=True)
|
||||
### end Alembic commands ###
|
|
@ -25,15 +25,6 @@ Create Date: 2014-08-01 11:48:10.319498
|
|||
revision = '4c31092895b8'
|
||||
down_revision = '81ffa86020d'
|
||||
|
||||
# from alembic import op
|
||||
|
||||
|
||||
def upgrade(active_plugins=None, options=None):
|
||||
# op.drop_column('devicetameplates', 'service_types')
|
||||
|
||||
# op.drop_table('servicetypes')
|
||||
# op.drop_table('deviceservicecontexts')
|
||||
# op.drop_table('serviceinstances')
|
||||
# op.drop_table('servicecontexts')
|
||||
# op.drop_table('servicedevicebindings')
|
||||
pass
|
||||
|
|
|
@ -1 +1 @@
|
|||
5958429bcb3c
|
||||
12a57080b278
|
Loading…
Reference in New Issue