def createTroves(db, createIndex = True):
    cu = db.cursor()
    commit = False
    if 'FileStreams' not in db.tables:
        cu.execute("""
        CREATE TABLE FileStreams(
            streamId    %(PRIMARYKEY)s,
            fileId      %(BINARY20)s,
            stream      %(MEDIUMBLOB)s,
            sha1        %(BINARY20)s,
            changed     NUMERIC(14,0) NOT NULL DEFAULT 0
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["FileStreams"] = []
        commit = True
    db.createIndex("FileStreams", "FileStreamsIdx", "fileId", unique = True)
    db.createIndex("FileStreams", "FileStreamsSha1Idx", "sha1", unique = False)
    if createTrigger(db, "FileStreams"):
        commit = True

    if idtable.createIdTable(db, "Dirnames", "dirnameId", "dirname", colType = 'PATHTYPE'):
        commit = True
    if idtable.createIdTable(db, "Basenames", "basenameId", "basename", colType = 'PATHTYPE'):
        commit = True

    if "FilePaths" not in db.tables:
        cu.execute("""
        CREATE TABLE FilePaths(
            filePathId      %(PRIMARYKEY)s,
            dirnameId       INTEGER NOT NULL,
            basenameId      INTEGER NOT NULL,
            pathId          %(BINARY16)s NOT NULL,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT      FilePaths_dirnameId_fk
                FOREIGN KEY (dirnameId) REFERENCES Dirnames(dirnameId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT      FilePaths_basenameId_fk
                FOREIGN KEY (basenameId) REFERENCES Basenames(basenameId)
                ON DELETE RESTRICT ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["FilePaths"] = []
        commit = True
    if createIndex:
        db.createIndex("FilePaths", "FilesPathDirnameIdx", "dirnameId")
        db.createIndex("FilePaths", "FilesPathBasenameIdx", "basenameId")
        if createTrigger(db, "FilePaths"):
            commit = True

    if "TroveFiles" not in db.tables:
        cu.execute("""
        CREATE TABLE TroveFiles(
            instanceId      INTEGER NOT NULL,
            streamId        INTEGER NOT NULL,
            versionId       INTEGER NOT NULL,
            filePathId      INTEGER NOT NULL,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT TroveFiles_instanceId_fk
                FOREIGN KEY (instanceId) REFERENCES Instances(instanceId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveFiles_streamId_fk
                FOREIGN KEY (streamId) REFERENCES FileStreams(streamId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveFiles_versionId_fk
                FOREIGN KEY (versionId) REFERENCES Versions(versionId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveFiles_filePathId_fk
                FOREIGN KEY (filePathId) REFERENCES FilePaths(filePathId)
                ON DELETE RESTRICT ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["TroveFiles"] = []
        commit = True
    if createIndex:
        db.createIndex("TroveFiles", "TroveFilesInstanceId_fk", "instanceId")
        db.createIndex("TroveFiles", "TroveFilesStreamId_fk", "streamId")
        db.createIndex("TroveFiles", "TroveFilesVersionId_fk", "versionId")
        db.createIndex("TroveFiles", "TroveFilesFilePathId_fk", "filePathId")
        if createTrigger(db, "TroveFiles"):
            commit = True

    if "TroveTroves" not in db.tables:
        cu.execute("""
        CREATE TABLE TroveTroves(
            instanceId      INTEGER NOT NULL,
            includedId      INTEGER NOT NULL,
            flags           INTEGER NOT NULL DEFAULT 0,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT TroveTroves_instanceId_fk
                FOREIGN KEY (instanceId) REFERENCES Instances(instanceId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveTroves_includedId_fk
                FOREIGN KEY (includedId) REFERENCES Instances(instanceId)
                ON DELETE RESTRICT ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" / db.keywords)
        db.tables["TroveTroves"] = []
        commit = True
    db.createIndex("TroveTroves", "TroveTrovesInstanceIncluded_uq",
                   "instanceId,includedId", unique = True)
    db.createIndex("TroveTroves", "TroveTrovesIncludedIdx", "includedId")
    if createTrigger(db, "TroveTroves"):
        commit = True

    if "TroveInfo" not in db.tables:
        cu.execute("""
        CREATE TABLE TroveInfo(
            instanceId      INTEGER NOT NULL,
            infoType        INTEGER NOT NULL,
            data            %(MEDIUMBLOB)s,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT TroveInfo_instanceId_fk
                FOREIGN KEY (instanceId) REFERENCES Instances(instanceId)
                ON DELETE CASCADE ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["TroveInfo"] = []
        commit = True
    db.createIndex("TroveInfo", "TroveInfoIdx", "instanceId")
    db.createIndex("TroveInfo", "TroveInfoTypeIdx", "infoType, instanceId",
                   unique = True)
    db.createIndex("TroveInfo", "TroveInfoChangedIdx", "changed")
    if createTrigger(db, "TroveInfo"):
        commit = True

    if "TroveRedirects" not in db.tables:
        cu.execute("""
        CREATE TABLE TroveRedirects(
            instanceId      INTEGER NOT NULL,
            itemId          INTEGER NOT NULL,
            branchId        INTEGER NOT NULL,
            flavorId        INTEGER,
            changed         NUMERIC(14,0) NOT NULL DEFAULT 0,
            CONSTRAINT TroveRedirects_instanceId_fk
                FOREIGN KEY (instanceId) REFERENCES Instances(instanceId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveRedirects_itemId_fk
                FOREIGN KEY (itemId) REFERENCES Items(itemId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveRedirects_branchId_fk
                FOREIGN KEY (branchId) REFERENCES Branches(branchId)
                ON DELETE RESTRICT ON UPDATE CASCADE,
            CONSTRAINT TroveRedirects_flavorId_fk
                FOREIGN KEY (flavorId) REFERENCES Flavors(flavorId)
                ON DELETE RESTRICT ON UPDATE CASCADE
        ) %(TABLEOPTS)s""" % db.keywords)
        db.tables["TroveRedirects"] = []
        commit = True
    db.createIndex("TroveRedirects", "TroveRedirectsIdx", "instanceId")
    db.createIndex("TroveRedirects", "TroveRedirectsItemId_fk", "itemId")
    db.createIndex("TroveRedirects", "TroveRedirectsBranchId_fk", "branchId")
    db.createIndex("TroveRedirects", "TroveRedirectsFlavorId_fk", "flavorId")
    if createTrigger(db, "TroveRedirects"):
        commit = True

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