db changes, refactoring with axios
This commit is contained in:
@@ -69,7 +69,7 @@ export default async function populate() {
|
||||
`
|
||||
|
||||
const populateComments = `
|
||||
INSERT INTO recipin.cmp_recipecomments
|
||||
INSERT INTO recipin.recipecomments
|
||||
(commentbody, datecreated, recipeid, authorid)
|
||||
VALUES
|
||||
('Very cool recipe!', $1, 2, 2),
|
||||
@@ -90,8 +90,9 @@ export default async function populate() {
|
||||
try {
|
||||
await pool.query(s, [now]);
|
||||
} catch(e: any) {
|
||||
console.error(e);
|
||||
console.log('Last executed: ' + s);
|
||||
throw new Error(e);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Client } from 'pg';
|
||||
import dotenv from 'dotenv';
|
||||
import populate from "./examplevals";
|
||||
import populate from "./populate";
|
||||
import pool from ".";
|
||||
|
||||
dotenv.config();
|
||||
@@ -73,7 +73,7 @@ dotenv.config();
|
||||
`
|
||||
|
||||
const recipecomments = `
|
||||
CREATE TABLE IF NOT EXISTS recipin.cmp_recipecomments (
|
||||
CREATE TABLE IF NOT EXISTS recipin.recipecomments (
|
||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
commentbody varchar NOT NULL,
|
||||
datecreated varchar NOT NULL,
|
||||
@@ -122,7 +122,8 @@ dotenv.config();
|
||||
await pool.query(s);
|
||||
}
|
||||
} catch(e: any) {
|
||||
throw new Error(e);
|
||||
console.error(e);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log("Database seed successful. Attempting to populate...");
|
||||
|
||||
Reference in New Issue
Block a user