From a0aa37ba4b282318cd7d7a9dd0f27a64eb3103a9 Mon Sep 17 00:00:00 2001 From: Nathan Pietrantonio <78774649+theNatePi@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:10:42 -0800 Subject: [PATCH] Replace invoices with PostgreSQL --- server/db/schema/invoices.sql | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/server/db/schema/invoices.sql b/server/db/schema/invoices.sql index 9f07190..9851aa6 100644 --- a/server/db/schema/invoices.sql +++ b/server/db/schema/invoices.sql @@ -1,9 +1,14 @@ -CREATE TABLE invoices ( - id INT PRIMARY KEY UNIQUE NOT NULL DEFAULT nextval('invoice_id_seq'), - event_id INT NOT NULL REFERENCES events(id), - start_date DATE NOT NULL, - end_date DATE NOT NULL, - is_sent BOOL NOT NULL DEFAULT False, - payment_status payment NOT NULL DEFAULT 'none' - -); \ No newline at end of file +CREATE TABLE IF NOT EXISTS public.invoices +( + id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), + event_id integer NOT NULL, + start_date date NOT NULL, + end_date date NOT NULL, + is_sent boolean NOT NULL DEFAULT false, + payment_status payment NOT NULL DEFAULT 'none'::payment, + CONSTRAINT invoice_pkey PRIMARY KEY (id), + CONSTRAINT event_id FOREIGN KEY (event_id) + REFERENCES public.events (id) MATCH SIMPLE + ON UPDATE NO ACTION + ON DELETE NO ACTION +);