source: github/SQL/postgres.initial.sql @ edc63c2

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since edc63c2 was edc63c2, checked in by alecpl <alec@…>, 5 years ago

fix: there's no ALTER TABLE ... ADD INDEX in postgresql

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[977a295e]1--
2-- Sequence "user_ids"
3-- Name: user_ids; Type: SEQUENCE; Schema: public; Owner: postgres
4--
5
6CREATE SEQUENCE user_ids
7    INCREMENT BY 1
8    NO MAXVALUE
9    NO MINVALUE
10    CACHE 1;
11
[f5dc2a4]12--
[1cded85]13-- Table "users"
14-- Name: users; Type: TABLE; Schema: public; Owner: postgres
[f5dc2a4]15--
16
[1cded85]17CREATE TABLE users (
[15a9d1c]18    user_id integer DEFAULT nextval('user_ids'::text) PRIMARY KEY,
[1cded85]19    username character varying(128) DEFAULT ''::character varying NOT NULL,
20    mail_host character varying(128) DEFAULT ''::character varying NOT NULL,
21    alias character varying(128) DEFAULT ''::character varying NOT NULL,
22    created timestamp with time zone DEFAULT now() NOT NULL,
23    last_login timestamp with time zone DEFAULT now() NOT NULL,
24    "language" character varying(5) DEFAULT 'en'::character varying NOT NULL,
25    preferences text DEFAULT ''::text NOT NULL
26);
[f5dc2a4]27
28
[b594741]29 
[f5dc2a4]30--
[1cded85]31-- Table "session"
32-- Name: session; Type: TABLE; Schema: public; Owner: postgres
[f5dc2a4]33--
34
[1cded85]35CREATE TABLE "session" (
[15a9d1c]36    sess_id character varying(40) DEFAULT ''::character varying PRIMARY KEY,
[1cded85]37    created timestamp with time zone DEFAULT now() NOT NULL,
38    changed timestamp with time zone DEFAULT now() NOT NULL,
[84d06ed]39    ip character varying(41) NOT NULL,
[1cded85]40    vars text NOT NULL
41);
[f5dc2a4]42
43
44
45--
[b594741]46-- Sequence "identity_ids"
47-- Name: identity_ids; Type: SEQUENCE; Schema: public; Owner: postgres
48--
49
50CREATE SEQUENCE identity_ids
51    START WITH 1
52    INCREMENT BY 1
53    NO MAXVALUE
54    NO MINVALUE
55    CACHE 1;
56
57--
[1cded85]58-- Table "identities"
59-- Name: identities; Type: TABLE; Schema: public; Owner: postgres
[f5dc2a4]60--
61
[1cded85]62CREATE TABLE identities (
[15a9d1c]63    identity_id integer DEFAULT nextval('identity_ids'::text) PRIMARY KEY,
64    user_id integer NOT NULL REFERENCES users (user_id),
[1cded85]65    del integer DEFAULT 0 NOT NULL,
66    standard integer DEFAULT 0 NOT NULL,
67    name character varying(128) NOT NULL,
68    organization character varying(128),
69    email character varying(128) NOT NULL,
70    "reply-to" character varying(128),
71    bcc character varying(128),
[a0109c4]72    signature text,
73    html_signature integer DEFAULT 0 NOT NULL
[f5dc2a4]74);
75
76
[b594741]77
78--
79-- Sequence "contact_ids"
80-- Name: contact_ids; Type: SEQUENCE; Schema: public; Owner: postgres
81--
82
83CREATE SEQUENCE contact_ids
84    START WITH 1
85    INCREMENT BY 1
86    NO MAXVALUE
87    NO MINVALUE
88    CACHE 1;
89
[f5dc2a4]90--
[1cded85]91-- Table "contacts"
[f5dc2a4]92-- Name: contacts; Type: TABLE; Schema: public; Owner: postgres
93--
94
95CREATE TABLE contacts (
[15a9d1c]96    contact_id integer DEFAULT nextval('contact_ids'::text) PRIMARY KEY,
97    user_id integer NOT NULL REFERENCES users (user_id),
[1cded85]98    changed timestamp with time zone DEFAULT now() NOT NULL,
99    del integer DEFAULT 0 NOT NULL,
[f5dc2a4]100    name character varying(128) DEFAULT ''::character varying NOT NULL,
101    email character varying(128) DEFAULT ''::character varying NOT NULL,
102    firstname character varying(128) DEFAULT ''::character varying NOT NULL,
103    surname character varying(128) DEFAULT ''::character varying NOT NULL,
[1cded85]104    vcard text
[f5dc2a4]105);
106
107
108
109--
[b594741]110-- Sequence "cache_ids"
111-- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
112--
113
114CREATE SEQUENCE cache_ids
115    INCREMENT BY 1
116    NO MAXVALUE
117    NO MINVALUE
118    CACHE 1;
119
120--
[1cded85]121-- Table "cache"
122-- Name: cache; Type: TABLE; Schema: public; Owner: postgres
[f5dc2a4]123--
124
[1cded85]125CREATE TABLE "cache" (
[15a9d1c]126    cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
127    user_id integer NOT NULL REFERENCES users (user_id),
[f88d417]128    session_id character varying(40) REFERENCES "session" (sess_id),
[1cded85]129    cache_key character varying(128) DEFAULT ''::character varying NOT NULL,
[f5dc2a4]130    created timestamp with time zone DEFAULT now() NOT NULL,
[1cded85]131    data text NOT NULL
[f5dc2a4]132);
133
[edc63c2]134CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key);
[1cded85]135
[f5dc2a4]136--
[b594741]137-- Sequence "message_ids"
138-- Name: message_ids; Type: SEQUENCE; Schema: public; Owner: postgres
139--
140
141CREATE SEQUENCE message_ids
142    INCREMENT BY 1
143    NO MAXVALUE
144    NO MINVALUE
145    CACHE 1;
146
147--
[1cded85]148-- Table "messages"
149-- Name: messages; Type: TABLE; Schema: public; Owner: postgres
[f5dc2a4]150--
151
[1cded85]152CREATE TABLE "messages" (
[15a9d1c]153    message_id integer DEFAULT nextval('message_ids'::text) PRIMARY KEY,
154    user_id integer NOT NULL REFERENCES users (user_id),
[1cded85]155    del integer DEFAULT 0 NOT NULL,
156    cache_key character varying(128) DEFAULT ''::character varying NOT NULL,
[b594741]157    created timestamp with time zone DEFAULT now() NOT NULL,
[1cded85]158    idx integer DEFAULT 0 NOT NULL,
159    uid integer DEFAULT 0 NOT NULL,
160    subject character varying(128) DEFAULT ''::character varying NOT NULL,
161    "from" character varying(128) DEFAULT ''::character varying NOT NULL,
162    "to" character varying(128) DEFAULT ''::character varying NOT NULL,
163    cc character varying(128) DEFAULT ''::character varying NOT NULL,
164    date timestamp with time zone NOT NULL,
165    size integer DEFAULT 0 NOT NULL,
166    headers text NOT NULL,
[f7bfec9]167    structure text
[f5dc2a4]168);
169
[43a42dc]170ALTER TABLE "messages" ADD UNIQUE (user_id, cache_key, uid);
Note: See TracBrowser for help on using the repository browser.