From efe3323075ebc3f63fe86d1efa8908f002887168 Mon Sep 17 00:00:00 2001 From: Jeffrey Elkner Date: Wed, 26 Apr 2023 19:58:36 +0100 Subject: [PATCH] Start making create script idempotent --- scripts/create_tables.sql | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/create_tables.sql b/scripts/create_tables.sql index bb53646..c767e07 100644 --- a/scripts/create_tables.sql +++ b/scripts/create_tables.sql @@ -1,10 +1,14 @@ BEGIN TRANSACTION; -CREATE TABLE Author( +DROP TABLE IF EXISTS "author"; +DROP TABLE IF EXISTS "quote"; +DROP TABLE IF EXISTS "category"; +DROP TABLE IF EXISTS "quotecategory"; +CREATE TABLE author( aid SERIAL PRIMARY KEY, fname TEXT, lname TEXT ); -CREATE TABLE Quote( +CREATE TABLE quote( qid SERIAL PRIMARY KEY, qtext TEXT, aid INTEGER, @@ -12,11 +16,11 @@ CREATE TABLE Quote( qdate DATE, FOREIGN KEY (aid) REFERENCES Author(aid) ); -CREATE TABLE Category( +CREATE TABLE category( cid SERIAL PRIMARY KEY, description TEXT ); -CREATE TABLE QuoteCategory( +CREATE TABLE quotecategory( qid INTEGER, cid INTEGER, FOREIGN KEY(qid) REFERENCES Quote(qid),