--
--



ALTER TABLE ONLY _cscf_subscription.support_term DROP CONSTRAINT "user";
ALTER TABLE ONLY _cscf_subscription.rel_acct_user DROP CONSTRAINT "user";
ALTER TABLE ONLY _cscf_subscription.charge DROP CONSTRAINT term;
ALTER TABLE ONLY _cscf_subscription.support_term DROP CONSTRAINT term;
ALTER TABLE ONLY _cscf_subscription.rel_acct_user DROP CONSTRAINT support_acct;
ALTER TABLE ONLY _cscf_subscription.support_term DROP CONSTRAINT support_acct;
ALTER TABLE ONLY _cscf_subscription.rel_acct_user DROP CONSTRAINT rel_status;
ALTER TABLE ONLY _cscf_subscription.support_term DROP CONSTRAINT poc;
ALTER TABLE ONLY _cscf_subscription.users DROP CONSTRAINT user_pkey;
ALTER TABLE ONLY _cscf_subscription.user_payments DROP CONSTRAINT user_payments_pkey;
ALTER TABLE ONLY _cscf_subscription.user_flds DROP CONSTRAINT user_flds_pkey;
ALTER TABLE ONLY _cscf_subscription.user_flds DROP CONSTRAINT user_flds_field_name_key;
ALTER TABLE ONLY _cscf_subscription.term DROP CONSTRAINT term_pkey;
ALTER TABLE ONLY _cscf_subscription.support_term DROP CONSTRAINT support_term_pkey;
ALTER TABLE ONLY _cscf_subscription.support_acct DROP CONSTRAINT support_acct_pkey;
DROP TABLE _cscf_subscription.users;
DROP TABLE _cscf_subscription.user_payments;
DROP TABLE _cscf_subscription.user_flds;
DROP TABLE _cscf_subscription.term;
DROP TABLE _cscf_subscription.support_term;
DROP TABLE _cscf_subscription.support_acct;
DROP TABLE _cscf_subscription.rel_acct_user;
DROP TABLE _cscf_subscription.charge;
DROP EXTENSION plpgsql;
DROP SCHEMA public;
DROP SCHEMA _cscf_subscription;
--
-- Name: _cscf_subscription; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA _cscf_subscription;


ALTER SCHEMA _cscf_subscription OWNER TO postgres;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA public;


ALTER SCHEMA public OWNER TO postgres;

--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'standard public schema';


--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';





--
-- Name: charge; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE charge (
    support_acct text NOT NULL,
    term_id integer NOT NULL,
    debit numeric,
    credit numeric,
    reason text NOT NULL,
    comments text,
    date timestamp without time zone DEFAULT now() NOT NULL,
    del_when_regen boolean DEFAULT false NOT NULL,
    type text DEFAULT 'subscription'::text NOT NULL,
    has_been_printed boolean
);


ALTER TABLE _cscf_subscription.charge OWNER TO _cscf_subscription;

--
-- Name: TABLE charge; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE charge IS 'Charges and Payments table. Holds the information regarding the transactions an individual account has made--including: charges, payments, why the transaction occured, when the transaction happened, the type of account and whether it''s been printed.';


--
-- Name: COLUMN charge.support_acct; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.support_acct IS 'Account associated with the transaction row.';


--
-- Name: COLUMN charge.term_id; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.term_id IS 'Term_id number to reference a specific school term. (I.e. 1145 references Spring 2014). This is used as a FOREIGN KEY to connect with the other tables.';


--
-- Name: COLUMN charge.debit; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.debit IS 'Amount that the account has been charged by the subscription service on a specific transaction.';


--
-- Name: COLUMN charge.credit; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.credit IS 'Amount the account has paid to the subscription service on a specific transaction.';


--
-- Name: COLUMN charge.reason; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.reason IS 'Reason the transaction occured.';


--
-- Name: COLUMN charge.comments; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.comments IS 'Additional comments on the transaction. This appears to be a mostly stale column as only 15 items have this filled in.';


--
-- Name: COLUMN charge.date; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.date IS 'Date and time of the transaction in the format: yyyy-mm-dd 24h:min:sec.decimal_seconds';


--
-- Name: COLUMN charge.del_when_regen; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.del_when_regen IS 'Used when adding charges to a user. It is a failsafe to ensure that someone is not double charged during the same term. It also marks a row for deletion just before generating a bill so it is calculated fresh every time. Upon creating a new term all of the rows with a del_when_regen value of true are set to del_when_regen = false.';


--
-- Name: COLUMN charge.type; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.type IS 'Specifies the whether account is subscription or personal.';


--
-- Name: COLUMN charge.has_been_printed; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN charge.has_been_printed IS 'Indicates an item has been printed. It is only set to true when the Clear Bills button is pressed in Admin, FORE spreadsheet.';


--
-- Name: rel_acct_user; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE rel_acct_user (
    support_acct text NOT NULL,
    user_id text NOT NULL,
    rel_status integer NOT NULL
);


ALTER TABLE _cscf_subscription.rel_acct_user OWNER TO _cscf_subscription;

--
-- Name: TABLE rel_acct_user; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE rel_acct_user IS 'A relations table one that relates user_ids with support_ids (i.e. subscription codes). A single user may be related to more than one subscription.';


--
-- Name: COLUMN rel_acct_user.support_acct; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN rel_acct_user.support_acct IS 'Subscription Code. Links to Support_Acct table.';


--
-- Name: COLUMN rel_acct_user.user_id; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN rel_acct_user.user_id IS 'User''s ID. Links to users table.';


--
-- Name: COLUMN rel_acct_user.rel_status; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN rel_acct_user.rel_status IS 'Status of the user. Links to user_FLDS table.';


--
-- Name: support_acct; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE support_acct (
    support_id text NOT NULL,
    inactivation_date date,
    billing_status integer NOT NULL,
    comments text,
    date_create date DEFAULT ('now'::text)::date NOT NULL,
    date_edit date DEFAULT ('now'::text)::date NOT NULL,
    mfcf_support text,
    website text,
    group_name text,
    org_unit text
);


ALTER TABLE _cscf_subscription.support_acct OWNER TO _cscf_subscription;

--
-- Name: TABLE support_acct; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE support_acct IS 'Information regarding the individual subscriptions and their current status. ';


--
-- Name: COLUMN support_acct.support_id; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.support_id IS 'Subscription ID. Relates to supportCode in Inventory db.  ';


--
-- Name: COLUMN support_acct.inactivation_date; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.inactivation_date IS 'Date subscription became inactive. Keep for records.';


--
-- Name: COLUMN support_acct.billing_status; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.billing_status IS 'Numeric (0,1,9). English bill, dont bill, or undecided.';


--
-- Name: COLUMN support_acct.comments; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.comments IS 'HTML formatted comment';


--
-- Name: COLUMN support_acct.date_create; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.date_create IS 'Date subscription was created.';


--
-- Name: COLUMN support_acct.date_edit; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.date_edit IS 'Date last edited.';


--
-- Name: COLUMN support_acct.mfcf_support; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.mfcf_support IS 'Link to a MFCF help page. Can be NULL. Most if not all links here are stale.';


--
-- Name: COLUMN support_acct.website; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.website IS 'Can be NULL.';


--
-- Name: COLUMN support_acct.group_name; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.group_name IS 'Describes what group the subscription is related to. Must not be NULL.';


--
-- Name: COLUMN support_acct.org_unit; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_acct.org_unit IS 'Organizational Unit. Only used for organization purposes. Not used in any code branching. Currently only ''CS'' and NULL. ';


--
-- Name: support_term; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE support_term (
    term_id integer NOT NULL,
    support_acct text NOT NULL,
    units_dd numeric,
    comments text,
    date_create date DEFAULT ('now'::text)::date NOT NULL,
    date_edit date DEFAULT ('now'::text)::date NOT NULL,
    poc text NOT NULL,
    type text DEFAULT 'dedicated'::text NOT NULL,
    units_dk numeric,
    active boolean NOT NULL
);


ALTER TABLE _cscf_subscription.support_term OWNER TO _cscf_subscription;

--
-- Name: TABLE support_term; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE support_term IS 'Data relating to the subscription status of the subscription accounts on a by term basis. I.e. units billed and type of account etc.';


--
-- Name: COLUMN support_term.term_id; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_term.term_id IS 'Numerical term id which represents a year and season (Fall, Winter, Spring).';


--
-- Name: COLUMN support_term.support_acct; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_term.support_acct IS 'Subscription account code. Links to support_acct table.';


--
-- Name: COLUMN support_term.units_dd; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_term.units_dd IS 'Dedicated units the subscription was billed for, for the given term. These work different than desktops since they are charged hourly.';


--
-- Name: COLUMN support_term.poc; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_term.poc IS 'Point of Contact. LINKS to Users table. There will only be one point of contact for a given subscription.';


--
-- Name: COLUMN support_term.type; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_term.type IS 'Type of account: ''dedicated or desktop''.';


--
-- Name: COLUMN support_term.units_dk; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN support_term.units_dk IS 'Desktop units the subscription was billed for, for the given term. Refers to computer units. Not necessarily equal to the number of Computer items linked to a subscription in inventory db.';


--
-- Name: term; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE term (
    numerical_id integer NOT NULL,
    unit_cost numeric NOT NULL,
    machine_cost numeric NOT NULL,
    unit_hr numeric NOT NULL,
    comments text,
    latex_template_dd text NOT NULL,
    latex_template_dk text NOT NULL,
    unit_hr_dk numeric NOT NULL,
    dd_bill_pagination integer DEFAULT 5 NOT NULL,
    dk_bill_pagination integer DEFAULT 30 NOT NULL
);


ALTER TABLE _cscf_subscription.term OWNER TO _cscf_subscription;

--
-- Name: TABLE term; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE term IS 'Information about each term such as the cost of the subscription for dedicated and desktop subscriptions for a given term. Also has templates for latex.';


--
-- Name: COLUMN term.numerical_id; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.numerical_id IS 'ID number of the term.';


--
-- Name: COLUMN term.unit_cost; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.unit_cost IS 'Cost per unit for the term.';


--
-- Name: COLUMN term.machine_cost; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.machine_cost IS 'Cost per desktop machine for the term.';


--
-- Name: COLUMN term.unit_hr; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.unit_hr IS 'Cost of an hour of a unit for term.';


--
-- Name: COLUMN term.latex_template_dd; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.latex_template_dd IS 'Latex template used for printing the bills for dedicated term subscriptions.';


--
-- Name: COLUMN term.latex_template_dk; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.latex_template_dk IS 'Latex template used for printing the bill for desktop term subscriptions. ';


--
-- Name: COLUMN term.unit_hr_dk; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.unit_hr_dk IS 'Desktop unit cost (per hour) for the term.';


--
-- Name: COLUMN term.dd_bill_pagination; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.dd_bill_pagination IS 'Number of dedicated units to paginate on bills.';


--
-- Name: COLUMN term.dk_bill_pagination; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN term.dk_bill_pagination IS 'Number of desktop units to paginate on bills.';


--
-- Name: user_flds; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE user_flds (
    rel_status integer NOT NULL,
    field_name text NOT NULL,
    form_name text NOT NULL,
    field_rows integer NOT NULL,
    billing_field boolean NOT NULL,
    order_list integer DEFAULT 1 NOT NULL,
    active boolean DEFAULT true NOT NULL
);


ALTER TABLE _cscf_subscription.user_flds OWNER TO _cscf_subscription;

--
-- Name: TABLE user_flds; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE user_flds IS 'Table used for categorizing users and creating new categories if desired. Every user will have an associated rel_status from here. ';


--
-- Name: COLUMN user_flds.rel_status; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_flds.rel_status IS 'Primary key for the table and thus a unique integer identifier by which to relate each row.';


--
-- Name: COLUMN user_flds.field_name; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_flds.field_name IS 'Computer/code friendly field name, not meant to be viewed.';


--
-- Name: COLUMN user_flds.form_name; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_flds.form_name IS 'Label that will be displayed in subscriptions.';


--
-- Name: COLUMN user_flds.billing_field; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_flds.billing_field IS 'Determines whether or not the user should be billed for their subscriptions.';


--
-- Name: COLUMN user_flds.order_list; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_flds.order_list IS 'Unique column used to change the order of results when database is queried. I.e. used in conjunction with an ORDER BY SQL command.';


--
-- Name: user_payments; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE user_payments (
    support_id text NOT NULL,
    username text NOT NULL,
    method text,
    value numeric DEFAULT 0,
    account_number text
);


ALTER TABLE _cscf_subscription.user_payments OWNER TO _cscf_subscription;

--
-- Name: TABLE user_payments; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE user_payments IS 'Subscription payment default information for auto-filling payment form. Also holds some stored account numbers.';


--
-- Name: COLUMN user_payments.support_id; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_payments.support_id IS 'Subscription code which relates to Support_acct table.';


--
-- Name: COLUMN user_payments.username; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_payments.username IS 'User associated with the subscription and partly responsible for payment';


--
-- Name: COLUMN user_payments.method; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_payments.method IS 'Preferred method of payment for the given subscription. Valid values are: ''%'', ''even'', or ''$''.';


--
-- Name: COLUMN user_payments.value; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_payments.value IS 'Value is used when the method requires it. If the method was ''%'' or ''$''.';


--
-- Name: COLUMN user_payments.account_number; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN user_payments.account_number IS 'Account number of the user. Doesn''t necessarily need to be filled in.';


--
-- Name: users; Type: TABLE; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

CREATE TABLE users (
    username text NOT NULL,
    comments text,
    expire date,
    flags text
);


ALTER TABLE _cscf_subscription.users OWNER TO _cscf_subscription;

--
-- Name: TABLE users; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON TABLE users IS 'List of users as well as expiry dates and privilege flags for database use/access.';


--
-- Name: COLUMN users.expire; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN users.expire IS 'Can be null or it can accept a date in the format: yyyy-mm-dd. The purpose is to determine whether a user should still be active in the system.';


--
-- Name: COLUMN users.flags; Type: COMMENT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

COMMENT ON COLUMN users.flags IS 'String field which can be null as well. Represents user privileges when accessing the database. ''r'' read. ''d'' delete. ''b'' bill. ''m'' modify.';


--
-- Name: support_acct_pkey; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY support_acct
    ADD CONSTRAINT support_acct_pkey PRIMARY KEY (support_id);


--
-- Name: support_term_pkey; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY support_term
    ADD CONSTRAINT support_term_pkey PRIMARY KEY (term_id, support_acct);


--
-- Name: term_pkey; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY term
    ADD CONSTRAINT term_pkey PRIMARY KEY (numerical_id);


--
-- Name: user_flds_field_name_key; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY user_flds
    ADD CONSTRAINT user_flds_field_name_key UNIQUE (field_name);


--
-- Name: user_flds_pkey; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY user_flds
    ADD CONSTRAINT user_flds_pkey PRIMARY KEY (rel_status);


--
-- Name: user_payments_pkey; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY user_payments
    ADD CONSTRAINT user_payments_pkey PRIMARY KEY (support_id, username);


--
-- Name: user_pkey; Type: CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription; Tablespace: 
--

ALTER TABLE ONLY users
    ADD CONSTRAINT user_pkey PRIMARY KEY (username);


--
-- Name: poc; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY support_term
    ADD CONSTRAINT poc FOREIGN KEY (poc) REFERENCES users(username) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: rel_status; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY rel_acct_user
    ADD CONSTRAINT rel_status FOREIGN KEY (rel_status) REFERENCES user_flds(rel_status);


--
-- Name: support_acct; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY support_term
    ADD CONSTRAINT support_acct FOREIGN KEY (support_acct) REFERENCES support_acct(support_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: support_acct; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY rel_acct_user
    ADD CONSTRAINT support_acct FOREIGN KEY (support_acct) REFERENCES support_acct(support_id) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: term; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY support_term
    ADD CONSTRAINT term FOREIGN KEY (term_id) REFERENCES term(numerical_id) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- Name: term; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY charge
    ADD CONSTRAINT term FOREIGN KEY (term_id) REFERENCES term(numerical_id) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- Name: user; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY rel_acct_user
    ADD CONSTRAINT "user" FOREIGN KEY (user_id) REFERENCES users(username) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: user; Type: FK CONSTRAINT; Schema: _cscf_subscription; Owner: _cscf_subscription
--

ALTER TABLE ONLY support_term
    ADD CONSTRAINT "user" FOREIGN KEY (poc) REFERENCES users(username) ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: _cscf_subscription; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA _cscf_subscription FROM PUBLIC;
REVOKE ALL ON SCHEMA _cscf_subscription FROM postgres;
GRANT ALL ON SCHEMA _cscf_subscription TO postgres;
GRANT ALL ON SCHEMA _cscf_subscription TO _cscf_subscription;
GRANT USAGE ON SCHEMA _cscf_subscription TO PUBLIC;


--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- Name: charge; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE charge FROM PUBLIC;
REVOKE ALL ON TABLE charge FROM _cscf_subscription;
GRANT ALL ON TABLE charge TO _cscf_subscription;


--
-- Name: rel_acct_user; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE rel_acct_user FROM PUBLIC;
REVOKE ALL ON TABLE rel_acct_user FROM _cscf_subscription;
GRANT ALL ON TABLE rel_acct_user TO _cscf_subscription;


--
-- Name: support_acct; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE support_acct FROM PUBLIC;
REVOKE ALL ON TABLE support_acct FROM _cscf_subscription;
GRANT ALL ON TABLE support_acct TO _cscf_subscription;


--
-- Name: support_term; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE support_term FROM PUBLIC;
REVOKE ALL ON TABLE support_term FROM _cscf_subscription;
GRANT ALL ON TABLE support_term TO _cscf_subscription;


--
-- Name: term; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE term FROM PUBLIC;
REVOKE ALL ON TABLE term FROM _cscf_subscription;
GRANT ALL ON TABLE term TO _cscf_subscription;


--
-- Name: user_flds; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE user_flds FROM PUBLIC;
REVOKE ALL ON TABLE user_flds FROM _cscf_subscription;
GRANT ALL ON TABLE user_flds TO _cscf_subscription;


--
-- Name: users; Type: ACL; Schema: _cscf_subscription; Owner: _cscf_subscription
--

REVOKE ALL ON TABLE users FROM PUBLIC;
REVOKE ALL ON TABLE users FROM _cscf_subscription;
GRANT ALL ON TABLE users TO _cscf_subscription;


--
--

