epic-s6ts
[kivitendo-erp.git] / sql / auth_db.sql
1 CREATE SCHEMA auth;
2
3 CREATE SEQUENCE auth.user_id_seq;
4 CREATE SEQUENCE auth.group_id_seq;
5
6 CREATE TABLE auth."user" (
7   id integer NOT NULL DEFAULT nextval('auth.user_id_seq'),
8   login text UNIQUE NOT NULL,
9   password text,
10
11   PRIMARY KEY (id)
12 );
13
14 CREATE TABLE auth."group" (
15   id integer NOT NULL DEFAULT nextval('auth.group_id_seq'),
16   name text UNIQUE NOT NULL,
17   description text,
18
19   PRIMARY KEY (id)
20 );
21
22 CREATE TABLE auth.user_group (
23   user_id integer NOT NULL,
24   group_id integer NOT NULL,
25
26   FOREIGN KEY (user_id) REFERENCES auth."user" (id),
27   FOREIGN KEY (group_id) REFERENCES auth."group" (id)
28 );
29
30 CREATE TABLE auth.group_rights (
31   group_id integer NOT NULL,
32   "right" text NOT NULL,
33   granted boolean NOT NULL,
34
35   FOREIGN KEY (group_id) REFERENCES auth."group" (id)
36 );
37
38 CREATE TABLE auth.user_config (
39   user_id integer NOT NULL,
40   cfg_key text NOT NULL,
41   cfg_value text,
42
43   FOREIGN KEY (user_id) REFERENCES auth."user" (id)
44 );
45
46 CREATE TABLE auth.schema_info (
47   tag text,
48   login text,
49   itime timestamp DEFAULT now(),
50   PRIMARY KEY (tag)
51 );
52
53 CREATE TABLE auth.session (
54   id text,
55   ip_address inet,
56   mtime timestamp,
57
58   PRIMARY KEY (id)
59 );
60
61 CREATE TABLE auth.session_content (
62   session_id text,
63   sess_key text,
64   sess_value text,
65
66   FOREIGN KEY (session_id) REFERENCES auth.session (id)
67 );