CREATE DATABASE cavecommdatabase;

\connect cavecommdatabase

CREATE SCHEMA public;

CREATE TABLE public.commissions (
    requestid integer NOT NULL,
    customeremailaddress text NOT NULL,
    freelancer character varying(64) NOT NULL,
    templatename character varying(64) DEFAULT 'N/A'::character varying NOT NULL,
    currencypreference character varying(6) NOT NULL,
    priceupfront numeric DEFAULT 0 NOT NULL,
    priceondeliver numeric DEFAULT 0 NOT NULL,
    requestdescription text DEFAULT 'N/A'::text NOT NULL,
    accepted boolean,
    upfrontinvoiceid character varying(64) DEFAULT 'N/A'::character varying NOT NULL,
    ondeliverinvoiceid character varying(64) DEFAULT 'N/A'::character varying NOT NULL,
    upfrontpaid boolean DEFAULT false NOT NULL,
    ondeliverpaid boolean DEFAULT false NOT NULL
);


COMMENT ON COLUMN public.commissions.accepted IS 'null = undecided';

CREATE SEQUENCE public.commissions_requestid_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.commissions_requestid_seq OWNER TO testuser;

ALTER SEQUENCE public.commissions_requestid_seq OWNED BY public.commissions.requestid;

ALTER TABLE ONLY public.commissions ALTER COLUMN requestid SET DEFAULT nextval('public.commissions_requestid_seq'::regclass);

SELECT pg_catalog.setval('public.commissions_requestid_seq', 1, false);
