updates to db; course, cuisine added

This commit is contained in:
Mikayla Dobson
2022-12-08 13:51:53 -06:00
parent 2e47b6d385
commit 1b5856fa8f
12 changed files with 76 additions and 22 deletions

View File

View File

View File

@@ -16,14 +16,34 @@ export default async function populate() {
;
`
const populateCuisines = `
INSERT INTO recipin.cuisine (name, datecreated, datemodified, active) VALUES
('Thai', $1, $1, true),
('American', $1, $1, true),
('Tex Mex', $1, $1, true),
('Italian', $1, $1, true),
('Korean', $1, $1, true)
;
`
const populateCourses = `
INSERT INTO recipin.course (name, datecreated, datemodified, active) VALUES
('Breakfast', $1, $1, true),
('Lunch', $1, $1, true),
('Dinner', $1, $1, true),
('Appetizers', $1, $1, true),
('Dessert', $1, $1, true)
;
`
const populateRecipes = `
INSERT INTO recipin.recipe
(name, description, preptime, authoruserid, datecreated, datemodified)
(name, description, preptime, authoruserid, cuisineid, courseid, datecreated, datemodified)
VALUES
('Pad Thai', 'noodles', '1 hour', 1, $1, $1),
('Tacos', null, '30 minutes', 1, $1, $1),
('Garlic knots', null, '1 hour', 4, $1, $1),
('Cacio e pepe', 'stinky pasta', '1 hour', 3, $1, $1)
('Pad Thai', 'noodles', '1 hour', 1, 1, 3, $1, $1),
('Tacos', null, '30 minutes', 1, 3, 3, $1, $1),
('Garlic knots', null, '1 hour', 4, 4, 3, $1, $1),
('Cacio e pepe', 'stinky pasta', '1 hour', 3, 4, 3, $1, $1)
;
`
@@ -79,9 +99,9 @@ export default async function populate() {
`
const allStatements: Array<string> = [
populateUsers, populateRecipes, populateCollection,
populateIngredients, populateGroceryList, populateFriendships,
populateComments
populateUsers, populateCuisines, populateCourses, populateRecipes,
populateCollection, populateIngredients, populateGroceryList,
populateFriendships, populateComments
];
await pool.query(setup);

View File

@@ -20,6 +20,8 @@ dotenv.config();
const ingredient = fs.readFileSync(appRoot + '/db/sql/create/createingredient.sql').toString();
const collection = fs.readFileSync(appRoot + '/db/sql/create/createcollection.sql').toString();
const groceryList = fs.readFileSync(appRoot + '/db/sql/create/creategrocerylist.sql').toString();
const cuisine = fs.readFileSync(appRoot + '/db/sql/create/createcuisine.sql').toString();
const course = fs.readFileSync(appRoot + '/db/sql/create/createcourse.sql').toString();
const recipe = fs.readFileSync(appRoot + '/db/sql/create/createrecipe.sql').toString();
const recipecomments = fs.readFileSync(appRoot + '/db/sql/create/createrecipecomments.sql').toString();
const recipeingredient = fs.readFileSync(appRoot + '/db/sql/create/createcmp_recipeingredient.sql').toString();
@@ -28,9 +30,9 @@ dotenv.config();
const userfriendships = fs.readFileSync(appRoot + '/db/sql/create/createcmp_userfriendships.sql').toString();
const allStatements = [
setRole, appusers, ingredient, collection, recipe, recipecomments,
groceryList, recipeingredient, recipecollection, usersubscriptions,
userfriendships
setRole, appusers, ingredient, collection, cuisine, course,
recipe, recipecomments, groceryList, recipeingredient,
recipecollection, usersubscriptions, userfriendships
]
try {

View File

@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS recipin.course (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name varchar NOT NULL,
datecreated varchar NOT NULL,
datemodified varchar NOT NULL,
active boolean NOT NULL
);

View File

@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS recipin.cuisine (
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name varchar NOT NULL,
datecreated varchar NOT NULL,
datemodified varchar NOT NULL,
active boolean NOT NULL
);

View File

@@ -5,5 +5,7 @@ CREATE TABLE IF NOT EXISTS recipin.recipe (
datecreated varchar NOT NULL,
datemodified varchar NOT NULL,
description varchar,
authoruserid int REFERENCES recipin.appusers (id)
authoruserid int REFERENCES recipin.appusers (id),
cuisineid int REFERENCES recipin.cuisine (id),
courseid int REFERENCES recipin.course (id)
);

0
server/models/course.ts Normal file
View File

0
server/models/cuisine.ts Normal file
View File

0
server/routes/course.ts Normal file
View File

0
server/routes/cuisine.ts Normal file
View File

View File

@@ -31,6 +31,8 @@ export interface IRecipe extends HasHistory, CanDeactivate {
name: string
preptime: string
authoruserid: string | number
cuisineid?: string | number
courseid?: string | number
description?: string
ingredients?: string[]
}
@@ -38,6 +40,7 @@ export interface IRecipe extends HasHistory, CanDeactivate {
export interface IIngredient extends HasHistory {
name: string
description?: string
flavorprofile?: string | FlavorProfile['name']
createdbyid: string | number
}
@@ -57,3 +60,16 @@ export interface IFriendship extends HasHistory, CanDeactivate {
targetid: string | number
pending: boolean
}
export interface ICuisine extends HasHistory, CanDeactivate {
name: string
}
export interface ICourse extends HasHistory, CanDeactivate {
name: string
}
export interface FlavorProfile extends HasHistory, CanDeactivate {
name: string
description?: string
}