123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- --
- -- PostgreSQL database dump
- --
- --
- -- Name: sp_lu_get_all_user_permission(integer); Type: FUNCTION; Schema: public; Owner: dev
- --
-
- CREATE FUNCTION sp_lu_get_all_user_permission(_user_id integer, OUT _permisson_name character varying, OUT val boolean) RETURNS SETOF record
- LANGUAGE sql IMMUTABLE SECURITY DEFINER COST 10
- AS $$
- SELECT p.name, sp_lu_get_user_permission(_user_id, p.name) FROM luticate_permissions p ORDER bY p.name
- $$;
-
-
-
- --
- -- Name: sp_lu_get_user_permission(integer, character varying); Type: FUNCTION; Schema: public; Owner: dev
- --
-
- CREATE FUNCTION sp_lu_get_user_permission(_user_id integer, _permisson_name character varying, OUT val boolean) RETURNS boolean
- LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER COST 10
- AS $$
- DECLARE
- groups int[];
- g INT;
- BEGIN
- SELECT "value" INTO val FROM luticate_permissions_users WHERE "user_id" = _user_id AND "name" = _permisson_name;
- IF val is null THEN
- SELECT lpg."value" into val FROM luticate_permissions_groups lpg
- INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
- INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
- WHERE lpg."name" = _permisson_name and lpg."value" = FALSE;
- IF val is null then
- SELECT lpg."value" into val FROM luticate_permissions_groups lpg
- INNER JOIN luticate_groups lg ON lg."id" = lpg."group_id"
- INNER JOIN luticate_users_groups lug ON lug."user_id" = _user_id AND lug."group_id" = lg."id"
- WHERE lpg."name" = _permisson_name and lpg."value" = TRUE;
- IF val is null then
- SELECT "value" INTO val FROM luticate_permissions WHERE "name" = _permisson_name;
- END IF;
- end if;
- END IF;
- END;
- $$;
-
- --
- -- Name: luticate_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
- --
-
- CREATE SEQUENCE luticate_groups_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
- SET default_tablespace = '';
-
- SET default_with_oids = false;
-
- --
- -- Name: luticate_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
- --
-
- CREATE TABLE luticate_groups (
- id integer DEFAULT nextval('luticate_groups_id_seq'::regclass) NOT NULL,
- name character varying NOT NULL
- );
-
-
-
- --
- -- Name: luticate_permissions; Type: TABLE; Schema: public; Owner: dev; Tablespace:
- --
-
- CREATE TABLE luticate_permissions (
- name character varying(128) NOT NULL,
- value boolean NOT NULL
- );
-
-
-
- --
- -- Name: luticate_permissions_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
- --
-
- CREATE TABLE luticate_permissions_groups (
- name character varying(128) NOT NULL,
- value boolean NOT NULL,
- group_id integer NOT NULL
- );
-
-
-
- --
- -- Name: luticate_permissions_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
- --
-
- CREATE TABLE luticate_permissions_users (
- name character varying(128) NOT NULL,
- value boolean,
- user_id integer NOT NULL
- );
-
-
-
- --
- -- Name: luticate_users_id_seq; Type: SEQUENCE; Schema: public; Owner: dev
- --
-
- CREATE SEQUENCE luticate_users_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
-
- --
- -- Name: luticate_users; Type: TABLE; Schema: public; Owner: dev; Tablespace:
- --
-
- CREATE TABLE luticate_users (
- id integer DEFAULT nextval('luticate_users_id_seq'::regclass) NOT NULL,
- username character varying(255) NOT NULL,
- email character varying(255) NOT NULL,
- password character varying(255) NOT NULL,
- salt character varying(10) NOT NULL,
- profile_id integer,
- firstname character varying(255) NOT NULL,
- lastname character varying(255) NOT NULL
- );
-
-
-
- --
- -- Name: luticate_users_groups; Type: TABLE; Schema: public; Owner: dev; Tablespace:
- --
-
- CREATE TABLE luticate_users_groups (
- user_id integer NOT NULL,
- group_id integer NOT NULL
- );
-
-
- --
- -- Name: luticate_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_groups
- ADD CONSTRAINT luticate_groups_name_key UNIQUE (name);
-
-
- --
- -- Name: luticate_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_groups
- ADD CONSTRAINT luticate_groups_pkey PRIMARY KEY (id);
-
-
- --
- -- Name: luticate_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_permissions
- ADD CONSTRAINT luticate_permissions_pkey PRIMARY KEY (name);
-
-
- --
- -- Name: luticate_permissions_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_permissions_users
- ADD CONSTRAINT luticate_permissions_users_pkey PRIMARY KEY (name, user_id);
-
-
- --
- -- Name: luticate_users_email_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_users
- ADD CONSTRAINT luticate_users_email_key UNIQUE (email);
-
-
- --
- -- Name: luticate_users_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_users_groups
- ADD CONSTRAINT luticate_users_groups_pkey PRIMARY KEY (user_id, group_id);
-
-
- --
- -- Name: luticate_users_pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_users
- ADD CONSTRAINT luticate_users_pkey PRIMARY KEY (id);
-
-
- --
- -- Name: luticate_users_username_key; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_users
- ADD CONSTRAINT luticate_users_username_key UNIQUE (username);
-
-
- --
- -- Name: pkey; Type: CONSTRAINT; Schema: public; Owner: dev; Tablespace:
- --
-
- ALTER TABLE ONLY luticate_permissions_groups
- ADD CONSTRAINT pkey PRIMARY KEY (name, group_id);
-
-
- --
- -- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
- --
-
- ALTER TABLE ONLY luticate_permissions_groups
- ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
-
-
- --
- -- Name: foreign_group; Type: FK CONSTRAINT; Schema: public; Owner: dev
- --
-
- ALTER TABLE ONLY luticate_users_groups
- ADD CONSTRAINT foreign_group FOREIGN KEY (group_id) REFERENCES luticate_groups(id) ON DELETE CASCADE;
-
-
- --
- -- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: dev
- --
-
- ALTER TABLE ONLY luticate_permissions_groups
- ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
-
-
- --
- -- Name: foreign_name; Type: FK CONSTRAINT; Schema: public; Owner: dev
- --
-
- ALTER TABLE ONLY luticate_permissions_users
- ADD CONSTRAINT foreign_name FOREIGN KEY (name) REFERENCES luticate_permissions(name) ON DELETE CASCADE;
-
-
- --
- -- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
- --
-
- ALTER TABLE ONLY luticate_permissions_users
- ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
-
-
- --
- -- Name: foreign_user; Type: FK CONSTRAINT; Schema: public; Owner: dev
- --
-
- ALTER TABLE ONLY luticate_users_groups
- ADD CONSTRAINT foreign_user FOREIGN KEY (user_id) REFERENCES luticate_users(id) ON DELETE CASCADE;
-
-
- --
- -- PostgreSQL database dump complete
- --
|