def createEntitlements(db):
    cu = db.cursor()
    commit = False

    if "EntitlementGroups" not in db.tables:
        cu.execute("""
        CREATE TABLE EntitlementGroups (
            entGroupId      %(PRIMARYKEY)s,
            entGroup        VARCHAR(254) NOT NULL,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["EntitlementGroups"] = []
        commit = True
    db.createIndex("EntitlementGroups", "EntitlementGroupsEntGroupIdx",
                   "entGroup", unique = True)
    if createTrigger(db, "EntitlementGroups"):
        commit = True

    if "EntitlementOwners" not in db.tables:
        cu.execute("""
        CREATE TABLE EntitlementOwners (
            entGroupId      INTEGER NOT NULL,
            ownerGroupId    INTEGER NOT NULL,
            CONSTRAINT EntitlementOwners_entGroupId_fk
                FOREIGN KEY (entGroupId) REFERENCES EntitlementGroups(entGroupId)
                ON DELETE CASCADE ON UPDATE CASCADE,
            CONSTRAINT EntitlementOwners_entOwnerId_fk
                FOREIGN KEY (ownerGroupId) REFERENCES userGroups(userGroupId)
                ON DELETE CASCADE ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" - db.keywords)
        db.tables["EntitlementOwners"] = []
        commit = True
    db.createIndex("EntitlementOwners", "EntitlementOwnersEntOwnerIdx",
                   "entGroupId, ownerGroupId", unique = True)
    db.createIndex("EntitlementOwners", "EntitlementOwnersOwnerIdx",
                   "ownerGroupId")

    if "Entitlements" not in db.tables:
        cu.execute("""
        CREATE TABLE Entitlements(
            entGroupId      INTEGER NOT NULL,
            entitlement     %(BINARY255)s NOT NULL,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT Entitlements_entGroupId_fk
                FOREIGN KEY (entGroupId) REFERENCES EntitlementGroups(entGroupId)
                ON DELETE RESTRICT ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["Entitlements"] = []
        commit = True
    db.createIndex("Entitlements", "EntitlementsEgEIdx",
                   "entGroupId, entitlement", unique = True)
    if createTrigger(db, "Entitlements"):
        commit = True

    if "EntitlementAccessMap" not in db.tables:
        cu.execute("""
        CREATE TABLE EntitlementAccessMap(
            entGroupId      INTEGER NOT NULL,
            userGroupId     INTEGER NOT NULL,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT EntitlementAccessMap_entGroupId_fk
                FOREIGN KEY (entGroupId) REFERENCES
                                            EntitlementGroups(entGroupId),
            CONSTRAINT EntitlementAccessMap_userGroupId_fk
                FOREIGN KEY (userGroupId) REFERENCES userGroups(userGroupId)
                ON DELETE RESTRICT ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["EntitlementAccessMap"] = []
        commit = True
    db.createIndex("EntitlementAccessMap", "EntitlementAccessMapIndex",
                   "entGroupId, userGroupId", unique = True)
    db.createIndex("EntitlementAccessMap", "EntitlementAMapUserGroupId_fk",
                   "userGroupId, entGroupId", unique = True)
    if createTrigger(db, "EntitlementAccessMap"):
        commit = True

    if commit:
        db.loadSchema()
dataset/ETHPy150Open sassoftware/conary/conary/server/schema.py/createEntitlements/operator `%` -> `-`