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 = ` const populateRecipes = `
INSERT INTO recipin.recipe INSERT INTO recipin.recipe
(name, description, preptime, authoruserid, datecreated, datemodified) (name, description, preptime, authoruserid, cuisineid, courseid, datecreated, datemodified)
VALUES VALUES
('Pad Thai', 'noodles', '1 hour', 1, $1, $1), ('Pad Thai', 'noodles', '1 hour', 1, 1, 3, $1, $1),
('Tacos', null, '30 minutes', 1, $1, $1), ('Tacos', null, '30 minutes', 1, 3, 3, $1, $1),
('Garlic knots', null, '1 hour', 4, $1, $1), ('Garlic knots', null, '1 hour', 4, 4, 3, $1, $1),
('Cacio e pepe', 'stinky pasta', '1 hour', 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> = [ const allStatements: Array<string> = [
populateUsers, populateRecipes, populateCollection, populateUsers, populateCuisines, populateCourses, populateRecipes,
populateIngredients, populateGroceryList, populateFriendships, populateCollection, populateIngredients, populateGroceryList,
populateComments populateFriendships, populateComments
]; ];
await pool.query(setup); await pool.query(setup);

View File

@@ -16,21 +16,23 @@ dotenv.config();
CREATE SCHEMA IF NOT EXISTS recipin; CREATE SCHEMA IF NOT EXISTS recipin;
` `
const appusers = fs.readFileSync(appRoot + '/db/sql/create/createappusers.sql').toString(); const appusers = fs.readFileSync(appRoot + '/db/sql/create/createappusers.sql').toString();
const ingredient = fs.readFileSync(appRoot + '/db/sql/create/createingredient.sql').toString(); const ingredient = fs.readFileSync(appRoot + '/db/sql/create/createingredient.sql').toString();
const collection = fs.readFileSync(appRoot + '/db/sql/create/createcollection.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 groceryList = fs.readFileSync(appRoot + '/db/sql/create/creategrocerylist.sql').toString();
const recipe = fs.readFileSync(appRoot + '/db/sql/create/createrecipe.sql').toString(); const cuisine = fs.readFileSync(appRoot + '/db/sql/create/createcuisine.sql').toString();
const recipecomments = fs.readFileSync(appRoot + '/db/sql/create/createrecipecomments.sql').toString(); const course = fs.readFileSync(appRoot + '/db/sql/create/createcourse.sql').toString();
const recipeingredient = fs.readFileSync(appRoot + '/db/sql/create/createcmp_recipeingredient.sql').toString(); const recipe = fs.readFileSync(appRoot + '/db/sql/create/createrecipe.sql').toString();
const recipecollection = fs.readFileSync(appRoot + '/db/sql/create/createcmp_recipecollection.sql').toString(); const recipecomments = fs.readFileSync(appRoot + '/db/sql/create/createrecipecomments.sql').toString();
const usersubscriptions = fs.readFileSync(appRoot + '/db/sql/create/createcmp_usersubscriptions.sql').toString(); const recipeingredient = fs.readFileSync(appRoot + '/db/sql/create/createcmp_recipeingredient.sql').toString();
const userfriendships = fs.readFileSync(appRoot + '/db/sql/create/createcmp_userfriendships.sql').toString(); const recipecollection = fs.readFileSync(appRoot + '/db/sql/create/createcmp_recipecollection.sql').toString();
const usersubscriptions = fs.readFileSync(appRoot + '/db/sql/create/createcmp_usersubscriptions.sql').toString();
const userfriendships = fs.readFileSync(appRoot + '/db/sql/create/createcmp_userfriendships.sql').toString();
const allStatements = [ const allStatements = [
setRole, appusers, ingredient, collection, recipe, recipecomments, setRole, appusers, ingredient, collection, cuisine, course,
groceryList, recipeingredient, recipecollection, usersubscriptions, recipe, recipecomments, groceryList, recipeingredient,
userfriendships recipecollection, usersubscriptions, userfriendships
] ]
try { 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, datecreated varchar NOT NULL,
datemodified varchar NOT NULL, datemodified varchar NOT NULL,
description varchar, 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 name: string
preptime: string preptime: string
authoruserid: string | number authoruserid: string | number
cuisineid?: string | number
courseid?: string | number
description?: string description?: string
ingredients?: string[] ingredients?: string[]
} }
@@ -38,6 +40,7 @@ export interface IRecipe extends HasHistory, CanDeactivate {
export interface IIngredient extends HasHistory { export interface IIngredient extends HasHistory {
name: string name: string
description?: string description?: string
flavorprofile?: string | FlavorProfile['name']
createdbyid: string | number createdbyid: string | number
} }
@@ -56,4 +59,17 @@ export interface IFriendship extends HasHistory, CanDeactivate {
senderid: string | number senderid: string | number
targetid: string | number targetid: string | number
pending: boolean 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
} }