Skip to content

Commit

Permalink
Updated spacings on strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdf18 committed Dec 16, 2024
1 parent 73b64dc commit f85ce93
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ const db = new sqlite3.Database('./data/forkedflavors.db', (err) => {
db.serialize(() => {
// Users Table
db.run(`
CREATE TABLE IF NOT EXISTS users (
user_id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL
);
`);
CREATE TABLE IF NOT EXISTS users (
user_id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password_hash TEXT NOT NULL
);
`);

// Recipes Table with JSON column
db.run(`
CREATE TABLE IF NOT EXISTS recipes (
recipe_id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
title TEXT NOT NULL,
recipe_data TEXT NOT NULL, -- JSON stored as TEXT
forked_from INTEGER DEFAULT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (forked_from) REFERENCES recipes(forked_from)
);
`);
CREATE TABLE IF NOT EXISTS recipes (
recipe_id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
title TEXT NOT NULL,
recipe_data TEXT NOT NULL, -- JSON stored as TEXT
forked_from INTEGER DEFAULT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (forked_from) REFERENCES recipes(forked_from)
);
`);

// Comments Table
db.run(`
CREATE TABLE IF NOT EXISTS comments (
comment_id INTEGER PRIMARY KEY AUTOINCREMENT,
recipe_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
comment_text TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id),
FOREIGN KEY (user_id) REFERENCES users(user_id)
);
`);
CREATE TABLE IF NOT EXISTS comments (
comment_id INTEGER PRIMARY KEY AUTOINCREMENT,
recipe_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
comment_text TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (recipe_id) REFERENCES recipes(recipe_id),
FOREIGN KEY (user_id) REFERENCES users(user_id)
);
`);
});

module.exports = db;

0 comments on commit f85ce93

Please sign in to comment.