Browse Source

Merge "Define orm relationships after db classes" into stable/queens

changes/91/708491/1
Zuul 4 months ago
committed by Gerrit Code Review
parent
commit
af1aed1478
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      neutron/db/models/flavor.py

+ 7
- 5
neutron/db/models/flavor.py View File

@@ -23,8 +23,6 @@ class Flavor(model_base.BASEV2, model_base.HasId):
server_default=sa.sql.true())
# Make it True for multi-type flavors
service_type = sa.Column(sa.String(36), nullable=True)
service_profiles = orm.relationship("FlavorServiceProfileBinding",
cascade="all, delete-orphan", lazy="subquery")


class ServiceProfile(model_base.BASEV2, model_base.HasId):
@@ -33,7 +31,6 @@ class ServiceProfile(model_base.BASEV2, model_base.HasId):
enabled = sa.Column(sa.Boolean, nullable=False, default=True,
server_default=sa.sql.true())
metainfo = sa.Column(sa.String(4096))
flavors = orm.relationship("FlavorServiceProfileBinding")


class FlavorServiceProfileBinding(model_base.BASEV2):
@@ -41,9 +38,14 @@ class FlavorServiceProfileBinding(model_base.BASEV2):
sa.ForeignKey("flavors.id",
ondelete="CASCADE"),
nullable=False, primary_key=True)
flavor = orm.relationship(Flavor)
flavor = orm.relationship(Flavor,
backref=orm.backref(
"service_profiles",
lazy='subquery',
cascade="all, delete-orphan"))
service_profile_id = sa.Column(sa.String(36),
sa.ForeignKey("serviceprofiles.id",
ondelete="CASCADE"),
nullable=False, primary_key=True)
service_profile = orm.relationship(ServiceProfile)
service_profile = orm.relationship(ServiceProfile,
backref="flavors")

Loading…
Cancel
Save