hs.hsadmin/hsarback/database/schema.sql

981 lines
24 KiB
MySQL
Raw Normal View History

2010-10-06 13:46:29 +02:00
--
-- Name: bank_account; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE bank_account (
bank_account_id integer DEFAULT nextval(('"bank_account_bank_account_id_seq"'::text)::regclass) NOT NULL,
bp_id integer NOT NULL,
2013-04-23 22:02:08 +02:00
autodebit_ga boolean NOT NULL DEFAULT false,
autodebit_ar boolean NOT NULL DEFAULT false,
autodebit_op boolean NOT NULL DEFAULT false,
bank_customer character varying(50) NOT NULL DEFAULT '',
bank_account character varying(10) NOT NULL DEFAULT '',
bank_code character varying(8) NOT NULL DEFAULT '',
bank_name character varying(50) NOT NULL DEFAULT ''
2010-10-06 13:46:29 +02:00
);
--
-- Name: bank_account_bank_account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE bank_account_bank_account_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: basecomponent; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE basecomponent (
basecomponent_id integer DEFAULT nextval(('"basecomponent_basecomponent_seq"'::text)::regclass) NOT NULL,
basecomponent_code character varying(10) NOT NULL,
description character varying(100) NOT NULL,
sorting integer NOT NULL,
valid boolean NOT NULL
);
--
-- Name: basecomponent_basecomponent_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE basecomponent_basecomponent_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: basepacket; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE basepacket (
basepacket_id integer DEFAULT nextval(('"basepacket_basepacket_id_seq"'::text)::regclass) NOT NULL,
basepacket_code character varying(10) NOT NULL,
description character varying(100) NOT NULL,
2013-04-18 11:57:16 +02:00
article_number integer NOT NULL,
2010-10-06 13:46:29 +02:00
sorting integer NOT NULL,
valid boolean NOT NULL
);
--
-- Name: basepacket_basepacket_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE basepacket_basepacket_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: billdata; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE billdata (
billdata_id integer DEFAULT nextval(('"billdata_billdata_id_seq"'::text)::regclass) NOT NULL,
bp_id integer NOT NULL,
tariff_domain_discount_since date,
tariff_domain_discount_until date,
tariff_traffic_discount_since date,
tariff_traffic_discount_until date,
tariff_quota_discount_since date,
tariff_quota_discount_until date,
tariff_discount_since date,
tariff_discount_until date
);
--
-- Name: billdata_billdata_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE billdata_billdata_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: business_partner; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE business_partner (
bp_id integer DEFAULT nextval(('"business_partner_bp_id_seq"'::text)::regclass) NOT NULL,
member_id integer NOT NULL,
member_code character varying(20) NOT NULL,
member_since date,
member_until date,
member_role character varying(100),
author_contract date,
nondisc_contract date,
shares_updated date,
shares_signed integer NOT NULL,
uid_vat character varying(20),
2013-04-29 11:16:17 +02:00
free boolean NOT NULL,
2013-04-29 11:32:58 +02:00
indicator_vat character varying(20) NOT NULL,
2013-04-29 12:11:31 +02:00
exempt_vat boolean NOT NULL,
2010-10-06 13:46:29 +02:00
CONSTRAINT ckc_member_id_business CHECK (((member_id >= 10000) AND (member_id <= 99999))),
CONSTRAINT ckc_shares_signed_business CHECK ((shares_signed >= 0)),
2013-04-23 17:39:58 +02:00
CONSTRAINT ckt_business_partner CHECK ( ( ((member_since IS NULL) AND (member_until IS NULL)) OR ((member_since IS NOT NULL) AND (member_until IS NULL)) OR ((member_since IS NOT NULL) AND (member_until IS NOT NULL) AND (member_since < member_until)) ) AND ((member_code)::text ~~ 'hsh00-%'::text)),
UNIQUE (bp_id)
2010-10-06 13:46:29 +02:00
);
--
-- Name: business_partner_bp_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE business_partner_bp_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: component; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE component (
basepacket_id integer NOT NULL,
basecomponent_id integer NOT NULL,
2013-04-18 11:57:16 +02:00
article_number integer NOT NULL,
2010-10-06 13:46:29 +02:00
min_quantity integer NOT NULL,
max_quantity integer NOT NULL,
default_quantity integer NOT NULL,
increment_quantity integer NOT NULL,
include_quantity integer NOT NULL,
admin_only boolean NOT NULL,
2013-04-23 18:17:13 +02:00
CONSTRAINT ckt_component CHECK (
(min_quantity <= max_quantity) AND
(min_quantity <= default_quantity) AND
(default_quantity <= max_quantity) AND
(include_quantity <= max_quantity) AND
(mod(max_quantity, increment_quantity) = 0) AND
(mod(default_quantity, increment_quantity) = 0) AND
(mod(include_quantity, increment_quantity) = 0)
)
2010-10-06 13:46:29 +02:00
);
--
-- Name: contact; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE contact (
contact_id integer DEFAULT nextval(('"contact_contact_id_seq"'::text)::regclass) NOT NULL,
bp_id integer NOT NULL,
salut character varying(30),
first_name character varying(40) NOT NULL,
last_name character varying(40) NOT NULL,
title character varying(20),
firma character varying(120),
co character varying(50),
street character varying(50),
zipcode character varying(10),
city character varying(40),
country character varying(30),
phone_private character varying(30),
phone_office character varying(30),
phone_mobile character varying(30),
fax character varying(30),
email character varying(100) NOT NULL,
CONSTRAINT ckc_email_contact CHECK (((email)::text ~~ '%@%.%'::text))
);
--
-- Name: contact_contact_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE contact_contact_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
2013-04-18 11:57:16 +02:00
--
-- Name: price_list
--
CREATE TABLE price_list (
id serial primary key,
name character varying(20)
);
--
-- Name: customer_price_list_mapping
--
CREATE TABLE customer_price_list_mapping (
customer integer references business_partner(bp_id),
price_list integer references price_list(id)
);
--
-- Name: price
--
CREATE TABLE price (
id serial primary key,
article_number integer NOT NULL,
price decimal(10, 2) NOT NULL,
vat decimal(4,2) NOT NULL,
price_list integer references price_list(id)
);
2010-10-06 13:46:29 +02:00
--
-- Name: database_database_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE database_database_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: database; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE database (
database_id integer DEFAULT nextval('database_database_id_seq'::regclass) NOT NULL,
engine character varying(12) NOT NULL,
packet_id integer NOT NULL,
name character varying(64) NOT NULL,
owner character varying(24) NOT NULL,
encoding character varying(12) NOT NULL
);
--
-- Name: dbuser_dbuser_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE dbuser_dbuser_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: database_user; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE database_user (
dbuser_id integer DEFAULT nextval('dbuser_dbuser_id_seq'::regclass) NOT NULL,
engine character varying(12) NOT NULL,
packet_id integer NOT NULL,
name character varying(64) NOT NULL
);
--
-- Name: domain_domain_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE domain_domain_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: domain; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE domain (
domain_name character varying(256) NOT NULL,
domain_since date,
domain_dns_master character varying(64),
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
2012-07-27 14:02:41 +02:00
domain_owner integer NOT NULL
2010-10-06 13:46:29 +02:00
);
--
-- Name: emailaddr_emailaddr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE emailaddr_emailaddr_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: emailaddr; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE emailaddr (
emailaddr_id integer DEFAULT nextval('emailaddr_emailaddr_id_seq'::regclass) NOT NULL,
localpart character varying(64) NOT NULL,
domain_id integer NOT NULL,
target text,
subdomain character varying(64)
);
--
-- Name: emailalias_emailalias_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE emailalias_emailalias_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: emailalias; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE emailalias (
emailalias_id integer DEFAULT nextval('emailalias_emailalias_id_seq'::regclass) NOT NULL,
pac_id integer NOT NULL,
target text NOT NULL,
name character varying(96) NOT NULL
);
SET default_with_oids = true;
--
-- Name: hive; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE hive (
hive_id integer DEFAULT nextval(('"hive_hive_id_seq"'::text)::regclass) NOT NULL,
hive_name character varying(3) NOT NULL,
inet_addr_id integer NOT NULL,
description character varying(100)
);
--
-- Name: hive_hive_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE hive_hive_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: inet_addr; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE inet_addr (
inet_addr_id integer DEFAULT nextval(('"inet_addr_inet_addr_id_seq"'::text)::regclass) NOT NULL,
inet_addr inet NOT NULL,
description character varying(100),
CONSTRAINT ckc_inet_addr_inet_add CHECK ((masklen(inet_addr) = 32))
);
--
-- Name: inet_addr_inet_addr_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE inet_addr_inet_addr_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: packet; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE packet (
packet_id integer DEFAULT nextval(('"packet_packet_id_seq"'::text)::regclass) NOT NULL,
packet_name character varying(5) NOT NULL,
bp_id integer NOT NULL,
hive_id integer NOT NULL,
created date NOT NULL,
cancelled date,
free boolean NOT NULL,
2010-10-06 13:46:29 +02:00
cur_inet_addr_id integer,
old_inet_addr_id integer,
CONSTRAINT ckt_packet CHECK (((cancelled IS NULL) OR (cancelled > created)))
);
--
-- Name: packet_component; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE packet_component (
basepacket_id integer NOT NULL,
basecomponent_id integer NOT NULL,
packet_id integer NOT NULL,
quantity integer NOT NULL,
created date,
cancelled date,
CONSTRAINT ckt_packet_component CHECK (((cancelled IS NULL) OR (cancelled > created)))
);
--
-- Name: packet_packet_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE packet_packet_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
SET default_with_oids = false;
--
-- Name: queue_task; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE queue_task (
task_id integer DEFAULT nextval(('"queue_task_id_seq"'::text)::regclass) NOT NULL,
proc bytea,
exception text,
started timestamp without time zone NOT NULL,
finished timestamp without time zone,
title character varying(192),
details text,
user_id integer
);
--
-- Name: queue_task_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE queue_task_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: unixuser_unixuser_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE unixuser_unixuser_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: unixuser; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE unixuser (
unixuser_id integer DEFAULT nextval('unixuser_unixuser_id_seq'::regclass) NOT NULL,
name character varying(64) NOT NULL,
comment character varying(128),
shell character varying(64) NOT NULL,
homedir character varying(128) NOT NULL,
locked boolean NOT NULL,
packet_id integer NOT NULL,
quota_softlimit integer DEFAULT 0 NOT NULL,
userid integer NOT NULL,
quota_hardlimit integer DEFAULT 0,
CONSTRAINT unixuser_userid CHECK ((userid >= 10000))
);
--
-- Name: database_uniq; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY database
ADD CONSTRAINT database_uniq UNIQUE (engine, name);
--
-- Name: database_user_uniq; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY database_user
ADD CONSTRAINT database_user_uniq UNIQUE (engine, name);
--
-- Name: emailaddr_uniq; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY emailaddr
ADD CONSTRAINT emailaddr_uniq UNIQUE (localpart, subdomain, domain_id);
--
-- Name: emailalias_uniq; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY emailalias
ADD CONSTRAINT emailalias_uniq UNIQUE (name);
--
-- Name: pk_bank_account; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY bank_account
ADD CONSTRAINT pk_bank_account PRIMARY KEY (bank_account_id);
--
-- Name: pk_basecomponent; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY basecomponent
ADD CONSTRAINT pk_basecomponent PRIMARY KEY (basecomponent_id);
--
-- Name: pk_basepacket; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY basepacket
ADD CONSTRAINT pk_basepacket PRIMARY KEY (basepacket_id);
--
-- Name: pk_billdata; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY billdata
ADD CONSTRAINT pk_billdata PRIMARY KEY (billdata_id);
--
-- Name: pk_business_partner; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY business_partner
ADD CONSTRAINT pk_business_partner PRIMARY KEY (bp_id);
--
-- Name: pk_component; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY component
ADD CONSTRAINT pk_component PRIMARY KEY (basepacket_id, basecomponent_id);
--
-- Name: pk_contact; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY contact
ADD CONSTRAINT pk_contact PRIMARY KEY (contact_id);
--
-- Name: pk_database; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY database
ADD CONSTRAINT pk_database PRIMARY KEY (database_id);
--
-- Name: pk_database_user; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY database_user
ADD CONSTRAINT pk_database_user PRIMARY KEY (dbuser_id);
--
-- Name: pk_hive; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY hive
ADD CONSTRAINT pk_hive PRIMARY KEY (hive_id);
--
-- Name: pk_inet_addr; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY inet_addr
ADD CONSTRAINT pk_inet_addr PRIMARY KEY (inet_addr_id);
--
-- Name: pk_packet; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY packet
ADD CONSTRAINT pk_packet PRIMARY KEY (packet_id);
--
-- Name: pk_packet_component; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY packet_component
ADD CONSTRAINT pk_packet_component PRIMARY KEY (basepacket_id, basecomponent_id, packet_id);
--
-- Name: pk_unixuser; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY unixuser
ADD CONSTRAINT pk_unixuser PRIMARY KEY (unixuser_id);
--
-- Name: unixuser_name_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY unixuser
ADD CONSTRAINT unixuser_name_key UNIQUE (name);
--
-- Name: bank_account_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX bank_account_in_1 ON bank_account USING btree (bp_id);
--
-- Name: basecomponent_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX basecomponent_in_1 ON basecomponent USING btree (basecomponent_code);
--
-- Name: basepacket_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX basepacket_in_1 ON basepacket USING btree (basepacket_code);
--
-- Name: billdata_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX billdata_in_1 ON billdata USING btree (bp_id);
--
-- Name: component_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX component_in_1 ON component USING btree (basecomponent_id);
--
-- Name: contact_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX contact_in_1 ON contact USING btree (bp_id);
--
-- Name: customer_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX customer_in_1 ON business_partner USING btree (member_code);
--
-- Name: customer_in_2; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX customer_in_2 ON business_partner USING btree (member_id);
--
-- Name: database_unique_owner; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX database_unique_owner ON database_user USING btree (name, engine);
--
-- Name: domain_unique_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX domain_unique_id ON domain USING btree (domain_id);
--
-- Name: domain_unique_name; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX domain_unique_name ON domain USING btree (domain_name);
--
-- Name: emailaddr_uniq2; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX emailaddr_uniq2 ON emailaddr USING btree (localpart, domain_id) WHERE (subdomain IS NULL);
--
-- Name: hive_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX hive_in_1 ON hive USING btree (hive_name);
--
-- Name: inet_addr_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX inet_addr_in_1 ON inet_addr USING btree (inet_addr);
--
-- Name: packet_component_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX packet_component_in_1 ON packet_component USING btree (packet_id);
--
-- Name: packet_component_in_2; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX packet_component_in_2 ON packet_component USING btree (basecomponent_id);
--
-- Name: packet_in_1; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX packet_in_1 ON packet USING btree (packet_name);
--
-- Name: packet_in_2; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX packet_in_2 ON packet USING btree (bp_id);
--
-- Name: unique_task_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE UNIQUE INDEX unique_task_id ON queue_task USING btree (task_id);
--
-- Name: database_owner; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY database
ADD CONSTRAINT database_owner FOREIGN KEY (owner, engine) REFERENCES database_user(name, engine);
--
-- Name: database_packet_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY database
ADD CONSTRAINT database_packet_id_fkey FOREIGN KEY (packet_id) REFERENCES packet(packet_id) DEFERRABLE;
--
-- Name: dbuser_packet_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY database_user
ADD CONSTRAINT dbuser_packet_id_fkey FOREIGN KEY (packet_id) REFERENCES packet(packet_id) DEFERRABLE;
--
-- Name: domain_owner_chk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY domain
ADD CONSTRAINT domain_owner_chk FOREIGN KEY (domain_owner) REFERENCES unixuser(unixuser_id) MATCH FULL;
--
-- Name: email_domain; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY emailaddr
ADD CONSTRAINT email_domain FOREIGN KEY (domain_id) REFERENCES domain(domain_id);
--
-- Name: emailalias_pac_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY emailalias
ADD CONSTRAINT emailalias_pac_id_fkey FOREIGN KEY (pac_id) REFERENCES packet(packet_id) DEFERRABLE;
--
-- Name: fk_bank_acc_reference_business; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY bank_account
ADD CONSTRAINT fk_bank_acc_reference_business FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_bcomp_bpack; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY component
ADD CONSTRAINT fk_bcomp_bpack FOREIGN KEY (basepacket_id) REFERENCES basepacket(basepacket_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_billdata_reference_business; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY billdata
ADD CONSTRAINT fk_billdata_reference_business FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_comp_bcomp; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY packet_component
ADD CONSTRAINT fk_comp_bcomp FOREIGN KEY (basepacket_id, basecomponent_id) REFERENCES component(basepacket_id, basecomponent_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_comp_pack; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY packet_component
ADD CONSTRAINT fk_comp_pack FOREIGN KEY (packet_id) REFERENCES packet(packet_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_contact_reference_business; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY contact
ADD CONSTRAINT fk_contact_reference_business FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_hive_inet; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY hive
ADD CONSTRAINT fk_hive_inet FOREIGN KEY (inet_addr_id) REFERENCES inet_addr(inet_addr_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_pac_cur_inet; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY packet
ADD CONSTRAINT fk_pac_cur_inet FOREIGN KEY (cur_inet_addr_id) REFERENCES inet_addr(inet_addr_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_pac_old_inet; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY packet
ADD CONSTRAINT fk_pac_old_inet FOREIGN KEY (old_inet_addr_id) REFERENCES inet_addr(inet_addr_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_packet_bp; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY packet
ADD CONSTRAINT fk_packet_bp FOREIGN KEY (bp_id) REFERENCES business_partner(bp_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_packet_hive; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY packet
ADD CONSTRAINT fk_packet_hive FOREIGN KEY (hive_id) REFERENCES hive(hive_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: fk_reference_13; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY component
ADD CONSTRAINT fk_reference_13 FOREIGN KEY (basecomponent_id) REFERENCES basecomponent(basecomponent_id) ON UPDATE RESTRICT ON DELETE RESTRICT;
--
-- Name: queue_task_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY queue_task
ADD CONSTRAINT queue_task_user_id_fkey FOREIGN KEY (user_id) REFERENCES unixuser(unixuser_id) ON DELETE SET NULL;
--
-- domain options
--
2012-07-18 11:00:12 +02:00
CREATE SEQUENCE domain_option_id_seq
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
CREATE TABLE domain_option (
domain_option_id integer DEFAULT nextval(('"domain_option_id_seq"'::text)::regclass) NOT NULL,
domain_option_name character varying(50) NOT NULL
);
ALTER TABLE ONLY domain_option
2012-09-20 12:39:14 +02:00
ADD CONSTRAINT pk_domain_option PRIMARY KEY (domain_option_id);
2012-07-18 11:00:12 +02:00
2012-09-20 12:39:14 +02:00
CREATE UNIQUE INDEX domain_option_name_idx ON domain_option USING btree ( domain_option_name );
2012-07-18 11:00:12 +02:00
CREATE TABLE domain__domain_option (
domain_option_id integer NOT NULL,
domain_id integer NOT NULL
);
2012-09-20 12:39:14 +02:00
ALTER TABLE ONLY domain__domain_option
ADD CONSTRAINT pk_domain__domain_option PRIMARY KEY (domain_option_id, domain_id);
2012-07-18 11:00:12 +02:00
ALTER TABLE ONLY domain__domain_option
ADD CONSTRAINT domain_option_id_fkey FOREIGN KEY (domain_option_id)
REFERENCES domain_option(domain_option_id) DEFERRABLE;
ALTER TABLE ONLY domain__domain_option
ADD CONSTRAINT domain_id_fkey FOREIGN KEY (domain_id)
REFERENCES domain(domain_id) DEFERRABLE;
2010-10-06 13:46:29 +02:00