From 8215de528c8cecfa14323a15b62a1db43fa8a75c Mon Sep 17 00:00:00 2001 From: Sangita Sunuwar Date: Wed, 8 Aug 2018 16:19:42 +0100 Subject: [PATCH] fix db_build sql table name type > relates #1 --- config.env | 1 + src/database/db_build.sql | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config.env b/config.env index e69de29..10ea4c0 100644 --- a/config.env +++ b/config.env @@ -0,0 +1 @@ +DB_URL = postgres://sunuwars:sunuwars123@localhost:5432/toolshare \ No newline at end of file diff --git a/src/database/db_build.sql b/src/database/db_build.sql index 468b85b..6047ca4 100644 --- a/src/database/db_build.sql +++ b/src/database/db_build.sql @@ -17,7 +17,7 @@ CREATE TABLE items ( id SERIAL PRIMARY KEY, name VARCHAR(80) NOT NULL, description TEXT, - lender_id INTEGER REFERENCES users (id) NOT NULL + lender_id INTEGER REFERENCES users(id) NOT NULL ); INSERT INTO items (name, description, lender_id) VALUES @@ -26,16 +26,16 @@ INSERT INTO items (name, description, lender_id) VALUES CREATE TABLE loans ( id SERIAL PRIMARY KEY, - item_id INTEGER REFERENCES items (id) NOT NULL, - borrowers_id INTEGER REFERENCES users (id) NOT NULL, + item_id INTEGER REFERENCES items(id) NOT NULL, + borrowers_id INTEGER REFERENCES users(id) NOT NULL, issue_date DATE NOT NULL DEFAULT CURRENT_DATE, return_date DATE ); -INSERT INTO items (item_id, borrowers_id) VALUES +INSERT INTO loans (item_id, borrowers_id) VALUES (1, 1); -INSERT INTO items (item_id, borrowers_id, issue_date) VALUES +INSERT INTO loans (item_id, borrowers_id, issue_date) VALUES (2, 2, '2018-07-08'); COMMIT; \ No newline at end of file