Datenbak Schema
This commit is contained in:
parent
ccf0a7958a
commit
13151e2ab6
45
hsarback/database/data.sql
Normal file
45
hsarback/database/data.sql
Normal file
@ -0,0 +1,45 @@
|
||||
--
|
||||
-- Table: basepacket
|
||||
--
|
||||
INSERT INTO basepacket (basepacket_code, description, sorting, valid)
|
||||
VALUES ('DW/B', 'Dynamic-Web/Base', 100, true);
|
||||
INSERT INTO basepacket (basepacket_code, description, sorting, valid)
|
||||
VALUES ('SW/B', 'Static-Web/Base', 200, true);
|
||||
|
||||
--
|
||||
-- Table: basecomponent
|
||||
--
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('TRAFFIC', 'Monatliches Datenvolumen in GB', 100, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('QUOTA', 'Festplattenspeicherplatz in MB', 200, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('TOMCAT', 'Nutzung eines eigenen Tomcat-Servers', 300, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('ZOPE', 'Nutzung eines eigenen Zope-Servers', 310, true);
|
||||
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
|
||||
VALUES ('APACHE', 'Nutzung eines eigenen Apache-Servers', 310, true);
|
||||
|
||||
--
|
||||
-- Table: component
|
||||
--
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 128, 40960, 128, 128, 128, false FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='QUOTA';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 512, 40960, 512, 512, 512, false FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='QUOTA';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 2, 40960, 2, 2, 2, false FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='TRAFFIC';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 4, 40960, 4, 4, 4, false FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='TRAFFIC';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='TOMCAT';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 0, 0, 1, 0, false FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='TOMCAT';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='ZOPE';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 0, 0, 1, 0, false FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='ZOPE';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 4, 0, 1, 0, false FROM basepacket, basecomponent WHERE basepacket_code='DW/B' AND basecomponent_code='APACHE';
|
||||
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only)
|
||||
SELECT basepacket_id, basecomponent_id, 0, 0, 0, 1, 0, false FROM basepacket, basecomponent WHERE basepacket_code='SW/B' AND basecomponent_code='APACHE';
|
939
hsarback/database/schema.sql
Normal file
939
hsarback/database/schema.sql
Normal file
@ -0,0 +1,939 @@
|
||||
--
|
||||
-- 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,
|
||||
autodebit_ga boolean,
|
||||
autodebit_ar boolean,
|
||||
autodebit_op boolean,
|
||||
bank_customer character varying(50),
|
||||
bank_account character varying(10),
|
||||
bank_code character varying(8),
|
||||
bank_name character varying(50),
|
||||
CONSTRAINT ckt_bank_account CHECK (((((((bank_customer IS NOT NULL) AND (bank_account IS NOT NULL)) AND (bank_code IS NOT NULL)) AND (bank_name IS NOT NULL)) AND (((autodebit_ga = true) OR (autodebit_ar = true)) OR (autodebit_op = true))) OR (((autodebit_ga = false) AND (autodebit_ar = false)) AND (autodebit_op = false))))
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: bank_account_bank_account_i_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE bank_account_bank_account_i_seq
|
||||
INCREMENT BY 1
|
||||
NO MAXVALUE
|
||||
NO MINVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- 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,
|
||||
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),
|
||||
CONSTRAINT ckc_member_id_business CHECK (((member_id >= 10000) AND (member_id <= 99999))),
|
||||
CONSTRAINT ckc_shares_signed_business CHECK ((shares_signed >= 0)),
|
||||
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) AND (member_since IS NOT NULL)) OR (((member_code)::text !~~ 'hsh00-%'::text) AND (member_since IS NULL)))))
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- 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,
|
||||
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,
|
||||
CONSTRAINT ckt_component CHECK (((((((((min_quantity <= max_quantity) AND (min_quantity <= default_quantity)) AND (default_quantity <= max_quantity)) AND (min_quantity <= include_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)))
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
|
||||
--
|
||||
-- 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;
|
||||
|
||||
|
||||
SET default_with_oids = false;
|
||||
|
||||
--
|
||||
-- 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_status character varying(12) NOT NULL,
|
||||
domain_status_changed date NOT NULL,
|
||||
domain_filed date,
|
||||
domain_since date,
|
||||
domain_until date,
|
||||
domain_dns_master character varying(64),
|
||||
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
|
||||
domain_owner integer NOT NULL,
|
||||
domain_reminder date,
|
||||
domain_free boolean DEFAULT false NOT NULL,
|
||||
domain_template character varying(32)
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- 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: member_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE member_id_seq
|
||||
INCREMENT BY 1
|
||||
MAXVALUE 99999
|
||||
MINVALUE 10200
|
||||
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,
|
||||
order_number character varying(20),
|
||||
webserver_group character varying(10),
|
||||
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;
|
||||
|
||||
|
||||
--
|
||||
-- Name: queue_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY queue
|
||||
ADD CONSTRAINT queue_user_id_fkey FOREIGN KEY (user_id) REFERENCES unixuser(unixuser_id) DEFERRABLE;
|
||||
|
Loading…
Reference in New Issue
Block a user