sql/schéma.sql
author František Kučera <franta-hg@frantovo.cz>
Tue May 05 16:46:22 2009 +0200 (2009-05-05)
changeset 1 001f2734b554
child 12 38aadc7c6386
permissions -rw-r--r--
Heslo – kostra PHP skriptu pro změnu hesla
franta-hg@0
     1
--
franta-hg@0
     2
-- PostgreSQL database dump
franta-hg@0
     3
--
franta-hg@0
     4
franta-hg@0
     5
-- Started on 2009-05-05 16:25:08 CEST
franta-hg@0
     6
franta-hg@0
     7
SET client_encoding = 'UTF8';
franta-hg@0
     8
SET standard_conforming_strings = off;
franta-hg@0
     9
SET check_function_bodies = false;
franta-hg@0
    10
SET client_min_messages = warning;
franta-hg@0
    11
SET escape_string_warning = off;
franta-hg@0
    12
franta-hg@0
    13
--
franta-hg@0
    14
-- TOC entry 6 (class 2615 OID 16387)
franta-hg@0
    15
-- Name: posta; Type: SCHEMA; Schema: -; Owner: -
franta-hg@0
    16
--
franta-hg@0
    17
franta-hg@0
    18
CREATE SCHEMA posta;
franta-hg@0
    19
franta-hg@0
    20
franta-hg@0
    21
SET search_path = posta, pg_catalog;
franta-hg@0
    22
franta-hg@0
    23
--
franta-hg@0
    24
-- TOC entry 22 (class 1255 OID 16646)
franta-hg@0
    25
-- Dependencies: 6
franta-hg@0
    26
-- Name: zmen_heslo(character varying, character varying, character varying, character varying); Type: FUNCTION; Schema: posta; Owner: -
franta-hg@0
    27
--
franta-hg@0
    28
franta-hg@0
    29
CREATE FUNCTION zmen_heslo(login character varying, domena character varying, stare_heslo character varying, nove_heslo character varying) RETURNS void
franta-hg@0
    30
    AS $_$UPDATE uzivatel
franta-hg@0
    31
 SET heslo = md5($4)
franta-hg@0
    32
 WHERE 	login = $1
franta-hg@0
    33
	AND domena = $2
franta-hg@0
    34
	AND heslo = md5($3);$_$
franta-hg@0
    35
    LANGUAGE sql SECURITY DEFINER;
franta-hg@0
    36
franta-hg@0
    37
franta-hg@0
    38
--
franta-hg@0
    39
-- TOC entry 1801 (class 0 OID 0)
franta-hg@0
    40
-- Dependencies: 22
franta-hg@0
    41
-- Name: FUNCTION zmen_heslo(login character varying, domena character varying, stare_heslo character varying, nove_heslo character varying); Type: COMMENT; Schema: posta; Owner: -
franta-hg@0
    42
--
franta-hg@0
    43
franta-hg@0
    44
COMMENT ON FUNCTION zmen_heslo(login character varying, domena character varying, stare_heslo character varying, nove_heslo character varying) IS 'Změní heslo uživatele.';
franta-hg@0
    45
franta-hg@0
    46
franta-hg@0
    47
SET default_tablespace = '';
franta-hg@0
    48
franta-hg@0
    49
SET default_with_oids = false;
franta-hg@0
    50
franta-hg@0
    51
--
franta-hg@0
    52
-- TOC entry 1515 (class 1259 OID 16550)
franta-hg@0
    53
-- Dependencies: 6
franta-hg@0
    54
-- Name: alias; Type: TABLE; Schema: posta; Owner: -; Tablespace: 
franta-hg@0
    55
--
franta-hg@0
    56
franta-hg@0
    57
CREATE TABLE alias (
franta-hg@0
    58
    login character varying(255) NOT NULL,
franta-hg@0
    59
    domena character varying(255) NOT NULL,
franta-hg@0
    60
    cilova_adresa character varying(255) NOT NULL
franta-hg@0
    61
);
franta-hg@0
    62
franta-hg@0
    63
franta-hg@0
    64
--
franta-hg@0
    65
-- TOC entry 1502 (class 1259 OID 16396)
franta-hg@0
    66
-- Dependencies: 6
franta-hg@0
    67
-- Name: domena; Type: TABLE; Schema: posta; Owner: -; Tablespace: 
franta-hg@0
    68
--
franta-hg@0
    69
franta-hg@0
    70
CREATE TABLE domena (
franta-hg@0
    71
    domena character varying(255) NOT NULL
franta-hg@0
    72
);
franta-hg@0
    73
franta-hg@0
    74
franta-hg@0
    75
--
franta-hg@0
    76
-- TOC entry 1503 (class 1259 OID 16409)
franta-hg@0
    77
-- Dependencies: 6
franta-hg@0
    78
-- Name: uzivatel; Type: TABLE; Schema: posta; Owner: -; Tablespace: 
franta-hg@0
    79
--
franta-hg@0
    80
franta-hg@0
    81
CREATE TABLE uzivatel (
franta-hg@0
    82
    login character varying(255) NOT NULL,
franta-hg@0
    83
    heslo character varying(512),
franta-hg@0
    84
    domena character varying(255) NOT NULL
franta-hg@0
    85
);
franta-hg@0
    86
franta-hg@0
    87
franta-hg@0
    88
--
franta-hg@0
    89
-- TOC entry 1517 (class 1259 OID 16602)
franta-hg@0
    90
-- Dependencies: 1596 6
franta-hg@0
    91
-- Name: dovecot_heslo; Type: VIEW; Schema: posta; Owner: -
franta-hg@0
    92
--
franta-hg@0
    93
franta-hg@0
    94
CREATE VIEW dovecot_heslo AS
franta-hg@0
    95
    SELECT (((uzivatel.login)::text || '@'::text) || (uzivatel.domena)::text) AS "user", uzivatel.heslo AS password, uzivatel.login, uzivatel.domena FROM uzivatel;
franta-hg@0
    96
franta-hg@0
    97
franta-hg@0
    98
--
franta-hg@0
    99
-- TOC entry 1519 (class 1259 OID 16631)
franta-hg@0
   100
-- Dependencies: 1598 6
franta-hg@0
   101
-- Name: dovecot_uzivatel; Type: VIEW; Schema: posta; Owner: -
franta-hg@0
   102
--
franta-hg@0
   103
franta-hg@0
   104
CREATE VIEW dovecot_uzivatel AS
franta-hg@0
   105
    SELECT 5000 AS uid, 5000 AS gid, ((('/var/mail/virtualniposta/'::text || (uzivatel.domena)::text) || '/'::text) || (uzivatel.login)::text) AS home, (((('maildir:/var/mail/virtualniposta/'::text || (uzivatel.domena)::text) || '/'::text) || (uzivatel.login)::text) || '/Maildir'::text) AS mail, 'maildir:storage=524288'::text AS quota, uzivatel.login, uzivatel.domena FROM uzivatel;
franta-hg@0
   106
franta-hg@0
   107
franta-hg@0
   108
--
franta-hg@0
   109
-- TOC entry 1516 (class 1259 OID 16563)
franta-hg@0
   110
-- Dependencies: 1595 6
franta-hg@0
   111
-- Name: postfix_alias; Type: VIEW; Schema: posta; Owner: -
franta-hg@0
   112
--
franta-hg@0
   113
franta-hg@0
   114
CREATE VIEW postfix_alias AS
franta-hg@0
   115
    SELECT (((alias.login)::text || '@'::text) || (alias.domena)::text) AS zdroj, alias.cilova_adresa AS cil FROM alias;
franta-hg@0
   116
franta-hg@0
   117
franta-hg@0
   118
--
franta-hg@0
   119
-- TOC entry 1518 (class 1259 OID 16607)
franta-hg@0
   120
-- Dependencies: 1597 6
franta-hg@0
   121
-- Name: postfix_uzivatel; Type: VIEW; Schema: posta; Owner: -
franta-hg@0
   122
--
franta-hg@0
   123
franta-hg@0
   124
CREATE VIEW postfix_uzivatel AS
franta-hg@0
   125
    SELECT ((((uzivatel.domena)::text || '/'::text) || (uzivatel.login)::text) || '/Maildir/'::text) AS cesta, uzivatel.login, uzivatel.domena FROM uzivatel;
franta-hg@0
   126
franta-hg@0
   127
franta-hg@0
   128
--
franta-hg@0
   129
-- TOC entry 1795 (class 2606 OID 16557)
franta-hg@0
   130
-- Dependencies: 1515 1515 1515 1515
franta-hg@0
   131
-- Name: aliasy_pk; Type: CONSTRAINT; Schema: posta; Owner: -; Tablespace: 
franta-hg@0
   132
--
franta-hg@0
   133
franta-hg@0
   134
ALTER TABLE ONLY alias
franta-hg@0
   135
    ADD CONSTRAINT aliasy_pk PRIMARY KEY (login, domena, cilova_adresa);
franta-hg@0
   136
franta-hg@0
   137
franta-hg@0
   138
--
franta-hg@0
   139
-- TOC entry 1791 (class 2606 OID 16400)
franta-hg@0
   140
-- Dependencies: 1502 1502
franta-hg@0
   141
-- Name: domena_pk; Type: CONSTRAINT; Schema: posta; Owner: -; Tablespace: 
franta-hg@0
   142
--
franta-hg@0
   143
franta-hg@0
   144
ALTER TABLE ONLY domena
franta-hg@0
   145
    ADD CONSTRAINT domena_pk PRIMARY KEY (domena);
franta-hg@0
   146
franta-hg@0
   147
franta-hg@0
   148
--
franta-hg@0
   149
-- TOC entry 1793 (class 2606 OID 16416)
franta-hg@0
   150
-- Dependencies: 1503 1503 1503
franta-hg@0
   151
-- Name: uzivatel_pk; Type: CONSTRAINT; Schema: posta; Owner: -; Tablespace: 
franta-hg@0
   152
--
franta-hg@0
   153
franta-hg@0
   154
ALTER TABLE ONLY uzivatel
franta-hg@0
   155
    ADD CONSTRAINT uzivatel_pk PRIMARY KEY (login, domena);
franta-hg@0
   156
franta-hg@0
   157
franta-hg@0
   158
--
franta-hg@0
   159
-- TOC entry 1797 (class 2606 OID 16558)
franta-hg@0
   160
-- Dependencies: 1790 1515 1502
franta-hg@0
   161
-- Name: alias_domena_fk; Type: FK CONSTRAINT; Schema: posta; Owner: -
franta-hg@0
   162
--
franta-hg@0
   163
franta-hg@0
   164
ALTER TABLE ONLY alias
franta-hg@0
   165
    ADD CONSTRAINT alias_domena_fk FOREIGN KEY (domena) REFERENCES domena(domena);
franta-hg@0
   166
franta-hg@0
   167
franta-hg@0
   168
--
franta-hg@0
   169
-- TOC entry 1796 (class 2606 OID 16417)
franta-hg@0
   170
-- Dependencies: 1503 1502 1790
franta-hg@0
   171
-- Name: uzivatel_domena_fk; Type: FK CONSTRAINT; Schema: posta; Owner: -
franta-hg@0
   172
--
franta-hg@0
   173
franta-hg@0
   174
ALTER TABLE ONLY uzivatel
franta-hg@0
   175
    ADD CONSTRAINT uzivatel_domena_fk FOREIGN KEY (domena) REFERENCES domena(domena);
franta-hg@0
   176
franta-hg@0
   177
franta-hg@0
   178
--
franta-hg@0
   179
-- TOC entry 1800 (class 0 OID 0)
franta-hg@0
   180
-- Dependencies: 6
franta-hg@0
   181
-- Name: posta; Type: ACL; Schema: -; Owner: -
franta-hg@0
   182
--
franta-hg@0
   183
franta-hg@0
   184
REVOKE ALL ON SCHEMA posta FROM PUBLIC;
franta-hg@0
   185
REVOKE ALL ON SCHEMA posta FROM posta;
franta-hg@0
   186
GRANT ALL ON SCHEMA posta TO posta;
franta-hg@0
   187
GRANT USAGE ON SCHEMA posta TO posta_cteni;
franta-hg@0
   188
franta-hg@0
   189
franta-hg@0
   190
--
franta-hg@0
   191
-- TOC entry 1802 (class 0 OID 0)
franta-hg@0
   192
-- Dependencies: 1515
franta-hg@0
   193
-- Name: alias; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   194
--
franta-hg@0
   195
franta-hg@0
   196
REVOKE ALL ON TABLE alias FROM PUBLIC;
franta-hg@0
   197
REVOKE ALL ON TABLE alias FROM posta;
franta-hg@0
   198
GRANT ALL ON TABLE alias TO posta;
franta-hg@0
   199
franta-hg@0
   200
franta-hg@0
   201
--
franta-hg@0
   202
-- TOC entry 1803 (class 0 OID 0)
franta-hg@0
   203
-- Dependencies: 1502
franta-hg@0
   204
-- Name: domena; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   205
--
franta-hg@0
   206
franta-hg@0
   207
REVOKE ALL ON TABLE domena FROM PUBLIC;
franta-hg@0
   208
REVOKE ALL ON TABLE domena FROM posta;
franta-hg@0
   209
GRANT ALL ON TABLE domena TO posta;
franta-hg@0
   210
GRANT SELECT ON TABLE domena TO posta_cteni;
franta-hg@0
   211
franta-hg@0
   212
franta-hg@0
   213
--
franta-hg@0
   214
-- TOC entry 1804 (class 0 OID 0)
franta-hg@0
   215
-- Dependencies: 1503
franta-hg@0
   216
-- Name: uzivatel; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   217
--
franta-hg@0
   218
franta-hg@0
   219
REVOKE ALL ON TABLE uzivatel FROM PUBLIC;
franta-hg@0
   220
REVOKE ALL ON TABLE uzivatel FROM posta;
franta-hg@0
   221
GRANT ALL ON TABLE uzivatel TO posta;
franta-hg@0
   222
GRANT SELECT ON TABLE uzivatel TO posta_cteni;
franta-hg@0
   223
franta-hg@0
   224
franta-hg@0
   225
--
franta-hg@0
   226
-- TOC entry 1805 (class 0 OID 0)
franta-hg@0
   227
-- Dependencies: 1517
franta-hg@0
   228
-- Name: dovecot_heslo; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   229
--
franta-hg@0
   230
franta-hg@0
   231
REVOKE ALL ON TABLE dovecot_heslo FROM PUBLIC;
franta-hg@0
   232
REVOKE ALL ON TABLE dovecot_heslo FROM posta;
franta-hg@0
   233
GRANT ALL ON TABLE dovecot_heslo TO posta;
franta-hg@0
   234
GRANT SELECT ON TABLE dovecot_heslo TO posta_cteni;
franta-hg@0
   235
franta-hg@0
   236
franta-hg@0
   237
--
franta-hg@0
   238
-- TOC entry 1806 (class 0 OID 0)
franta-hg@0
   239
-- Dependencies: 1519
franta-hg@0
   240
-- Name: dovecot_uzivatel; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   241
--
franta-hg@0
   242
franta-hg@0
   243
REVOKE ALL ON TABLE dovecot_uzivatel FROM PUBLIC;
franta-hg@0
   244
REVOKE ALL ON TABLE dovecot_uzivatel FROM posta;
franta-hg@0
   245
GRANT ALL ON TABLE dovecot_uzivatel TO posta;
franta-hg@0
   246
GRANT SELECT ON TABLE dovecot_uzivatel TO posta_cteni;
franta-hg@0
   247
franta-hg@0
   248
franta-hg@0
   249
--
franta-hg@0
   250
-- TOC entry 1807 (class 0 OID 0)
franta-hg@0
   251
-- Dependencies: 1516
franta-hg@0
   252
-- Name: postfix_alias; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   253
--
franta-hg@0
   254
franta-hg@0
   255
REVOKE ALL ON TABLE postfix_alias FROM PUBLIC;
franta-hg@0
   256
REVOKE ALL ON TABLE postfix_alias FROM posta;
franta-hg@0
   257
GRANT ALL ON TABLE postfix_alias TO posta;
franta-hg@0
   258
GRANT SELECT ON TABLE postfix_alias TO posta_cteni;
franta-hg@0
   259
franta-hg@0
   260
franta-hg@0
   261
--
franta-hg@0
   262
-- TOC entry 1808 (class 0 OID 0)
franta-hg@0
   263
-- Dependencies: 1518
franta-hg@0
   264
-- Name: postfix_uzivatel; Type: ACL; Schema: posta; Owner: -
franta-hg@0
   265
--
franta-hg@0
   266
franta-hg@0
   267
REVOKE ALL ON TABLE postfix_uzivatel FROM PUBLIC;
franta-hg@0
   268
REVOKE ALL ON TABLE postfix_uzivatel FROM posta;
franta-hg@0
   269
GRANT ALL ON TABLE postfix_uzivatel TO posta;
franta-hg@0
   270
GRANT SELECT ON TABLE postfix_uzivatel TO posta_cteni;
franta-hg@0
   271
franta-hg@0
   272
franta-hg@0
   273
-- Completed on 2009-05-05 16:25:18 CEST
franta-hg@0
   274
franta-hg@0
   275
--
franta-hg@0
   276
-- PostgreSQL database dump complete
franta-hg@0
   277
--
franta-hg@0
   278