sql/schéma.sql
author František Kučera <franta-hg@frantovo.cz>
Tue Jun 08 13:29:13 2010 +0200 (2010-06-08)
changeset 133 2acdbc74bc24
parent 115 b278b6b2d552
child 137 5a7a24ac3a15
permissions -rw-r--r--
zalamování řádků
franta-hg@18
     1
--
franta-hg@18
     2
-- PostgreSQL database dump
franta-hg@18
     3
--
franta-hg@18
     4
franta-hg@118
     5
-- Started on 2010-04-29 14:41:40 CEST
franta-hg@18
     6
franta-hg@18
     7
SET statement_timeout = 0;
franta-hg@18
     8
SET client_encoding = 'UTF8';
franta-hg@18
     9
SET standard_conforming_strings = off;
franta-hg@18
    10
SET check_function_bodies = false;
franta-hg@18
    11
SET client_min_messages = warning;
franta-hg@18
    12
SET escape_string_warning = off;
franta-hg@18
    13
franta-hg@18
    14
--
franta-hg@18
    15
-- TOC entry 10 (class 2615 OID 35015)
franta-hg@18
    16
-- Name: nekurak; Type: SCHEMA; Schema: -; Owner: nekurak
franta-hg@18
    17
--
franta-hg@18
    18
franta-hg@18
    19
CREATE SCHEMA nekurak;
franta-hg@18
    20
franta-hg@18
    21
franta-hg@18
    22
ALTER SCHEMA nekurak OWNER TO nekurak;
franta-hg@18
    23
franta-hg@18
    24
SET search_path = nekurak, pg_catalog;
franta-hg@18
    25
franta-hg@18
    26
--
franta-hg@115
    27
-- TOC entry 366 (class 1247 OID 35086)
franta-hg@115
    28
-- Dependencies: 367 10
franta-hg@62
    29
-- Name: email; Type: DOMAIN; Schema: nekurak; Owner: nekurak
franta-hg@62
    30
--
franta-hg@62
    31
franta-hg@62
    32
CREATE DOMAIN email AS character varying(255)
franta-hg@62
    33
	CONSTRAINT email_regexp CHECK (((VALUE)::text ~ '^[_a-zA-Z0-9\\.\\-]+@[_a-zA-Z0-9\\.\\-]+\\.[a-zA-Z]{2,4}$'::text));
franta-hg@62
    34
franta-hg@62
    35
franta-hg@62
    36
ALTER DOMAIN nekurak.email OWNER TO nekurak;
franta-hg@62
    37
franta-hg@62
    38
--
franta-hg@118
    39
-- TOC entry 1914 (class 0 OID 0)
franta-hg@115
    40
-- Dependencies: 366
franta-hg@62
    41
-- Name: DOMAIN email; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@62
    42
--
franta-hg@62
    43
franta-hg@62
    44
COMMENT ON DOMAIN email IS 'e-mailová adresa';
franta-hg@62
    45
franta-hg@62
    46
franta-hg@62
    47
--
franta-hg@62
    48
-- TOC entry 65 (class 1255 OID 35124)
franta-hg@118
    49
-- Dependencies: 10 402
franta-hg@62
    50
-- Name: bezny_uzivatel(); Type: FUNCTION; Schema: nekurak; Owner: nekurak
franta-hg@62
    51
--
franta-hg@62
    52
franta-hg@62
    53
CREATE FUNCTION bezny_uzivatel() RETURNS trigger
franta-hg@62
    54
    LANGUAGE plpgsql
franta-hg@62
    55
    AS $$BEGIN
franta-hg@62
    56
INSERT INTO uzivatel_role 
franta-hg@62
    57
(role, prezdivka) 
franta-hg@62
    58
VALUES
franta-hg@62
    59
('bezny', new.prezdivka);
franta-hg@62
    60
RETURN new;
franta-hg@62
    61
END;$$;
franta-hg@62
    62
franta-hg@62
    63
franta-hg@62
    64
ALTER FUNCTION nekurak.bezny_uzivatel() OWNER TO nekurak;
franta-hg@62
    65
franta-hg@62
    66
--
franta-hg@118
    67
-- TOC entry 1915 (class 0 OID 0)
franta-hg@62
    68
-- Dependencies: 65
franta-hg@62
    69
-- Name: FUNCTION bezny_uzivatel(); Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@62
    70
--
franta-hg@62
    71
franta-hg@62
    72
COMMENT ON FUNCTION bezny_uzivatel() IS 'Každému novému uživateli dáme automaticky roli „bezny“.';
franta-hg@62
    73
franta-hg@62
    74
franta-hg@71
    75
--
franta-hg@115
    76
-- TOC entry 1601 (class 1259 OID 35223)
franta-hg@115
    77
-- Dependencies: 10
franta-hg@115
    78
-- Name: clanek_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
franta-hg@115
    79
--
franta-hg@115
    80
franta-hg@115
    81
CREATE SEQUENCE clanek_seq
franta-hg@115
    82
    INCREMENT BY 1
franta-hg@115
    83
    NO MAXVALUE
franta-hg@115
    84
    NO MINVALUE
franta-hg@115
    85
    CACHE 1;
franta-hg@115
    86
franta-hg@115
    87
franta-hg@115
    88
ALTER TABLE nekurak.clanek_seq OWNER TO nekurak;
franta-hg@115
    89
franta-hg@115
    90
SET default_tablespace = '';
franta-hg@115
    91
franta-hg@115
    92
SET default_with_oids = false;
franta-hg@115
    93
franta-hg@115
    94
--
franta-hg@115
    95
-- TOC entry 1600 (class 1259 OID 35205)
franta-hg@115
    96
-- Dependencies: 1882 10
franta-hg@115
    97
-- Name: clanek; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@115
    98
--
franta-hg@115
    99
franta-hg@115
   100
CREATE TABLE clanek (
franta-hg@115
   101
    id integer DEFAULT nextval('clanek_seq'::regclass) NOT NULL,
franta-hg@115
   102
    nadpis character varying(255) NOT NULL,
franta-hg@115
   103
    text text
franta-hg@115
   104
);
franta-hg@115
   105
franta-hg@115
   106
franta-hg@115
   107
ALTER TABLE nekurak.clanek OWNER TO nekurak;
franta-hg@115
   108
franta-hg@115
   109
--
franta-hg@118
   110
-- TOC entry 1917 (class 0 OID 0)
franta-hg@115
   111
-- Dependencies: 1600
franta-hg@115
   112
-- Name: TABLE clanek; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@115
   113
--
franta-hg@115
   114
franta-hg@115
   115
COMMENT ON TABLE clanek IS 'Článek potažmo stránka – nějaký textový obsah, (XúHTML.';
franta-hg@115
   116
franta-hg@115
   117
franta-hg@115
   118
--
franta-hg@115
   119
-- TOC entry 1598 (class 1259 OID 35183)
franta-hg@71
   120
-- Dependencies: 10
franta-hg@71
   121
-- Name: fotka_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
franta-hg@71
   122
--
franta-hg@71
   123
franta-hg@71
   124
CREATE SEQUENCE fotka_seq
franta-hg@71
   125
    START WITH 1
franta-hg@71
   126
    INCREMENT BY 1
franta-hg@71
   127
    NO MAXVALUE
franta-hg@71
   128
    NO MINVALUE
franta-hg@71
   129
    CACHE 1;
franta-hg@71
   130
franta-hg@71
   131
franta-hg@71
   132
ALTER TABLE nekurak.fotka_seq OWNER TO nekurak;
franta-hg@71
   133
franta-hg@71
   134
--
franta-hg@115
   135
-- TOC entry 1599 (class 1259 OID 35185)
franta-hg@115
   136
-- Dependencies: 1880 1881 10
franta-hg@71
   137
-- Name: fotka; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@71
   138
--
franta-hg@71
   139
franta-hg@71
   140
CREATE TABLE fotka (
franta-hg@71
   141
    id integer DEFAULT nextval('fotka_seq'::regclass) NOT NULL,
franta-hg@71
   142
    podnik integer NOT NULL,
franta-hg@71
   143
    popis character varying(255),
franta-hg@71
   144
    poradi integer DEFAULT 0 NOT NULL
franta-hg@71
   145
);
franta-hg@71
   146
franta-hg@71
   147
franta-hg@71
   148
ALTER TABLE nekurak.fotka OWNER TO nekurak;
franta-hg@71
   149
franta-hg@71
   150
--
franta-hg@118
   151
-- TOC entry 1920 (class 0 OID 0)
franta-hg@115
   152
-- Dependencies: 1599
franta-hg@71
   153
-- Name: TABLE fotka; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@71
   154
--
franta-hg@71
   155
franta-hg@71
   156
COMMENT ON TABLE fotka IS 'Fotka podniku.';
franta-hg@71
   157
franta-hg@71
   158
franta-hg@71
   159
--
franta-hg@118
   160
-- TOC entry 1921 (class 0 OID 0)
franta-hg@115
   161
-- Dependencies: 1599
franta-hg@71
   162
-- Name: COLUMN fotka.poradi; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@71
   163
--
franta-hg@71
   164
franta-hg@71
   165
COMMENT ON COLUMN fotka.poradi IS 'Pořadí fotky v rámci daného podniku.';
franta-hg@71
   166
franta-hg@71
   167
franta-hg@115
   168
--
franta-hg@115
   169
-- TOC entry 1603 (class 1259 OID 35250)
franta-hg@115
   170
-- Dependencies: 10
franta-hg@115
   171
-- Name: hlasovani_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
franta-hg@115
   172
--
franta-hg@115
   173
franta-hg@115
   174
CREATE SEQUENCE hlasovani_seq
franta-hg@115
   175
    INCREMENT BY 1
franta-hg@115
   176
    NO MAXVALUE
franta-hg@115
   177
    NO MINVALUE
franta-hg@115
   178
    CACHE 1;
franta-hg@115
   179
franta-hg@115
   180
franta-hg@115
   181
ALTER TABLE nekurak.hlasovani_seq OWNER TO nekurak;
franta-hg@62
   182
franta-hg@62
   183
--
franta-hg@115
   184
-- TOC entry 1604 (class 1259 OID 35278)
franta-hg@115
   185
-- Dependencies: 1883 1884 10
franta-hg@62
   186
-- Name: hlasovani; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   187
--
franta-hg@62
   188
franta-hg@62
   189
CREATE TABLE hlasovani (
franta-hg@115
   190
    id integer DEFAULT nextval('hlasovani_seq'::regclass) NOT NULL,
franta-hg@62
   191
    podnik integer NOT NULL,
franta-hg@62
   192
    hlas boolean NOT NULL,
franta-hg@118
   193
    datum timestamp without time zone DEFAULT now() NOT NULL,
franta-hg@115
   194
    ip_adresa character varying(255) NOT NULL
franta-hg@62
   195
);
franta-hg@62
   196
franta-hg@62
   197
franta-hg@62
   198
ALTER TABLE nekurak.hlasovani OWNER TO nekurak;
franta-hg@62
   199
franta-hg@62
   200
--
franta-hg@118
   201
-- TOC entry 1924 (class 0 OID 0)
franta-hg@115
   202
-- Dependencies: 1604
franta-hg@115
   203
-- Name: COLUMN hlasovani.id; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@115
   204
--
franta-hg@115
   205
franta-hg@115
   206
COMMENT ON COLUMN hlasovani.id IS 'V této tabulce v princupu ID nepotřebujeme,
franta-hg@115
   207
protože nebudeme adresovat konkrétní záznamy (a i kdyby, můžeme použít OID).
franta-hg@115
   208
Ale číselné ID se nám bude hodit pro rychlejší nalezení posledního hlasu od dané IP adresy.';
franta-hg@115
   209
franta-hg@115
   210
franta-hg@115
   211
--
franta-hg@118
   212
-- TOC entry 1925 (class 0 OID 0)
franta-hg@115
   213
-- Dependencies: 1604
franta-hg@62
   214
-- Name: COLUMN hlasovani.hlas; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@62
   215
--
franta-hg@62
   216
franta-hg@62
   217
COMMENT ON COLUMN hlasovani.hlas IS 'Má být tento podnik nekuřácký?
franta-hg@62
   218
true = nekuřácký
franta-hg@62
   219
false = kouření povoleno';
franta-hg@62
   220
franta-hg@62
   221
franta-hg@62
   222
--
franta-hg@115
   223
-- TOC entry 1592 (class 1259 OID 35019)
franta-hg@18
   224
-- Dependencies: 10
franta-hg@18
   225
-- Name: podnik_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
franta-hg@18
   226
--
franta-hg@18
   227
franta-hg@18
   228
CREATE SEQUENCE podnik_seq
franta-hg@18
   229
    INCREMENT BY 1
franta-hg@18
   230
    NO MAXVALUE
franta-hg@18
   231
    NO MINVALUE
franta-hg@18
   232
    CACHE 1;
franta-hg@18
   233
franta-hg@18
   234
franta-hg@18
   235
ALTER TABLE nekurak.podnik_seq OWNER TO nekurak;
franta-hg@18
   236
franta-hg@18
   237
--
franta-hg@115
   238
-- TOC entry 1593 (class 1259 OID 35049)
franta-hg@115
   239
-- Dependencies: 1876 1877 10
franta-hg@18
   240
-- Name: podnik; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@18
   241
--
franta-hg@18
   242
franta-hg@18
   243
CREATE TABLE podnik (
franta-hg@18
   244
    id integer DEFAULT nextval('podnik_seq'::regclass) NOT NULL,
franta-hg@18
   245
    nazev character varying(255) NOT NULL,
franta-hg@62
   246
    popis character varying(255),
franta-hg@62
   247
    url character varying(255),
franta-hg@62
   248
    datum timestamp with time zone DEFAULT now(),
franta-hg@62
   249
    ulice character varying(64),
franta-hg@62
   250
    cislo_popisne integer,
franta-hg@71
   251
    mesto character varying(64),
franta-hg@115
   252
    spravce character varying(64),
franta-hg@115
   253
    sirka double precision,
franta-hg@115
   254
    delka double precision
franta-hg@18
   255
);
franta-hg@18
   256
franta-hg@18
   257
franta-hg@18
   258
ALTER TABLE nekurak.podnik OWNER TO nekurak;
franta-hg@18
   259
franta-hg@18
   260
--
franta-hg@118
   261
-- TOC entry 1928 (class 0 OID 0)
franta-hg@115
   262
-- Dependencies: 1593
franta-hg@71
   263
-- Name: COLUMN podnik.spravce; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@71
   264
--
franta-hg@71
   265
franta-hg@71
   266
COMMENT ON COLUMN podnik.spravce IS 'Přezdívka uživatele, který je správcem tohoto podniku (zadal ho do systému nebo správcovství později dostal)';
franta-hg@71
   267
franta-hg@71
   268
franta-hg@71
   269
--
franta-hg@115
   270
-- TOC entry 1596 (class 1259 OID 35101)
franta-hg@62
   271
-- Dependencies: 10
franta-hg@62
   272
-- Name: role; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@18
   273
--
franta-hg@18
   274
franta-hg@62
   275
CREATE TABLE role (
franta-hg@62
   276
    kod character varying(16) NOT NULL,
franta-hg@62
   277
    popis character varying(255)
franta-hg@62
   278
);
franta-hg@18
   279
franta-hg@18
   280
franta-hg@62
   281
ALTER TABLE nekurak.role OWNER TO nekurak;
franta-hg@62
   282
franta-hg@18
   283
--
franta-hg@118
   284
-- TOC entry 1930 (class 0 OID 0)
franta-hg@115
   285
-- Dependencies: 1596
franta-hg@62
   286
-- Name: TABLE role; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@62
   287
--
franta-hg@62
   288
franta-hg@62
   289
COMMENT ON TABLE role IS 'Role (skupiny) uživatelů ~ oprávnění';
franta-hg@62
   290
franta-hg@62
   291
franta-hg@62
   292
--
franta-hg@115
   293
-- TOC entry 1594 (class 1259 OID 35080)
franta-hg@62
   294
-- Dependencies: 10
franta-hg@62
   295
-- Name: uzivatel_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
franta-hg@62
   296
--
franta-hg@62
   297
franta-hg@62
   298
CREATE SEQUENCE uzivatel_seq
franta-hg@62
   299
    INCREMENT BY 1
franta-hg@62
   300
    NO MAXVALUE
franta-hg@62
   301
    NO MINVALUE
franta-hg@62
   302
    CACHE 1;
franta-hg@62
   303
franta-hg@62
   304
franta-hg@62
   305
ALTER TABLE nekurak.uzivatel_seq OWNER TO nekurak;
franta-hg@62
   306
franta-hg@62
   307
--
franta-hg@115
   308
-- TOC entry 1595 (class 1259 OID 35091)
franta-hg@115
   309
-- Dependencies: 1878 1879 10
franta-hg@62
   310
-- Name: uzivatel; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   311
--
franta-hg@62
   312
franta-hg@62
   313
CREATE TABLE uzivatel (
franta-hg@62
   314
    id integer DEFAULT nextval('uzivatel_seq'::regclass) NOT NULL,
franta-hg@62
   315
    prezdivka character varying(64) NOT NULL,
franta-hg@62
   316
    heslo character varying(512) NOT NULL,
franta-hg@62
   317
    jmeno character varying(64),
franta-hg@62
   318
    prijmeni character varying(64),
franta-hg@62
   319
    email character varying(255),
franta-hg@62
   320
    datum timestamp with time zone DEFAULT now() NOT NULL
franta-hg@62
   321
);
franta-hg@62
   322
franta-hg@62
   323
franta-hg@62
   324
ALTER TABLE nekurak.uzivatel OWNER TO nekurak;
franta-hg@62
   325
franta-hg@62
   326
--
franta-hg@118
   327
-- TOC entry 1933 (class 0 OID 0)
franta-hg@115
   328
-- Dependencies: 1595
franta-hg@62
   329
-- Name: COLUMN uzivatel.prezdivka; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@62
   330
--
franta-hg@62
   331
franta-hg@62
   332
COMMENT ON COLUMN uzivatel.prezdivka IS 'Uživatelské jméno';
franta-hg@62
   333
franta-hg@62
   334
franta-hg@62
   335
--
franta-hg@115
   336
-- TOC entry 1597 (class 1259 OID 35106)
franta-hg@62
   337
-- Dependencies: 10
franta-hg@62
   338
-- Name: uzivatel_role; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   339
--
franta-hg@62
   340
franta-hg@62
   341
CREATE TABLE uzivatel_role (
franta-hg@62
   342
    role character varying(16) NOT NULL,
franta-hg@62
   343
    prezdivka character varying(64) NOT NULL
franta-hg@62
   344
);
franta-hg@62
   345
franta-hg@62
   346
franta-hg@62
   347
ALTER TABLE nekurak.uzivatel_role OWNER TO nekurak;
franta-hg@62
   348
franta-hg@62
   349
--
franta-hg@118
   350
-- TOC entry 1935 (class 0 OID 0)
franta-hg@115
   351
-- Dependencies: 1597
franta-hg@62
   352
-- Name: TABLE uzivatel_role; Type: COMMENT; Schema: nekurak; Owner: nekurak
franta-hg@62
   353
--
franta-hg@62
   354
franta-hg@62
   355
COMMENT ON TABLE uzivatel_role IS 'Přiřazení uživatelských rolí (skupin).';
franta-hg@62
   356
franta-hg@62
   357
franta-hg@62
   358
--
franta-hg@115
   359
-- TOC entry 1900 (class 2606 OID 35227)
franta-hg@115
   360
-- Dependencies: 1600 1600
franta-hg@115
   361
-- Name: clanek_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@115
   362
--
franta-hg@115
   363
franta-hg@115
   364
ALTER TABLE ONLY clanek
franta-hg@115
   365
    ADD CONSTRAINT clanek_pk PRIMARY KEY (id);
franta-hg@115
   366
franta-hg@115
   367
franta-hg@115
   368
--
franta-hg@115
   369
-- TOC entry 1896 (class 2606 OID 35190)
franta-hg@115
   370
-- Dependencies: 1599 1599
franta-hg@71
   371
-- Name: fotka_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@71
   372
--
franta-hg@71
   373
franta-hg@71
   374
ALTER TABLE ONLY fotka
franta-hg@71
   375
    ADD CONSTRAINT fotka_pk PRIMARY KEY (id);
franta-hg@71
   376
franta-hg@71
   377
franta-hg@71
   378
--
franta-hg@115
   379
-- TOC entry 1898 (class 2606 OID 35204)
franta-hg@115
   380
-- Dependencies: 1599 1599 1599
franta-hg@72
   381
-- Name: fotka_poradi_uq; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@72
   382
--
franta-hg@72
   383
franta-hg@72
   384
ALTER TABLE ONLY fotka
franta-hg@72
   385
    ADD CONSTRAINT fotka_poradi_uq UNIQUE (popis, poradi);
franta-hg@72
   386
franta-hg@72
   387
franta-hg@72
   388
--
franta-hg@115
   389
-- TOC entry 1903 (class 2606 OID 35284)
franta-hg@115
   390
-- Dependencies: 1604 1604
franta-hg@115
   391
-- Name: hlasovani_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@115
   392
--
franta-hg@115
   393
franta-hg@115
   394
ALTER TABLE ONLY hlasovani
franta-hg@115
   395
    ADD CONSTRAINT hlasovani_pk PRIMARY KEY (id);
franta-hg@115
   396
franta-hg@115
   397
franta-hg@115
   398
--
franta-hg@115
   399
-- TOC entry 1886 (class 2606 OID 35058)
franta-hg@115
   400
-- Dependencies: 1593 1593
franta-hg@18
   401
-- Name: podnik_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@18
   402
--
franta-hg@18
   403
franta-hg@18
   404
ALTER TABLE ONLY podnik
franta-hg@18
   405
    ADD CONSTRAINT podnik_pk PRIMARY KEY (id);
franta-hg@18
   406
franta-hg@18
   407
franta-hg@19
   408
--
franta-hg@115
   409
-- TOC entry 1892 (class 2606 OID 35105)
franta-hg@115
   410
-- Dependencies: 1596 1596
franta-hg@62
   411
-- Name: skupina_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   412
--
franta-hg@62
   413
franta-hg@62
   414
ALTER TABLE ONLY role
franta-hg@62
   415
    ADD CONSTRAINT skupina_pk PRIMARY KEY (kod);
franta-hg@62
   416
franta-hg@62
   417
franta-hg@62
   418
--
franta-hg@115
   419
-- TOC entry 1888 (class 2606 OID 35098)
franta-hg@115
   420
-- Dependencies: 1595 1595
franta-hg@62
   421
-- Name: uzivatel_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   422
--
franta-hg@62
   423
franta-hg@62
   424
ALTER TABLE ONLY uzivatel
franta-hg@62
   425
    ADD CONSTRAINT uzivatel_pk PRIMARY KEY (id);
franta-hg@62
   426
franta-hg@62
   427
franta-hg@62
   428
--
franta-hg@115
   429
-- TOC entry 1890 (class 2606 OID 35100)
franta-hg@115
   430
-- Dependencies: 1595 1595
franta-hg@62
   431
-- Name: uzivatel_prezdivka_uq; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   432
--
franta-hg@62
   433
franta-hg@62
   434
ALTER TABLE ONLY uzivatel
franta-hg@62
   435
    ADD CONSTRAINT uzivatel_prezdivka_uq UNIQUE (prezdivka);
franta-hg@62
   436
franta-hg@62
   437
franta-hg@62
   438
--
franta-hg@115
   439
-- TOC entry 1894 (class 2606 OID 35137)
franta-hg@115
   440
-- Dependencies: 1597 1597 1597
franta-hg@62
   441
-- Name: uzivatel_role_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@62
   442
--
franta-hg@62
   443
franta-hg@62
   444
ALTER TABLE ONLY uzivatel_role
franta-hg@62
   445
    ADD CONSTRAINT uzivatel_role_pk PRIMARY KEY (role, prezdivka);
franta-hg@62
   446
franta-hg@62
   447
franta-hg@62
   448
--
franta-hg@115
   449
-- TOC entry 1901 (class 1259 OID 35291)
franta-hg@115
   450
-- Dependencies: 1604
franta-hg@115
   451
-- Name: hlasovani_ip_idx; Type: INDEX; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@115
   452
--
franta-hg@115
   453
franta-hg@115
   454
CREATE INDEX hlasovani_ip_idx ON hlasovani USING btree (ip_adresa);
franta-hg@115
   455
franta-hg@115
   456
franta-hg@115
   457
--
franta-hg@118
   458
-- TOC entry 1904 (class 1259 OID 35309)
franta-hg@118
   459
-- Dependencies: 1604
franta-hg@118
   460
-- Name: hlsovani_datum_idx; Type: INDEX; Schema: nekurak; Owner: nekurak; Tablespace: 
franta-hg@118
   461
--
franta-hg@118
   462
franta-hg@118
   463
CREATE INDEX hlsovani_datum_idx ON hlasovani USING btree (date(datum));
franta-hg@118
   464
franta-hg@118
   465
franta-hg@118
   466
--
franta-hg@118
   467
-- TOC entry 1910 (class 2620 OID 35125)
franta-hg@118
   468
-- Dependencies: 1595 65
franta-hg@62
   469
-- Name: uzivatel_insert; Type: TRIGGER; Schema: nekurak; Owner: nekurak
franta-hg@62
   470
--
franta-hg@62
   471
franta-hg@62
   472
CREATE TRIGGER uzivatel_insert
franta-hg@62
   473
    AFTER INSERT ON uzivatel
franta-hg@62
   474
    FOR EACH ROW
franta-hg@62
   475
    EXECUTE PROCEDURE bezny_uzivatel();
franta-hg@62
   476
franta-hg@62
   477
franta-hg@62
   478
--
franta-hg@118
   479
-- TOC entry 1908 (class 2606 OID 35191)
franta-hg@118
   480
-- Dependencies: 1599 1885 1593
franta-hg@71
   481
-- Name: fotka_podnik_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
franta-hg@71
   482
--
franta-hg@71
   483
franta-hg@71
   484
ALTER TABLE ONLY fotka
franta-hg@71
   485
    ADD CONSTRAINT fotka_podnik_fk FOREIGN KEY (podnik) REFERENCES podnik(id) ON DELETE CASCADE;
franta-hg@71
   486
franta-hg@71
   487
franta-hg@71
   488
--
franta-hg@118
   489
-- TOC entry 1909 (class 2606 OID 35285)
franta-hg@115
   490
-- Dependencies: 1885 1604 1593
franta-hg@62
   491
-- Name: hlasovani_podnik_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
franta-hg@62
   492
--
franta-hg@62
   493
franta-hg@62
   494
ALTER TABLE ONLY hlasovani
franta-hg@62
   495
    ADD CONSTRAINT hlasovani_podnik_fk FOREIGN KEY (podnik) REFERENCES podnik(id) ON DELETE CASCADE;
franta-hg@62
   496
franta-hg@62
   497
franta-hg@62
   498
--
franta-hg@118
   499
-- TOC entry 1905 (class 2606 OID 35178)
franta-hg@118
   500
-- Dependencies: 1889 1595 1593
franta-hg@71
   501
-- Name: podnik_uzivatel_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
franta-hg@71
   502
--
franta-hg@71
   503
franta-hg@71
   504
ALTER TABLE ONLY podnik
franta-hg@71
   505
    ADD CONSTRAINT podnik_uzivatel_fk FOREIGN KEY (spravce) REFERENCES uzivatel(prezdivka) ON DELETE SET NULL;
franta-hg@71
   506
franta-hg@71
   507
franta-hg@71
   508
--
franta-hg@118
   509
-- TOC entry 1906 (class 2606 OID 35138)
franta-hg@118
   510
-- Dependencies: 1597 1596 1891
franta-hg@62
   511
-- Name: uzivatel_role_role_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
franta-hg@62
   512
--
franta-hg@62
   513
franta-hg@62
   514
ALTER TABLE ONLY uzivatel_role
franta-hg@62
   515
    ADD CONSTRAINT uzivatel_role_role_fk FOREIGN KEY (role) REFERENCES role(kod) ON UPDATE CASCADE ON DELETE CASCADE;
franta-hg@62
   516
franta-hg@62
   517
franta-hg@62
   518
--
franta-hg@118
   519
-- TOC entry 1907 (class 2606 OID 35143)
franta-hg@118
   520
-- Dependencies: 1597 1889 1595
franta-hg@62
   521
-- Name: uzivatel_role_uzivatel_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
franta-hg@62
   522
--
franta-hg@62
   523
franta-hg@62
   524
ALTER TABLE ONLY uzivatel_role
franta-hg@62
   525
    ADD CONSTRAINT uzivatel_role_uzivatel_fk FOREIGN KEY (prezdivka) REFERENCES uzivatel(prezdivka) ON UPDATE CASCADE ON DELETE CASCADE;
franta-hg@62
   526
franta-hg@62
   527
franta-hg@62
   528
--
franta-hg@118
   529
-- TOC entry 1913 (class 0 OID 0)
franta-hg@19
   530
-- Dependencies: 10
franta-hg@19
   531
-- Name: nekurak; Type: ACL; Schema: -; Owner: nekurak
franta-hg@19
   532
--
franta-hg@19
   533
franta-hg@19
   534
REVOKE ALL ON SCHEMA nekurak FROM PUBLIC;
franta-hg@19
   535
REVOKE ALL ON SCHEMA nekurak FROM nekurak;
franta-hg@19
   536
GRANT ALL ON SCHEMA nekurak TO nekurak;
franta-hg@19
   537
GRANT USAGE ON SCHEMA nekurak TO nekurak_web;
franta-hg@19
   538
franta-hg@19
   539
franta-hg@19
   540
--
franta-hg@118
   541
-- TOC entry 1916 (class 0 OID 0)
franta-hg@115
   542
-- Dependencies: 1601
franta-hg@115
   543
-- Name: clanek_seq; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@115
   544
--
franta-hg@115
   545
franta-hg@115
   546
REVOKE ALL ON SEQUENCE clanek_seq FROM PUBLIC;
franta-hg@115
   547
REVOKE ALL ON SEQUENCE clanek_seq FROM nekurak;
franta-hg@115
   548
GRANT ALL ON SEQUENCE clanek_seq TO nekurak;
franta-hg@115
   549
GRANT USAGE ON SEQUENCE clanek_seq TO nekurak_web;
franta-hg@115
   550
franta-hg@115
   551
franta-hg@115
   552
--
franta-hg@118
   553
-- TOC entry 1918 (class 0 OID 0)
franta-hg@115
   554
-- Dependencies: 1600
franta-hg@115
   555
-- Name: clanek; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@115
   556
--
franta-hg@115
   557
franta-hg@115
   558
REVOKE ALL ON TABLE clanek FROM PUBLIC;
franta-hg@115
   559
REVOKE ALL ON TABLE clanek FROM nekurak;
franta-hg@115
   560
GRANT ALL ON TABLE clanek TO nekurak;
franta-hg@115
   561
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE clanek TO nekurak_web;
franta-hg@115
   562
franta-hg@115
   563
franta-hg@115
   564
--
franta-hg@118
   565
-- TOC entry 1919 (class 0 OID 0)
franta-hg@115
   566
-- Dependencies: 1598
franta-hg@71
   567
-- Name: fotka_seq; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@71
   568
--
franta-hg@71
   569
franta-hg@71
   570
REVOKE ALL ON SEQUENCE fotka_seq FROM PUBLIC;
franta-hg@71
   571
REVOKE ALL ON SEQUENCE fotka_seq FROM nekurak;
franta-hg@71
   572
GRANT ALL ON SEQUENCE fotka_seq TO nekurak;
franta-hg@71
   573
GRANT USAGE ON SEQUENCE fotka_seq TO nekurak_web;
franta-hg@71
   574
franta-hg@71
   575
franta-hg@71
   576
--
franta-hg@118
   577
-- TOC entry 1922 (class 0 OID 0)
franta-hg@115
   578
-- Dependencies: 1599
franta-hg@71
   579
-- Name: fotka; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@71
   580
--
franta-hg@71
   581
franta-hg@71
   582
REVOKE ALL ON TABLE fotka FROM PUBLIC;
franta-hg@71
   583
REVOKE ALL ON TABLE fotka FROM nekurak;
franta-hg@71
   584
GRANT ALL ON TABLE fotka TO nekurak;
franta-hg@71
   585
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE fotka TO nekurak_web;
franta-hg@71
   586
franta-hg@71
   587
franta-hg@71
   588
--
franta-hg@118
   589
-- TOC entry 1923 (class 0 OID 0)
franta-hg@115
   590
-- Dependencies: 1603
franta-hg@115
   591
-- Name: hlasovani_seq; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@115
   592
--
franta-hg@115
   593
franta-hg@115
   594
REVOKE ALL ON SEQUENCE hlasovani_seq FROM PUBLIC;
franta-hg@115
   595
REVOKE ALL ON SEQUENCE hlasovani_seq FROM nekurak;
franta-hg@115
   596
GRANT ALL ON SEQUENCE hlasovani_seq TO nekurak;
franta-hg@115
   597
GRANT USAGE ON SEQUENCE hlasovani_seq TO nekurak_web;
franta-hg@115
   598
franta-hg@115
   599
franta-hg@115
   600
--
franta-hg@118
   601
-- TOC entry 1926 (class 0 OID 0)
franta-hg@115
   602
-- Dependencies: 1604
franta-hg@62
   603
-- Name: hlasovani; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@62
   604
--
franta-hg@62
   605
franta-hg@62
   606
REVOKE ALL ON TABLE hlasovani FROM PUBLIC;
franta-hg@62
   607
REVOKE ALL ON TABLE hlasovani FROM nekurak;
franta-hg@62
   608
GRANT ALL ON TABLE hlasovani TO nekurak;
franta-hg@62
   609
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE hlasovani TO nekurak_web;
franta-hg@62
   610
franta-hg@62
   611
franta-hg@62
   612
--
franta-hg@118
   613
-- TOC entry 1927 (class 0 OID 0)
franta-hg@115
   614
-- Dependencies: 1592
franta-hg@19
   615
-- Name: podnik_seq; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@19
   616
--
franta-hg@19
   617
franta-hg@19
   618
REVOKE ALL ON SEQUENCE podnik_seq FROM PUBLIC;
franta-hg@19
   619
REVOKE ALL ON SEQUENCE podnik_seq FROM nekurak;
franta-hg@19
   620
GRANT ALL ON SEQUENCE podnik_seq TO nekurak;
franta-hg@19
   621
GRANT USAGE ON SEQUENCE podnik_seq TO nekurak_web;
franta-hg@19
   622
franta-hg@19
   623
franta-hg@19
   624
--
franta-hg@118
   625
-- TOC entry 1929 (class 0 OID 0)
franta-hg@115
   626
-- Dependencies: 1593
franta-hg@19
   627
-- Name: podnik; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@19
   628
--
franta-hg@19
   629
franta-hg@19
   630
REVOKE ALL ON TABLE podnik FROM PUBLIC;
franta-hg@19
   631
REVOKE ALL ON TABLE podnik FROM nekurak;
franta-hg@19
   632
GRANT ALL ON TABLE podnik TO nekurak;
franta-hg@19
   633
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE podnik TO nekurak_web;
franta-hg@19
   634
franta-hg@19
   635
franta-hg@62
   636
--
franta-hg@118
   637
-- TOC entry 1931 (class 0 OID 0)
franta-hg@115
   638
-- Dependencies: 1596
franta-hg@62
   639
-- Name: role; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@62
   640
--
franta-hg@62
   641
franta-hg@62
   642
REVOKE ALL ON TABLE role FROM PUBLIC;
franta-hg@62
   643
REVOKE ALL ON TABLE role FROM nekurak;
franta-hg@62
   644
GRANT ALL ON TABLE role TO nekurak;
franta-hg@62
   645
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE role TO nekurak_web;
franta-hg@62
   646
franta-hg@62
   647
franta-hg@62
   648
--
franta-hg@118
   649
-- TOC entry 1932 (class 0 OID 0)
franta-hg@115
   650
-- Dependencies: 1594
franta-hg@62
   651
-- Name: uzivatel_seq; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@62
   652
--
franta-hg@62
   653
franta-hg@62
   654
REVOKE ALL ON SEQUENCE uzivatel_seq FROM PUBLIC;
franta-hg@62
   655
REVOKE ALL ON SEQUENCE uzivatel_seq FROM nekurak;
franta-hg@62
   656
GRANT ALL ON SEQUENCE uzivatel_seq TO nekurak;
franta-hg@62
   657
GRANT USAGE ON SEQUENCE uzivatel_seq TO nekurak_web;
franta-hg@62
   658
franta-hg@62
   659
franta-hg@62
   660
--
franta-hg@118
   661
-- TOC entry 1934 (class 0 OID 0)
franta-hg@115
   662
-- Dependencies: 1595
franta-hg@62
   663
-- Name: uzivatel; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@62
   664
--
franta-hg@62
   665
franta-hg@62
   666
REVOKE ALL ON TABLE uzivatel FROM PUBLIC;
franta-hg@62
   667
REVOKE ALL ON TABLE uzivatel FROM nekurak;
franta-hg@62
   668
GRANT ALL ON TABLE uzivatel TO nekurak;
franta-hg@62
   669
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE uzivatel TO nekurak_web;
franta-hg@62
   670
franta-hg@62
   671
franta-hg@62
   672
--
franta-hg@118
   673
-- TOC entry 1936 (class 0 OID 0)
franta-hg@115
   674
-- Dependencies: 1597
franta-hg@62
   675
-- Name: uzivatel_role; Type: ACL; Schema: nekurak; Owner: nekurak
franta-hg@62
   676
--
franta-hg@62
   677
franta-hg@62
   678
REVOKE ALL ON TABLE uzivatel_role FROM PUBLIC;
franta-hg@62
   679
REVOKE ALL ON TABLE uzivatel_role FROM nekurak;
franta-hg@62
   680
GRANT ALL ON TABLE uzivatel_role TO nekurak;
franta-hg@62
   681
GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE uzivatel_role TO nekurak_web;
franta-hg@62
   682
franta-hg@62
   683
franta-hg@118
   684
-- Completed on 2010-04-29 14:41:42 CEST
franta-hg@18
   685
franta-hg@18
   686
--
franta-hg@18
   687
-- PostgreSQL database dump complete
franta-hg@18
   688
--
franta-hg@18
   689