Use `TextClause
` to define the DB model "server_default"
The alembic comparator needs the same class to compare the database model with the loaded SQL schema. Closes-Bug: #2020050 Change-Id: I4feab3e55f2e38a9eca70d4ca755b4c2974346d5
This commit is contained in:
parent
43c756d728
commit
6fa3d8019f
@ -14,6 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
|
from sqlalchemy.sql import elements
|
||||||
|
|
||||||
# NOTE(boden): This module is common constants for neutron only.
|
# NOTE(boden): This module is common constants for neutron only.
|
||||||
# Any constants used outside of neutron should go into neutron-lib.
|
# Any constants used outside of neutron should go into neutron-lib.
|
||||||
@ -92,3 +93,6 @@ METADATA_V6_CIDR = constants.METADATA_V6_IP + '/128'
|
|||||||
|
|
||||||
# TODO(haleyb): move this constant to neutron_lib.constants
|
# TODO(haleyb): move this constant to neutron_lib.constants
|
||||||
IPV4_MIN_MTU = 68
|
IPV4_MIN_MTU = 68
|
||||||
|
|
||||||
|
# TODO(ralonsoh): move to neutron-lib.db.contants
|
||||||
|
SQL_EMPTY_STRING = elements.TextClause("''")
|
||||||
|
@ -16,6 +16,7 @@ import sqlalchemy as sa
|
|||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
from sqlalchemy import sql
|
from sqlalchemy import sql
|
||||||
|
|
||||||
|
from neutron.common import _constants as n_const
|
||||||
from neutron.db.models import l3 as l3_models
|
from neutron.db.models import l3 as l3_models
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ class PortDNS(model_base.BASEV2):
|
|||||||
dns_name = sa.Column(sa.String(255), nullable=False)
|
dns_name = sa.Column(sa.String(255), nullable=False)
|
||||||
dns_domain = sa.Column(sa.String(constants.FQDN_FIELD_SIZE),
|
dns_domain = sa.Column(sa.String(constants.FQDN_FIELD_SIZE),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
server_default='')
|
server_default=n_const.SQL_EMPTY_STRING)
|
||||||
# Add a relationship to the Port model in order to instruct
|
# Add a relationship to the Port model in order to instruct
|
||||||
# SQLAlchemy to eagerly load this association
|
# SQLAlchemy to eagerly load this association
|
||||||
port = orm.relationship(models_v2.Port,
|
port = orm.relationship(models_v2.Port,
|
||||||
|
@ -25,6 +25,7 @@ import sqlalchemy as sa
|
|||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
from sqlalchemy import sql
|
from sqlalchemy import sql
|
||||||
|
|
||||||
|
from neutron.common import _constants as n_const
|
||||||
from neutron.db.network_dhcp_agent_binding import models as ndab_model
|
from neutron.db.network_dhcp_agent_binding import models as ndab_model
|
||||||
from neutron.db import rbac_db_models
|
from neutron.db import rbac_db_models
|
||||||
|
|
||||||
@ -296,7 +297,8 @@ class SubnetPool(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
|||||||
is_default = sa.Column(sa.Boolean, nullable=False,
|
is_default = sa.Column(sa.Boolean, nullable=False,
|
||||||
server_default=sql.false())
|
server_default=sql.false())
|
||||||
default_quota = sa.Column(sa.Integer, nullable=True)
|
default_quota = sa.Column(sa.Integer, nullable=True)
|
||||||
hash = sa.Column(sa.String(36), nullable=False, server_default='')
|
hash = sa.Column(sa.String(36), nullable=False,
|
||||||
|
server_default=n_const.SQL_EMPTY_STRING)
|
||||||
address_scope_id = sa.Column(sa.String(36), nullable=True, index=True)
|
address_scope_id = sa.Column(sa.String(36), nullable=True, index=True)
|
||||||
prefixes = orm.relationship(SubnetPoolPrefix,
|
prefixes = orm.relationship(SubnetPoolPrefix,
|
||||||
backref='subnetpools',
|
backref='subnetpools',
|
||||||
|
@ -19,6 +19,7 @@ from neutron_lib.db import model_base
|
|||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
||||||
|
from neutron.common import _constants as n_const
|
||||||
from neutron.db.models import segment as segment_models
|
from neutron.db.models import segment as segment_models
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
|
|
||||||
@ -45,10 +46,10 @@ class PortBinding(model_base.BASEV2):
|
|||||||
default=portbindings.VNIC_NORMAL,
|
default=portbindings.VNIC_NORMAL,
|
||||||
server_default=portbindings.VNIC_NORMAL)
|
server_default=portbindings.VNIC_NORMAL)
|
||||||
profile = sa.Column(sa.String(BINDING_PROFILE_LEN), nullable=False,
|
profile = sa.Column(sa.String(BINDING_PROFILE_LEN), nullable=False,
|
||||||
default='', server_default='')
|
default='', server_default=n_const.SQL_EMPTY_STRING)
|
||||||
vif_type = sa.Column(sa.String(64), nullable=False)
|
vif_type = sa.Column(sa.String(64), nullable=False)
|
||||||
vif_details = sa.Column(sa.String(4095), nullable=False, default='',
|
vif_details = sa.Column(sa.String(4095), nullable=False, default='',
|
||||||
server_default='')
|
server_default=n_const.SQL_EMPTY_STRING)
|
||||||
status = sa.Column(sa.String(16), nullable=False,
|
status = sa.Column(sa.String(16), nullable=False,
|
||||||
default=constants.ACTIVE,
|
default=constants.ACTIVE,
|
||||||
server_default=constants.ACTIVE)
|
server_default=constants.ACTIVE)
|
||||||
@ -115,12 +116,12 @@ class DistributedPortBinding(model_base.BASEV2):
|
|||||||
router_id = sa.Column(sa.String(36), nullable=True)
|
router_id = sa.Column(sa.String(36), nullable=True)
|
||||||
vif_type = sa.Column(sa.String(64), nullable=False)
|
vif_type = sa.Column(sa.String(64), nullable=False)
|
||||||
vif_details = sa.Column(sa.String(4095), nullable=False, default='',
|
vif_details = sa.Column(sa.String(4095), nullable=False, default='',
|
||||||
server_default='')
|
server_default=n_const.SQL_EMPTY_STRING)
|
||||||
vnic_type = sa.Column(sa.String(64), nullable=False,
|
vnic_type = sa.Column(sa.String(64), nullable=False,
|
||||||
default=portbindings.VNIC_NORMAL,
|
default=portbindings.VNIC_NORMAL,
|
||||||
server_default=portbindings.VNIC_NORMAL)
|
server_default=portbindings.VNIC_NORMAL)
|
||||||
profile = sa.Column(sa.String(BINDING_PROFILE_LEN), nullable=False,
|
profile = sa.Column(sa.String(BINDING_PROFILE_LEN), nullable=False,
|
||||||
default='', server_default='')
|
default='', server_default=n_const.SQL_EMPTY_STRING)
|
||||||
status = sa.Column(sa.String(16), nullable=False)
|
status = sa.Column(sa.String(16), nullable=False)
|
||||||
|
|
||||||
# Add a relationship to the Port model in order to instruct SQLAlchemy to
|
# Add a relationship to the Port model in order to instruct SQLAlchemy to
|
||||||
|
Loading…
Reference in New Issue
Block a user