updates to db seed, ts definitions
This commit is contained in:
0
server/db/examplevals.ts
Normal file
0
server/db/examplevals.ts
Normal file
@@ -5,6 +5,7 @@ dotenv.config();
|
||||
(async function() {
|
||||
const setRole = `
|
||||
SET ROLE postgres;
|
||||
DROP SCHEMA IF EXISTS recipin CASCADE;
|
||||
CREATE SCHEMA IF NOT EXISTS recipin;
|
||||
`
|
||||
|
||||
@@ -31,10 +32,22 @@ dotenv.config();
|
||||
CREATE TABLE IF NOT EXISTS recipin.collection (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
name varchar NOT NULL,
|
||||
active boolean NOT NULL,
|
||||
ismaincollection boolean NOT NULL,
|
||||
ownerid int REFERENCES recipin.appusers (id)
|
||||
);
|
||||
`
|
||||
|
||||
const groceryList = `
|
||||
CREATE TABLE IF NOT EXISTS recipin.grocerylist (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
name varchar NOT NULL,
|
||||
active boolean NOT NULL,
|
||||
ownerid int REFERENCES recipin.appusers (id)
|
||||
);
|
||||
`
|
||||
|
||||
|
||||
const recipe = `
|
||||
CREATE TABLE IF NOT EXISTS recipin.recipe (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
@@ -48,8 +61,8 @@ dotenv.config();
|
||||
`
|
||||
|
||||
const recipeingredient = `
|
||||
CREATE TABLE IF NOT EXISTS recipin.cmp_recipe_ingredient (
|
||||
recipe_ingredient_id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
CREATE TABLE IF NOT EXISTS recipin.cmp_recipeingredient (
|
||||
recipeingredientid INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
quantity decimal,
|
||||
unit varchar,
|
||||
ingredientid int REFERENCES recipin.ingredient (id),
|
||||
@@ -59,7 +72,7 @@ dotenv.config();
|
||||
`
|
||||
|
||||
const userscollections = `
|
||||
CREATE TABLE IF NOT EXISTS recipin.cmp_users_collections (
|
||||
CREATE TABLE IF NOT EXISTS recipin.cmp_userscollections (
|
||||
userscollectionsid INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
collectionid int REFERENCES recipin.collection (id),
|
||||
usermemberid int REFERENCES recipin.appusers (id)
|
||||
@@ -67,7 +80,7 @@ dotenv.config();
|
||||
`;
|
||||
|
||||
const allStatements = [
|
||||
setRole, appusers, ingredient, collection, recipe, recipeingredient, userscollections
|
||||
setRole, appusers, ingredient, collection, recipe, groceryList, recipeingredient, userscollections
|
||||
]
|
||||
|
||||
const client = new Client({ connectionString: process.env.CONSTRING });
|
||||
|
||||
Reference in New Issue
Block a user