Commit 7e4d786a authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[schema] add a unique index on cwuri

Closes #4985752
parent 480187dd66b3
......@@ -425,7 +425,7 @@ class Entity(AppObject):
else:
for rschema in cls.e_schema.subject_relations():
if (rschema.final
and rschema != 'eid'
and rschema not in ('eid', 'cwuri')
and cls.e_schema.has_unique_values(rschema)
and cls.e_schema.rdef(rschema.type).cardinality[0] == '1'):
mainattr = str(rschema)
......
......@@ -19,3 +19,5 @@ sql('DELETE FROM entities WHERE eid < 0')
commit()
sync_schema_props_perms('CWEType')
sync_schema_props_perms('cwuri')
......@@ -23,7 +23,7 @@ _ = unicode
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
SubjectRelation,
String, TZDatetime, Datetime, Password, Interval,
Boolean)
Boolean, UniqueConstraint)
from cubicweb.schema import (
RQLConstraint, WorkflowableEntityType, ERQLExpression, RRQLExpression,
PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, PUB_SYSTEM_ATTR_PERMS)
......@@ -164,6 +164,7 @@ class cwuri(RelationType):
cardinality = '11'
subject = '*'
object = 'String'
constraints = [UniqueConstraint()]
# XXX find a better relation name
......@@ -183,7 +184,6 @@ class for_user(RelationType):
cardinality = '?*'
class ExternalUri(EntityType):
"""a URI representing an object in external data store"""
uri = String(required=True, unique=True, maxsize=256,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment