create_tables.pgsql
changeset 20 55146c78b3fb
parent 15 1607f7b2dba9
child 29 9653d4f5d97f
equal deleted inserted replaced
19:bf9a03c476fc 20:55146c78b3fb
    51     name        varchar(128) NULL,
    51     name        varchar(128) NULL,
    52     uid         bigint NOT NULL DEFAULT nextval('users_uid'),
    52     uid         bigint NOT NULL DEFAULT nextval('users_uid'),
    53     gid         bigint NOT NULL,
    53     gid         bigint NOT NULL,
    54     mid         bigint NOT NULL DEFAULT 1,
    54     mid         bigint NOT NULL DEFAULT 1,
    55     tid         bigint NOT NULL DEFAULT 1,
    55     tid         bigint NOT NULL DEFAULT 1,
    56     disabled    boolean NOT NULL DEFAULT FALSE,
    56     smpt        boolean NOT NULL DEFAULT TRUE,
       
    57     pop3        boolean NOT NULL DEFAULT TRUE,
       
    58     imap        boolean NOT NULL DEFAULT TRUE,
       
    59     managesieve boolean NOT NULL DEFAULT TRUE,
    57     CONSTRAINT pkye_users PRIMARY KEY (local_part, gid),
    60     CONSTRAINT pkye_users PRIMARY KEY (local_part, gid),
    58     CONSTRAINT ukey_users_uid UNIQUE (uid),
    61     CONSTRAINT ukey_users_uid UNIQUE (uid),
    59     CONSTRAINT fkey_users_gid_domains FOREIGN KEY (gid)
    62     CONSTRAINT fkey_users_gid_domains FOREIGN KEY (gid)
    60         REFERENCES domains (gid),
    63         REFERENCES domains (gid),
    61     CONSTRAINT fkey_users_mid_maillocation FOREIGN KEY (mid)
    64     CONSTRAINT fkey_users_mid_maillocation FOREIGN KEY (mid)
    82         REFERENCES domains (gid)
    85         REFERENCES domains (gid)
    83 );
    86 );
    84 
    87 
    85 CREATE OR REPLACE VIEW dovecot_password AS
    88 CREATE OR REPLACE VIEW dovecot_password AS
    86     SELECT local_part || '@' || domains.domainname AS "user",
    89     SELECT local_part || '@' || domains.domainname AS "user",
    87            passwd AS "password"
    90            passwd AS "password", smtp, pop3, imap, managesieve
    88       FROM users
    91       FROM users
    89            LEFT JOIN domains USING (gid);
    92            LEFT JOIN domains USING (gid);
    90 
    93 
    91 CREATE OR REPLACE VIEW dovecot_user AS
    94 CREATE OR REPLACE VIEW dovecot_user AS
    92     SELECT local_part || '@' || domains.domainname AS userid,
    95     SELECT local_part || '@' || domains.domainname AS userid,