added a users table

This commit is contained in:
Arlo Filley 2022-11-06 19:28:35 +00:00
parent c7691adb56
commit b7e85e8c69

View File

@ -8,6 +8,15 @@ fn get_connection() -> rusqlite::Connection {
pub fn create_database() -> Result<()> { pub fn create_database() -> Result<()> {
let connection = get_connection(); let connection = get_connection();
connection.execute(
"CREATE TABLE IF NOT EXISTS users (
user_id INTEGER PRIMARY KEY,
username UNIQUE TEXT NOT NULL,
password TEXT NOT NULL
)",
()
)?;
connection.execute( connection.execute(
"CREATE TABLE IF NOT EXISTS tests ( "CREATE TABLE IF NOT EXISTS tests (
test_id INTEGER PRIMARY KEY, test_id INTEGER PRIMARY KEY,
@ -18,9 +27,10 @@ pub fn create_database() -> Result<()> {
quote_id INTEGER, quote_id INTEGER,
wpm INTEGER, wpm INTEGER,
accuracy INTEGER, accuracy INTEGER,
user_id INTEGER user_id INTEGER,
FOREIGN KEY(user_id) REFERENCES users(user_id)
)", )",
(), // empty parameters list ()
)?; )?;
Ok(()) Ok(())