SLQ: aktualizace datového modelu.
2 -- PostgreSQL database dump
5 -- Started on 2010-03-16 14:11:16 CET
7 SET statement_timeout = 0;
8 SET client_encoding = 'UTF8';
9 SET standard_conforming_strings = off;
10 SET check_function_bodies = false;
11 SET client_min_messages = warning;
12 SET escape_string_warning = off;
15 -- TOC entry 10 (class 2615 OID 35015)
16 -- Name: nekurak; Type: SCHEMA; Schema: -; Owner: nekurak
19 CREATE SCHEMA nekurak;
22 ALTER SCHEMA nekurak OWNER TO nekurak;
24 SET search_path = nekurak, pg_catalog;
27 -- TOC entry 368 (class 1247 OID 35086)
28 -- Dependencies: 369 10
29 -- Name: email; Type: DOMAIN; Schema: nekurak; Owner: nekurak
32 CREATE DOMAIN email AS character varying(255)
33 CONSTRAINT email_regexp CHECK (((VALUE)::text ~ '^[_a-zA-Z0-9\\.\\-]+@[_a-zA-Z0-9\\.\\-]+\\.[a-zA-Z]{2,4}$'::text));
36 ALTER DOMAIN nekurak.email OWNER TO nekurak;
39 -- TOC entry 1892 (class 0 OID 0)
41 -- Name: DOMAIN email; Type: COMMENT; Schema: nekurak; Owner: nekurak
44 COMMENT ON DOMAIN email IS 'e-mailová adresa';
48 -- TOC entry 65 (class 1255 OID 35124)
49 -- Dependencies: 395 10
50 -- Name: bezny_uzivatel(); Type: FUNCTION; Schema: nekurak; Owner: nekurak
53 CREATE FUNCTION bezny_uzivatel() RETURNS trigger
56 INSERT INTO uzivatel_role
59 ('bezny', new.prezdivka);
64 ALTER FUNCTION nekurak.bezny_uzivatel() OWNER TO nekurak;
67 -- TOC entry 1893 (class 0 OID 0)
69 -- Name: FUNCTION bezny_uzivatel(); Type: COMMENT; Schema: nekurak; Owner: nekurak
72 COMMENT ON FUNCTION bezny_uzivatel() IS 'Každému novému uživateli dáme automaticky roli „bezny“.';
76 -- TOC entry 1592 (class 1259 OID 35183)
78 -- Name: fotka_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
81 CREATE SEQUENCE fotka_seq
89 ALTER TABLE nekurak.fotka_seq OWNER TO nekurak;
91 SET default_tablespace = '';
93 SET default_with_oids = false;
96 -- TOC entry 1593 (class 1259 OID 35185)
97 -- Dependencies: 1869 1870 10
98 -- Name: fotka; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace:
102 id integer DEFAULT nextval('fotka_seq'::regclass) NOT NULL,
103 podnik integer NOT NULL,
104 popis character varying(255),
105 poradi integer DEFAULT 0 NOT NULL
109 ALTER TABLE nekurak.fotka OWNER TO nekurak;
112 -- TOC entry 1895 (class 0 OID 0)
113 -- Dependencies: 1593
114 -- Name: TABLE fotka; Type: COMMENT; Schema: nekurak; Owner: nekurak
117 COMMENT ON TABLE fotka IS 'Fotka podniku.';
121 -- TOC entry 1896 (class 0 OID 0)
122 -- Dependencies: 1593
123 -- Name: COLUMN fotka.poradi; Type: COMMENT; Schema: nekurak; Owner: nekurak
126 COMMENT ON COLUMN fotka.poradi IS 'Pořadí fotky v rámci daného podniku.';
129 SET default_with_oids = true;
132 -- TOC entry 1587 (class 1259 OID 35068)
133 -- Dependencies: 1866 10
134 -- Name: hlasovani; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace:
137 CREATE TABLE hlasovani (
138 podnik integer NOT NULL,
139 hlas boolean NOT NULL,
140 datum date DEFAULT now() NOT NULL,
141 ip_adresa character varying(255)
145 ALTER TABLE nekurak.hlasovani OWNER TO nekurak;
148 -- TOC entry 1898 (class 0 OID 0)
149 -- Dependencies: 1587
150 -- Name: COLUMN hlasovani.hlas; Type: COMMENT; Schema: nekurak; Owner: nekurak
153 COMMENT ON COLUMN hlasovani.hlas IS 'Má být tento podnik nekuřácký?
155 false = kouření povoleno';
159 -- TOC entry 1585 (class 1259 OID 35019)
161 -- Name: podnik_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
164 CREATE SEQUENCE podnik_seq
171 ALTER TABLE nekurak.podnik_seq OWNER TO nekurak;
173 SET default_with_oids = false;
176 -- TOC entry 1586 (class 1259 OID 35049)
177 -- Dependencies: 1864 1865 10
178 -- Name: podnik; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace:
181 CREATE TABLE podnik (
182 id integer DEFAULT nextval('podnik_seq'::regclass) NOT NULL,
183 nazev character varying(255) NOT NULL,
184 popis character varying(255),
185 url character varying(255),
186 datum timestamp with time zone DEFAULT now(),
187 ulice character varying(64),
188 cislo_popisne integer,
189 mesto character varying(64),
190 spravce character varying(64)
194 ALTER TABLE nekurak.podnik OWNER TO nekurak;
197 -- TOC entry 1901 (class 0 OID 0)
198 -- Dependencies: 1586
199 -- Name: COLUMN podnik.spravce; Type: COMMENT; Schema: nekurak; Owner: nekurak
202 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)';
206 -- TOC entry 1590 (class 1259 OID 35101)
208 -- Name: role; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace:
212 kod character varying(16) NOT NULL,
213 popis character varying(255)
217 ALTER TABLE nekurak.role OWNER TO nekurak;
220 -- TOC entry 1903 (class 0 OID 0)
221 -- Dependencies: 1590
222 -- Name: TABLE role; Type: COMMENT; Schema: nekurak; Owner: nekurak
225 COMMENT ON TABLE role IS 'Role (skupiny) uživatelů ~ oprávnění';
229 -- TOC entry 1588 (class 1259 OID 35080)
231 -- Name: uzivatel_seq; Type: SEQUENCE; Schema: nekurak; Owner: nekurak
234 CREATE SEQUENCE uzivatel_seq
241 ALTER TABLE nekurak.uzivatel_seq OWNER TO nekurak;
244 -- TOC entry 1589 (class 1259 OID 35091)
245 -- Dependencies: 1867 1868 10
246 -- Name: uzivatel; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace:
249 CREATE TABLE uzivatel (
250 id integer DEFAULT nextval('uzivatel_seq'::regclass) NOT NULL,
251 prezdivka character varying(64) NOT NULL,
252 heslo character varying(512) NOT NULL,
253 jmeno character varying(64),
254 prijmeni character varying(64),
255 email character varying(255),
256 datum timestamp with time zone DEFAULT now() NOT NULL
260 ALTER TABLE nekurak.uzivatel OWNER TO nekurak;
263 -- TOC entry 1906 (class 0 OID 0)
264 -- Dependencies: 1589
265 -- Name: COLUMN uzivatel.prezdivka; Type: COMMENT; Schema: nekurak; Owner: nekurak
268 COMMENT ON COLUMN uzivatel.prezdivka IS 'Uživatelské jméno';
272 -- TOC entry 1591 (class 1259 OID 35106)
274 -- Name: uzivatel_role; Type: TABLE; Schema: nekurak; Owner: nekurak; Tablespace:
277 CREATE TABLE uzivatel_role (
278 role character varying(16) NOT NULL,
279 prezdivka character varying(64) NOT NULL
283 ALTER TABLE nekurak.uzivatel_role OWNER TO nekurak;
286 -- TOC entry 1908 (class 0 OID 0)
287 -- Dependencies: 1591
288 -- Name: TABLE uzivatel_role; Type: COMMENT; Schema: nekurak; Owner: nekurak
291 COMMENT ON TABLE uzivatel_role IS 'Přiřazení uživatelských rolí (skupin).';
295 -- TOC entry 1882 (class 2606 OID 35190)
296 -- Dependencies: 1593 1593
297 -- Name: fotka_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace:
300 ALTER TABLE ONLY fotka
301 ADD CONSTRAINT fotka_pk PRIMARY KEY (id);
305 -- TOC entry 1872 (class 2606 OID 35058)
306 -- Dependencies: 1586 1586
307 -- Name: podnik_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace:
310 ALTER TABLE ONLY podnik
311 ADD CONSTRAINT podnik_pk PRIMARY KEY (id);
315 -- TOC entry 1878 (class 2606 OID 35105)
316 -- Dependencies: 1590 1590
317 -- Name: skupina_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace:
320 ALTER TABLE ONLY role
321 ADD CONSTRAINT skupina_pk PRIMARY KEY (kod);
325 -- TOC entry 1874 (class 2606 OID 35098)
326 -- Dependencies: 1589 1589
327 -- Name: uzivatel_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace:
330 ALTER TABLE ONLY uzivatel
331 ADD CONSTRAINT uzivatel_pk PRIMARY KEY (id);
335 -- TOC entry 1876 (class 2606 OID 35100)
336 -- Dependencies: 1589 1589
337 -- Name: uzivatel_prezdivka_uq; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace:
340 ALTER TABLE ONLY uzivatel
341 ADD CONSTRAINT uzivatel_prezdivka_uq UNIQUE (prezdivka);
345 -- TOC entry 1880 (class 2606 OID 35137)
346 -- Dependencies: 1591 1591 1591
347 -- Name: uzivatel_role_pk; Type: CONSTRAINT; Schema: nekurak; Owner: nekurak; Tablespace:
350 ALTER TABLE ONLY uzivatel_role
351 ADD CONSTRAINT uzivatel_role_pk PRIMARY KEY (role, prezdivka);
355 -- TOC entry 1888 (class 2620 OID 35125)
356 -- Dependencies: 65 1589
357 -- Name: uzivatel_insert; Type: TRIGGER; Schema: nekurak; Owner: nekurak
360 CREATE TRIGGER uzivatel_insert
361 AFTER INSERT ON uzivatel
363 EXECUTE PROCEDURE bezny_uzivatel();
367 -- TOC entry 1887 (class 2606 OID 35191)
368 -- Dependencies: 1871 1593 1586
369 -- Name: fotka_podnik_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
372 ALTER TABLE ONLY fotka
373 ADD CONSTRAINT fotka_podnik_fk FOREIGN KEY (podnik) REFERENCES podnik(id) ON DELETE CASCADE;
377 -- TOC entry 1884 (class 2606 OID 35072)
378 -- Dependencies: 1871 1586 1587
379 -- Name: hlasovani_podnik_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
382 ALTER TABLE ONLY hlasovani
383 ADD CONSTRAINT hlasovani_podnik_fk FOREIGN KEY (podnik) REFERENCES podnik(id) ON DELETE CASCADE;
387 -- TOC entry 1883 (class 2606 OID 35178)
388 -- Dependencies: 1875 1589 1586
389 -- Name: podnik_uzivatel_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
392 ALTER TABLE ONLY podnik
393 ADD CONSTRAINT podnik_uzivatel_fk FOREIGN KEY (spravce) REFERENCES uzivatel(prezdivka) ON DELETE SET NULL;
397 -- TOC entry 1885 (class 2606 OID 35138)
398 -- Dependencies: 1590 1591 1877
399 -- Name: uzivatel_role_role_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
402 ALTER TABLE ONLY uzivatel_role
403 ADD CONSTRAINT uzivatel_role_role_fk FOREIGN KEY (role) REFERENCES role(kod) ON UPDATE CASCADE ON DELETE CASCADE;
407 -- TOC entry 1886 (class 2606 OID 35143)
408 -- Dependencies: 1591 1589 1875
409 -- Name: uzivatel_role_uzivatel_fk; Type: FK CONSTRAINT; Schema: nekurak; Owner: nekurak
412 ALTER TABLE ONLY uzivatel_role
413 ADD CONSTRAINT uzivatel_role_uzivatel_fk FOREIGN KEY (prezdivka) REFERENCES uzivatel(prezdivka) ON UPDATE CASCADE ON DELETE CASCADE;
417 -- TOC entry 1891 (class 0 OID 0)
419 -- Name: nekurak; Type: ACL; Schema: -; Owner: nekurak
422 REVOKE ALL ON SCHEMA nekurak FROM PUBLIC;
423 REVOKE ALL ON SCHEMA nekurak FROM nekurak;
424 GRANT ALL ON SCHEMA nekurak TO nekurak;
425 GRANT USAGE ON SCHEMA nekurak TO nekurak_web;
429 -- TOC entry 1894 (class 0 OID 0)
430 -- Dependencies: 1592
431 -- Name: fotka_seq; Type: ACL; Schema: nekurak; Owner: nekurak
434 REVOKE ALL ON SEQUENCE fotka_seq FROM PUBLIC;
435 REVOKE ALL ON SEQUENCE fotka_seq FROM nekurak;
436 GRANT ALL ON SEQUENCE fotka_seq TO nekurak;
437 GRANT USAGE ON SEQUENCE fotka_seq TO nekurak_web;
441 -- TOC entry 1897 (class 0 OID 0)
442 -- Dependencies: 1593
443 -- Name: fotka; Type: ACL; Schema: nekurak; Owner: nekurak
446 REVOKE ALL ON TABLE fotka FROM PUBLIC;
447 REVOKE ALL ON TABLE fotka FROM nekurak;
448 GRANT ALL ON TABLE fotka TO nekurak;
449 GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE fotka TO nekurak_web;
453 -- TOC entry 1899 (class 0 OID 0)
454 -- Dependencies: 1587
455 -- Name: hlasovani; Type: ACL; Schema: nekurak; Owner: nekurak
458 REVOKE ALL ON TABLE hlasovani FROM PUBLIC;
459 REVOKE ALL ON TABLE hlasovani FROM nekurak;
460 GRANT ALL ON TABLE hlasovani TO nekurak;
461 GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE hlasovani TO nekurak_web;
465 -- TOC entry 1900 (class 0 OID 0)
466 -- Dependencies: 1585
467 -- Name: podnik_seq; Type: ACL; Schema: nekurak; Owner: nekurak
470 REVOKE ALL ON SEQUENCE podnik_seq FROM PUBLIC;
471 REVOKE ALL ON SEQUENCE podnik_seq FROM nekurak;
472 GRANT ALL ON SEQUENCE podnik_seq TO nekurak;
473 GRANT USAGE ON SEQUENCE podnik_seq TO nekurak_web;
477 -- TOC entry 1902 (class 0 OID 0)
478 -- Dependencies: 1586
479 -- Name: podnik; Type: ACL; Schema: nekurak; Owner: nekurak
482 REVOKE ALL ON TABLE podnik FROM PUBLIC;
483 REVOKE ALL ON TABLE podnik FROM nekurak;
484 GRANT ALL ON TABLE podnik TO nekurak;
485 GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE podnik TO nekurak_web;
489 -- TOC entry 1904 (class 0 OID 0)
490 -- Dependencies: 1590
491 -- Name: role; Type: ACL; Schema: nekurak; Owner: nekurak
494 REVOKE ALL ON TABLE role FROM PUBLIC;
495 REVOKE ALL ON TABLE role FROM nekurak;
496 GRANT ALL ON TABLE role TO nekurak;
497 GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE role TO nekurak_web;
501 -- TOC entry 1905 (class 0 OID 0)
502 -- Dependencies: 1588
503 -- Name: uzivatel_seq; Type: ACL; Schema: nekurak; Owner: nekurak
506 REVOKE ALL ON SEQUENCE uzivatel_seq FROM PUBLIC;
507 REVOKE ALL ON SEQUENCE uzivatel_seq FROM nekurak;
508 GRANT ALL ON SEQUENCE uzivatel_seq TO nekurak;
509 GRANT USAGE ON SEQUENCE uzivatel_seq TO nekurak_web;
513 -- TOC entry 1907 (class 0 OID 0)
514 -- Dependencies: 1589
515 -- Name: uzivatel; Type: ACL; Schema: nekurak; Owner: nekurak
518 REVOKE ALL ON TABLE uzivatel FROM PUBLIC;
519 REVOKE ALL ON TABLE uzivatel FROM nekurak;
520 GRANT ALL ON TABLE uzivatel TO nekurak;
521 GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE uzivatel TO nekurak_web;
525 -- TOC entry 1909 (class 0 OID 0)
526 -- Dependencies: 1591
527 -- Name: uzivatel_role; Type: ACL; Schema: nekurak; Owner: nekurak
530 REVOKE ALL ON TABLE uzivatel_role FROM PUBLIC;
531 REVOKE ALL ON TABLE uzivatel_role FROM nekurak;
532 GRANT ALL ON TABLE uzivatel_role TO nekurak;
533 GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE uzivatel_role TO nekurak_web;
536 -- Completed on 2010-03-16 14:11:18 CET
539 -- PostgreSQL database dump complete