Merge "Add foreign key constraints for Component fields"
This commit is contained in:
commit
68220cfcae
@ -34,8 +34,8 @@ class Component(sql.Base, abstract.Component):
|
||||
name = sa.Column(sa.String(100))
|
||||
description = sa.Column(sa.String(255))
|
||||
tags = sa.Column(sa.Text)
|
||||
assembly_id = sa.Column(sa.Integer)
|
||||
parent_component_id = sa.Column(sa.Integer)
|
||||
assembly_id = sa.Column(sa.Integer, sa.ForeignKey('assembly.id'))
|
||||
parent_component_id = sa.Column(sa.Integer, sa.ForeignKey('component.id'))
|
||||
resource_uri = sa.Column(sa.String(1024))
|
||||
|
||||
@property
|
||||
|
@ -0,0 +1,38 @@
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""update component foreign keys
|
||||
|
||||
Revision ID: 18b94e085cf9
|
||||
Revises: 12d90235e174
|
||||
Create Date: 2014-03-10 18:04:58.733470
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '18b94e085cf9'
|
||||
down_revision = '12d90235e174'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_foreign_key('fk_component_assembly', 'component',
|
||||
'assembly', ['assembly_id'], ['id'])
|
||||
op.create_foreign_key('fk_parent_component', 'component',
|
||||
'component', ['parent_component_id'], ['id'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_constraint('fk_component_assembly', 'component',
|
||||
type_='foreignkey')
|
||||
op.drop_constraint('fk_parent_component', 'component', type_='foreignkey')
|
@ -29,6 +29,8 @@ class TestComponent(base.BaseTestCase):
|
||||
'uuid': 'ce43e347f0b0422825245b3e5f140a81cef6e65b',
|
||||
'name': 'component1',
|
||||
'description': 'test component',
|
||||
'assembly_id': '42d42d',
|
||||
'parent_component_id': '87d98s',
|
||||
'tags': 'component tags'}]
|
||||
utils.create_models_from_data(component.Component, self.data, self.ctx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user