Skip to content

Commit

Permalink
Replace comments with PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
theNatePi authored Dec 4, 2024
1 parent 98d881e commit 2084900
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions server/db/schema/comments.sql
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
);

0 comments on commit 2084900

Please sign in to comment.