SVN_SILENT made messages (.desktop file) - always resolve ours
[trojita.git] / src / XtConnect / pgsql.sql
blob95914d42108f7c2736538f9c2b3c1795f5f060b4
1 CREATE SCHEMA xtbatch;
3 CREATE TABLE xtbatch.eml (
4   eml_id serial primary key,
5   eml_hash bytea not null UNIQUE,
6   eml_date date not null,
7   eml_subj text not null,
8   eml_body text not null,
9   eml_msg bytea not null,
10   eml_status char(1) not null CHECK (eml_status IN ('I','O','C'))
13 GRANT ALL ON TABLE xtbatch.eml TO xtrole;
14 GRANT ALL ON SEQUENCE xtbatch.eml_eml_id_seq TO xtrole;
16 COMMENT ON TABLE xtbatch.eml IS 'E-mail Repository';
17 COMMENT ON COLUMN xtbatch.eml.eml_id IS 'E-mail primary key';
18 COMMENT ON COLUMN xtbatch.eml.eml_hash IS 'Email md5 hash of message to check for uniqueness';
19 COMMENT ON COLUMN xtbatch.eml.eml_subj IS 'E-mail subject';
20 COMMENT ON COLUMN xtbatch.eml.eml_body IS 'E-mail body text';
21 COMMENT ON COLUMN xtbatch.eml.eml_msg IS 'Complete e-mail message content';
22 COMMENT ON COLUMN xtbatch.eml.eml_status IS 'Processing status I=In-process, O=open,C=complete';
25 CREATE TABLE xtbatch.emladdr (
26  emladdr_id serial,
27  emladdr_eml_id integer not null REFERENCES xtbatch.eml (eml_id),
28  emladdr_type text not null CHECK (emladdr_type IN ('FROM','TO','CC','BCC')),
29  emladdr_addr text not null,
30  emladdr_name text not null
31  );
34 GRANT ALL ON TABLE xtbatch.emladdr TO xtrole;
35 GRANT ALL ON SEQUENCE xtbatch.emladdr_emladdr_id_seq TO xtrole;
37 COMMENT ON TABLE xtbatch.emladdr IS 'E-mail addresses';
38 COMMENT ON COLUMN xtbatch.emladdr.emladdr_id IS 'E-mail address primary key';
39 COMMENT ON COLUMN xtbatch.emladdr.emladdr_eml_id IS 'Reference to E-mail primary key';
40 COMMENT ON COLUMN xtbatch.emladdr.emladdr_type IS 'Address type';
41 COMMENT ON COLUMN xtbatch.emladdr.emladdr_addr IS 'Address';
42 COMMENT ON COLUMN xtbatch.emladdr.emladdr_name IS 'Addressee name';
45 CREATE TABLE xtbatch.emlassc (
46   emlassc_id serial primary key,
47   emlassc_eml_id integer not null references xtbatch.eml (eml_id) ON DELETE CASCADE,
48   emlassc_type text not null CHECK (emlassc_type IN ('CRMA','T','C', 'EMP','INCDT','OPP','P','Q','S','TD','TO','V','RA','J')),
49   emlassc_assc_id integer );
51 GRANT ALL ON TABLE xtbatch.emlassc TO xtrole;
52 GRANT ALL ON SEQUENCE xtbatch.emlassc_emlassc_id_seq TO xtrole;
54 COMMENT ON TABLE xtbatch.emlassc IS 'E-mail Associations';
55 COMMENT ON COLUMN xtbatch.emlassc.emlassc_id IS 'E-mail Association unique identifier';
56 COMMENT ON COLUMN xtbatch.emlassc.emlassc_eml_id IS 'Reference to E-mail unique identifier';
57 COMMENT ON COLUMN xtbatch.emlassc.emlassc_type IS 'Association type (i.e. S=Sales Order, C=Customer, T=Contact etc.)';
58 COMMENT ON COLUMN xtbatch.emlassc.emlassc_assc_id IS 'Reference to associated table key';