generated from ctc-uci/npo-template-merged
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,24 @@ | ||
CREATE TYPE adjustment AS ENUM ('none', 'total', 'rate_flat', 'rate_percent', 'paid'); | ||
|
||
CREATE TABLE comments ( | ||
id INT PRIMARY KEY UNIQUE NOT NULL DEFAULT nextval('comment_id_seq'), | ||
user_id INT REFERENCES users(id) NOT NULL, | ||
invoice_id INT REFERENCES invoices(id) NOT NULL, | ||
datetime TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, | ||
comment TEXT NOT NULL, | ||
adjustment_type adjustment DEFAULT 'none', | ||
adjustment_value NUMERIC DEFAULT 0 | ||
); | ||
CREATE TABLE IF NOT EXISTS public.comments | ||
( | ||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), | ||
user_id integer NOT NULL, | ||
booking_id integer, | ||
invoice_id integer NOT NULL, | ||
datetime timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
comment text COLLATE pg_catalog."default" NOT NULL, | ||
adjustment_type adjustment NOT NULL DEFAULT 'none'::adjustment, | ||
adjustment_value numeric NOT NULL DEFAULT 0, | ||
CONSTRAINT comment_pkey PRIMARY KEY (id), | ||
CONSTRAINT booking_id FOREIGN KEY (booking_id) | ||
REFERENCES public.bookings (id) MATCH SIMPLE | ||
ON UPDATE NO ACTION | ||
ON DELETE NO ACTION, | ||
CONSTRAINT invoice_id FOREIGN KEY (invoice_id) | ||
REFERENCES public.invoices (id) MATCH SIMPLE | ||
ON UPDATE NO ACTION | ||
ON DELETE NO ACTION, | ||
CONSTRAINT user_id FOREIGN KEY (user_id) | ||
REFERENCES public.users (id) MATCH SIMPLE | ||
ON UPDATE NO ACTION | ||
ON DELETE NO ACTION | ||
); |