Skip to content

Commit

Permalink
use text blocks for index creation
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Sep 25, 2024
1 parent 30d38ae commit 358137d
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions src/main/java/app/attestation/server/AttestationServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,33 @@ systemUser INTEGER NOT NULL CHECK (systemUser in (0, 1))
}

private static void createAttestationIndices(final SQLiteConnection conn) throws SQLiteException {
conn.exec("CREATE INDEX IF NOT EXISTS Accounts_loginTime " +
"ON Accounts (loginTime)");

conn.exec("CREATE INDEX IF NOT EXISTS Sessions_expiryTime " +
"ON Sessions (expiryTime)");
conn.exec("CREATE INDEX IF NOT EXISTS Sessions_userId " +
"ON Sessions (userId)");

conn.exec("CREATE INDEX IF NOT EXISTS Devices_userId_verifiedTimeFirst " +
"ON Devices (userId, verifiedTimeFirst)");
conn.exec("CREATE INDEX IF NOT EXISTS Devices_userId_verifiedTimeLast_deletionTimeNull " +
"ON Devices (userId, verifiedTimeLast) WHERE deletionTime IS NULL");
conn.exec("CREATE INDEX IF NOT EXISTS Devices_deletionTime " +
"ON Devices (deletionTime) WHERE deletionTime IS NOT NULL");
conn.exec("CREATE INDEX IF NOT EXISTS Devices_verifiedTimeLast_deletionTimeNull " +
"ON Devices (verifiedTimeLast) WHERE deletionTime IS NULL");

conn.exec("CREATE INDEX IF NOT EXISTS Attestations_fingerprint_id " +
"ON Attestations (fingerprint, id)");
conn.exec("""
CREATE INDEX IF NOT EXISTS Accounts_loginTime
ON Accounts (loginTime)""");

conn.exec("""
CREATE INDEX IF NOT EXISTS Sessions_expiryTime
ON Sessions (expiryTime)""");
conn.exec("""
CREATE INDEX IF NOT EXISTS Sessions_userId
ON Sessions (userId)""");

conn.exec("""
CREATE INDEX IF NOT EXISTS Devices_userId_verifiedTimeFirst
ON Devices (userId, verifiedTimeFirst)""");
conn.exec("""
CREATE INDEX IF NOT EXISTS Devices_userId_verifiedTimeLast_deletionTimeNull
ON Devices (userId, verifiedTimeLast) WHERE deletionTime IS NULL""");
conn.exec("""
CREATE INDEX IF NOT EXISTS Devices_deletionTime
ON Devices (deletionTime) WHERE deletionTime IS NOT NULL""");
conn.exec("""
CREATE INDEX IF NOT EXISTS Devices_verifiedTimeLast_deletionTimeNull
ON Devices (verifiedTimeLast) WHERE deletionTime IS NULL""");

conn.exec("""
CREATE INDEX IF NOT EXISTS Attestations_fingerprint_id
ON Attestations (fingerprint, id)""");
}

private static void createSamplesTable(final SQLiteConnection conn) throws SQLiteException {
Expand Down

0 comments on commit 358137d

Please sign in to comment.