From a7fd792017b34f80e3abd4aa2783a23a6d58d141 Mon Sep 17 00:00:00 2001 From: Michael Lin Date: Thu, 9 Jun 2022 17:10:22 -0700 Subject: [PATCH] Uploaded Schema --- package-lock.json | 13 ++++++++++++ package.json | 19 +++++++++++++++++ server/.gitignore | 0 server/schema/.gitignore | 0 server/schema/answers.sql | 35 ++++++++++++++++++++++++++++++++ server/schema/answers_photos.sql | 29 ++++++++++++++++++++++++++ server/schema/questions.sql | 22 ++++++++++++++++++++ 7 files changed, 118 insertions(+) create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 server/.gitignore create mode 100644 server/schema/.gitignore create mode 100644 server/schema/answers.sql create mode 100644 server/schema/answers_photos.sql create mode 100644 server/schema/questions.sql diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e85550c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "foo", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "foo", + "version": "1.0.0", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d800cb4 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "foo", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Baratheonly/SDC-QnA.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/Baratheonly/SDC-QnA/issues" + }, + "homepage": "https://github.com/Baratheonly/SDC-QnA#readme" +} diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/server/schema/.gitignore b/server/schema/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/server/schema/answers.sql b/server/schema/answers.sql new file mode 100644 index 0000000..4d171fb --- /dev/null +++ b/server/schema/answers.sql @@ -0,0 +1,35 @@ +-- Table: public.answers + +-- DROP TABLE IF EXISTS public.answers; + +CREATE TABLE IF NOT EXISTS public.answers +( + id integer NOT NULL DEFAULT nextval('answers_id_seq'::regclass), + question_id bigint NOT NULL, + body character varying(1000) COLLATE pg_catalog."default" NOT NULL, + answerer_name character varying(60) COLLATE pg_catalog."default" NOT NULL, + answerer_email character varying(60) COLLATE pg_catalog."default" NOT NULL, + reported boolean NOT NULL DEFAULT false, + helpful integer NOT NULL DEFAULT 0, + date_written bigint DEFAULT EXTRACT(epoch FROM CURRENT_TIMESTAMP), + "timestamp" timestamp(0) with time zone, + CONSTRAINT answers_pkey PRIMARY KEY (id), + CONSTRAINT question_id FOREIGN KEY (question_id) + REFERENCES public.questions (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + NOT VALID +) + +TABLESPACE pg_default; + +ALTER TABLE IF EXISTS public.answers + OWNER to michaellin; +-- Index: fki_question_id + +-- DROP INDEX IF EXISTS public.fki_question_id; + +CREATE INDEX IF NOT EXISTS fki_question_id + ON public.answers USING btree + (question_id ASC NULLS LAST) + TABLESPACE pg_default; \ No newline at end of file diff --git a/server/schema/answers_photos.sql b/server/schema/answers_photos.sql new file mode 100644 index 0000000..fea52d5 --- /dev/null +++ b/server/schema/answers_photos.sql @@ -0,0 +1,29 @@ +-- Table: public.answers_photos + +-- DROP TABLE IF EXISTS public.answers_photos; + +CREATE TABLE IF NOT EXISTS public.answers_photos +( + id integer NOT NULL DEFAULT nextval('answers_photos_id_seq'::regclass), + answer_id bigint NOT NULL, + url character varying(255) COLLATE pg_catalog."default" NOT NULL, + CONSTRAINT answers_photos_pkey PRIMARY KEY (id), + CONSTRAINT answer_id FOREIGN KEY (answer_id) + REFERENCES public.answers (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION + NOT VALID +) + +TABLESPACE pg_default; + +ALTER TABLE IF EXISTS public.answers_photos + OWNER to michaellin; +-- Index: fki_answer_id + +-- DROP INDEX IF EXISTS public.fki_answer_id; + +CREATE INDEX IF NOT EXISTS fki_answer_id + ON public.answers_photos USING btree + (answer_id ASC NULLS LAST) + TABLESPACE pg_default; \ No newline at end of file diff --git a/server/schema/questions.sql b/server/schema/questions.sql new file mode 100644 index 0000000..fc45b51 --- /dev/null +++ b/server/schema/questions.sql @@ -0,0 +1,22 @@ +-- Table: public.questions + +-- DROP TABLE IF EXISTS public.questions; + +CREATE TABLE IF NOT EXISTS public.questions +( + id integer NOT NULL DEFAULT nextval('questions_id_seq'::regclass), + product_id bigint NOT NULL, + body character varying(1000) COLLATE pg_catalog."default" NOT NULL, + asker_name character varying(60) COLLATE pg_catalog."default" NOT NULL, + asker_email character varying(60) COLLATE pg_catalog."default" NOT NULL, + reported boolean NOT NULL, + helpful integer NOT NULL, + date_written bigint, + "timestamp" timestamp(0) with time zone, + CONSTRAINT questions_pkey PRIMARY KEY (id) +) + +TABLESPACE pg_default; + +ALTER TABLE IF EXISTS public.questions + OWNER to michaellin; \ No newline at end of file