sqlGetPreferencesByUsername:fmt.Sprintf("SELECT second_factor_method FROM %s WHERE username=$1",userPreferencesTableName),
sqlUpsertSecondFactorPreference:fmt.Sprintf("INSERT INTO %s (username, second_factor_method) VALUES ($1, $2) ON CONFLICT (username) DO UPDATE SET second_factor_method=$2",userPreferencesTableName),
sqlTestIdentityVerificationTokenExistence:fmt.Sprintf("SELECT EXISTS (SELECT * FROM %s WHERE token=$1)",identityVerificationTokensTableName),
sqlInsertIdentityVerificationToken:fmt.Sprintf("INSERT INTO %s (token) VALUES ($1)",identityVerificationTokensTableName),
sqlDeleteIdentityVerificationToken:fmt.Sprintf("DELETE FROM %s WHERE token=$1",identityVerificationTokensTableName),
sqlGetTOTPSecretByUsername:fmt.Sprintf("SELECT secret FROM %s WHERE username=$1",totpSecretsTableName),
sqlUpsertTOTPSecret:fmt.Sprintf("INSERT INTO %s (username, secret) VALUES ($1, $2) ON CONFLICT (username) DO UPDATE SET secret=$2",totpSecretsTableName),
sqlDeleteTOTPSecret:fmt.Sprintf("DELETE FROM %s WHERE username=$1",totpSecretsTableName),
sqlGetU2FDeviceHandleByUsername:fmt.Sprintf("SELECT keyHandle, publicKey FROM %s WHERE username=$1",u2fDeviceHandlesTableName),
sqlUpsertU2FDeviceHandle:fmt.Sprintf("INSERT INTO %s (username, keyHandle, publicKey) VALUES ($1, $2, $3) ON CONFLICT (username) DO UPDATE SET keyHandle=$2, publicKey=$3",u2fDeviceHandlesTableName),
sqlInsertAuthenticationLog:fmt.Sprintf("INSERT INTO %s (username, successful, time) VALUES ($1, $2, $3)",authenticationLogsTableName),
sqlGetLatestAuthenticationLogs:fmt.Sprintf("SELECT successful, time FROM %s WHERE time>$1 AND username=$2 ORDER BY time DESC",authenticationLogsTableName),
sqlGetExistingTables:"SELECT table_name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema='public'",
sqlConfigSetValue:fmt.Sprintf("INSERT INTO %s (category, key_name, value) VALUES ($1, $2, $3) ON CONFLICT (category, key_name) DO UPDATE SET value=$3",configTableName),
sqlConfigGetValue:fmt.Sprintf("SELECT value FROM %s WHERE category=$1 AND key_name=$2",configTableName),