cubicweb/misc/migration/3.22.3_Any.py
author Laurent Peuch <cortex@worlddomination.be>
Tue, 17 Dec 2019 16:56:23 +0100
changeset 12820 da416fb21657
parent 11291 7c565548fb09
permissions -rw-r--r--
[test/fix] prevent FirefoxHelper from silently failing to start This was breaking some tests without any obvious error message and you should fail as early as possible to make debugging easier. Closes #17260390

from yams.constraints import UniqueConstraint

for rschema in schema.relations():
    if rschema.rule or not rschema.final:
        continue
    for rdef in rschema.rdefs.values():
        if (rdef.object != 'String'
                and any(isinstance(cstr, UniqueConstraint) for cstr in rdef.constraints)):
            table = 'cw_{0}'.format(rdef.subject)
            column = 'cw_{0}'.format(rdef.rtype)
            repo.system_source.create_index(cnx, table, column, unique=True)