diff --git a/include/sql/account_repository/comment.sql b/include/sql/account_repository/comment.sql index 38922318e..3a64b5775 100644 --- a/include/sql/account_repository/comment.sql +++ b/include/sql/account_repository/comment.sql @@ -1,11 +1 @@ -COMMENT ON COLUMN ac_dossier.dos_email IS 'Max emails per day : 0 none , -1 unlimited or max value'; -COMMENT ON COLUMN ac_users.use_email IS 'Email of the user'; -COMMENT ON TABLE dossier_sent_email IS 'Count the sent email by folder'; -COMMENT ON COLUMN dossier_sent_email.id IS 'primary key'; -COMMENT ON COLUMN dossier_sent_email.de_date IS 'Date YYYYMMDD'; -COMMENT ON COLUMN dossier_sent_email.de_sent_email IS 'Number of sent emails'; -COMMENT ON COLUMN dossier_sent_email.dos_id IS 'Link to ac_dossier'; -COMMENT ON TABLE user_global_pref IS 'The user''s global parameter '; -COMMENT ON COLUMN user_global_pref.user_id IS 'user''s login '; -COMMENT ON COLUMN user_global_pref.parameter_type IS 'the type of parameter '; -COMMENT ON COLUMN user_global_pref.parameter_value IS 'the value of parameter '; +COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; diff --git a/include/sql/account_repository/constraint.sql b/include/sql/account_repository/constraint.sql index d909222b5..6aa16aa8f 100644 --- a/include/sql/account_repository/constraint.sql +++ b/include/sql/account_repository/constraint.sql @@ -2,44 +2,3 @@ SET check_function_bodies = false; SET client_min_messages = warning; SET search_path = public, pg_catalog; -ALTER TABLE ONLY audit_connect ALTER COLUMN ac_id SET DEFAULT nextval('audit_connect_ac_id_seq'::regclass); -ALTER TABLE ONLY dossier_sent_email ALTER COLUMN id SET DEFAULT nextval('dossier_sent_email_id_seq'::regclass); -ALTER TABLE ONLY ac_dossier - ADD CONSTRAINT ac_dossier_dos_name_key UNIQUE (dos_name); -ALTER TABLE ONLY ac_dossier - ADD CONSTRAINT ac_dossier_pkey PRIMARY KEY (dos_id); -ALTER TABLE ONLY ac_users - ADD CONSTRAINT ac_users_pkey PRIMARY KEY (use_id); -ALTER TABLE ONLY ac_users - ADD CONSTRAINT ac_users_use_login_key UNIQUE (use_login); -ALTER TABLE ONLY audit_connect - ADD CONSTRAINT audit_connect_pkey PRIMARY KEY (ac_id); -ALTER TABLE ONLY dossier_sent_email - ADD CONSTRAINT de_date_dos_id_ux UNIQUE (de_date, dos_id); -ALTER TABLE ONLY dossier_sent_email - ADD CONSTRAINT dossier_sent_email_pkey PRIMARY KEY (id); -ALTER TABLE ONLY jnt_use_dos - ADD CONSTRAINT jnt_use_dos_pkey PRIMARY KEY (jnt_id); -ALTER TABLE ONLY modeledef - ADD CONSTRAINT modeledef_pkey PRIMARY KEY (mod_id); -ALTER TABLE ONLY user_global_pref - ADD CONSTRAINT pk_user_global_pref PRIMARY KEY (user_id, parameter_type); -ALTER TABLE ONLY progress - ADD CONSTRAINT progress_pkey PRIMARY KEY (p_id); -ALTER TABLE ONLY recover_pass - ADD CONSTRAINT recover_pass_pkey PRIMARY KEY (request); -ALTER TABLE ONLY jnt_use_dos - ADD CONSTRAINT use_id_dos_id_uniq UNIQUE (use_id, dos_id); -ALTER TABLE ONLY version - ADD CONSTRAINT version_pkey PRIMARY KEY (val); -ALTER TABLE ONLY recover_pass - ADD CONSTRAINT ac_users_recover_pass_fk FOREIGN KEY (use_id) REFERENCES ac_users(use_id) ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY dossier_sent_email - ADD CONSTRAINT de_ac_dossier_fk FOREIGN KEY (dos_id) REFERENCES ac_dossier(dos_id) ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY user_global_pref - ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES ac_users(use_login) ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY jnt_use_dos - ADD CONSTRAINT jnt_use_dos_dos_id_fkey FOREIGN KEY (dos_id) REFERENCES ac_dossier(dos_id) ON UPDATE CASCADE ON DELETE CASCADE; -ALTER TABLE ONLY jnt_use_dos - ADD CONSTRAINT jnt_use_dos_use_id_fkey FOREIGN KEY (use_id) REFERENCES ac_users(use_id); -CREATE TRIGGER limit_user_trg BEFORE INSERT OR UPDATE ON audit_connect FOR EACH ROW EXECUTE PROCEDURE limit_user(); diff --git a/include/sql/account_repository/data.sql b/include/sql/account_repository/data.sql index c6d336381..35d278bd5 100644 --- a/include/sql/account_repository/data.sql +++ b/include/sql/account_repository/data.sql @@ -1,4 +1,3 @@ -set search_path = public, comptaproc,pg_catalog ; SET statement_timeout = 0; SET client_encoding = 'UTF8'; @@ -7,83 +6,3 @@ SET check_function_bodies = false; SET client_min_messages = warning; - - - - -INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_email) VALUES (1, NULL, NULL, 'admin', 1, 'b1cc88e1907cde80cb2595fa793b3da9', 1, NULL); -INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_email) VALUES (4, 'demo', 'demo', 'demo', 0, 'fe01ce2a7fbac8fafaed7c982a04e229', 0, NULL); - - - - - - -SELECT pg_catalog.setval('audit_connect_ac_id_seq', 3, true); - - - -SELECT pg_catalog.setval('dossier_id', 24, true); - - - - - - -SELECT pg_catalog.setval('dossier_sent_email_id_seq', 1, false); - - - - - - -INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, à adapter'); -INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, '(FR) Basique', 'Comptabilité Française, à adapter'); - - - - - - - - - -SELECT pg_catalog.setval('s_modid', 8, true); - - - -SELECT pg_catalog.setval('seq_jnt_use_dos', 28, true); - - - -SELECT pg_catalog.setval('seq_priv_user', 12, true); - - - -INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Light', 'style-light.css', NULL); -INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Classique', 'style-classic.css', NULL); -INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Classic7', 'style-classic7.css', NULL); - - - -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'PAGESIZE', '50'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'LANG', 'fr_FR.utf8'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'PAGESIZE', '50'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'LANG', 'fr_FR.utf8'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'TOPMENU', 'TEXT'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'THEME', 'Classic7'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'THEME', 'Classic7'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'csv_fieldsep', '0'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'csv_decimal', '0'); -INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'csv_encoding', 'utf8'); - - - -SELECT pg_catalog.setval('users_id', 5, true); - - - -INSERT INTO version (val) VALUES (18); - - - diff --git a/include/sql/account_repository/function.sql b/include/sql/account_repository/function.sql index f45b63985..e69de29bb 100644 --- a/include/sql/account_repository/function.sql +++ b/include/sql/account_repository/function.sql @@ -1,22 +0,0 @@ -CREATE FUNCTION limit_user() RETURNS trigger - LANGUAGE plpgsql - AS $$ - -begin -NEW.ac_user := substring(NEW.ac_user from 1 for 80); -return NEW; -end; $$; -CREATE FUNCTION upgrade_repo(p_version integer) RETURNS void - LANGUAGE plpgsql - AS $$ -declare - is_mono integer; -begin - select count (*) into is_mono from information_schema.tables where table_name='repo_version'; - if is_mono = 1 then - update repo_version set val=p_version; - else - update version set val=p_version; - end if; -end; -$$; diff --git a/include/sql/account_repository/index.sql b/include/sql/account_repository/index.sql index 45898c221..e69de29bb 100644 --- a/include/sql/account_repository/index.sql +++ b/include/sql/account_repository/index.sql @@ -1,4 +0,0 @@ -CREATE INDEX audit_connect_ac_user ON audit_connect USING btree (ac_user); -CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id); -CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id); -CREATE INDEX fki_ac_users_recover_pass_fk ON recover_pass USING btree (use_id); diff --git a/include/sql/account_repository/make-sql b/include/sql/account_repository/make-sql index b661af200..1d097aab2 100755 --- a/include/sql/account_repository/make-sql +++ b/include/sql/account_repository/make-sql @@ -34,7 +34,6 @@ sed -i -e "/REVOKE /d" -e "/GRANT /d" -e "/ALTER TABLE.*/d" -e "/ADD CONSTRAINT/ grep setval schema.sql >> sequence.sql -echo "set search_path = public, comptaproc,pg_catalog ;" > data.sql -pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql +pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" > data.sql diff --git a/include/sql/account_repository/schema.sql b/include/sql/account_repository/schema.sql index b4e2c9acb..867f20f6d 100644 --- a/include/sql/account_repository/schema.sql +++ b/include/sql/account_repository/schema.sql @@ -10,340 +10,7 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - -SET search_path = public, pg_catalog; - - -CREATE FUNCTION limit_user() RETURNS trigger - LANGUAGE plpgsql - AS $$ - -begin -NEW.ac_user := substring(NEW.ac_user from 1 for 80); -return NEW; -end; $$; - - - -CREATE FUNCTION upgrade_repo(p_version integer) RETURNS void - LANGUAGE plpgsql - AS $$ -declare - is_mono integer; -begin - select count (*) into is_mono from information_schema.tables where table_name='repo_version'; - if is_mono = 1 then - update repo_version set val=p_version; - else - update version set val=p_version; - end if; -end; -$$; - - -SET default_tablespace = ''; - -SET default_with_oids = false; - - -CREATE TABLE ac_dossier ( - dos_id integer DEFAULT nextval(('dossier_id'::text)::regclass) NOT NULL, - dos_name text NOT NULL, - dos_description text, - dos_email integer DEFAULT (-1) -); - - - -COMMENT ON COLUMN ac_dossier.dos_email IS 'Max emails per day : 0 none , -1 unlimited or max value'; - - - -CREATE TABLE ac_users ( - use_id integer DEFAULT nextval(('users_id'::text)::regclass) NOT NULL, - use_first_name text, - use_name text, - use_login text NOT NULL, - use_active integer DEFAULT 0, - use_pass text, - use_admin integer DEFAULT 0, - use_email text, - CONSTRAINT ac_users_use_active_check CHECK (((use_active = 0) OR (use_active = 1))) -); - - - -COMMENT ON COLUMN ac_users.use_email IS 'Email of the user'; - - - -CREATE TABLE audit_connect ( - ac_id integer NOT NULL, - ac_user text, - ac_date timestamp without time zone DEFAULT now(), - ac_ip text, - ac_state text, - ac_module text, - ac_url text, - CONSTRAINT valid_state CHECK ((((ac_state = 'FAIL'::text) OR (ac_state = 'SUCCESS'::text)) OR (ac_state = 'AUDIT'::text))) -); - - - -CREATE SEQUENCE audit_connect_ac_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -ALTER SEQUENCE audit_connect_ac_id_seq OWNED BY audit_connect.ac_id; - - - -CREATE SEQUENCE dossier_id - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -CREATE TABLE dossier_sent_email ( - id integer NOT NULL, - de_date character varying(8) NOT NULL, - de_sent_email integer NOT NULL, - dos_id integer NOT NULL -); - - - -COMMENT ON TABLE dossier_sent_email IS 'Count the sent email by folder'; - - - -COMMENT ON COLUMN dossier_sent_email.id IS 'primary key'; - - - -COMMENT ON COLUMN dossier_sent_email.de_date IS 'Date YYYYMMDD'; - - - -COMMENT ON COLUMN dossier_sent_email.de_sent_email IS 'Number of sent emails'; - - - -COMMENT ON COLUMN dossier_sent_email.dos_id IS 'Link to ac_dossier'; - - - -CREATE SEQUENCE dossier_sent_email_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -ALTER SEQUENCE dossier_sent_email_id_seq OWNED BY dossier_sent_email.id; - - - -CREATE TABLE jnt_use_dos ( - jnt_id integer DEFAULT nextval(('seq_jnt_use_dos'::text)::regclass) NOT NULL, - use_id integer NOT NULL, - dos_id integer NOT NULL -); - - - -CREATE TABLE modeledef ( - mod_id integer DEFAULT nextval(('s_modid'::text)::regclass) NOT NULL, - mod_name text NOT NULL, - mod_desc text -); - - - -CREATE TABLE progress ( - p_id character varying(16) NOT NULL, - p_value numeric(5,2) NOT NULL, - p_created timestamp without time zone DEFAULT now() -); - - - -CREATE TABLE recover_pass ( - use_id bigint NOT NULL, - request text NOT NULL, - password text NOT NULL, - created_on timestamp with time zone, - created_host text, - recover_on timestamp with time zone, - recover_by text -); - - - -CREATE SEQUENCE s_modid - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -CREATE SEQUENCE seq_jnt_use_dos - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -CREATE SEQUENCE seq_priv_user - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -CREATE TABLE theme ( - the_name text NOT NULL, - the_filestyle text, - the_filebutton text -); - - - -CREATE TABLE user_global_pref ( - user_id text NOT NULL, - parameter_type text NOT NULL, - parameter_value text -); - - - -COMMENT ON TABLE user_global_pref IS 'The user''s global parameter '; - - - -COMMENT ON COLUMN user_global_pref.user_id IS 'user''s login '; - - - -COMMENT ON COLUMN user_global_pref.parameter_type IS 'the type of parameter '; - - - -COMMENT ON COLUMN user_global_pref.parameter_value IS 'the value of parameter '; - - - -CREATE SEQUENCE users_id - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - - -CREATE TABLE version ( - val integer NOT NULL -); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -CREATE INDEX audit_connect_ac_user ON audit_connect USING btree (ac_user); - - - -CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id); - - - -CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id); - - - -CREATE INDEX fki_ac_users_recover_pass_fk ON recover_pass USING btree (use_id); - - - - - - - - - - - - - - - - - - +COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; diff --git a/include/sql/account_repository/sequence.sql b/include/sql/account_repository/sequence.sql index 32ecd65a5..e69de29bb 100644 --- a/include/sql/account_repository/sequence.sql +++ b/include/sql/account_repository/sequence.sql @@ -1,44 +0,0 @@ -CREATE SEQUENCE audit_connect_ac_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; -ALTER SEQUENCE audit_connect_ac_id_seq OWNED BY audit_connect.ac_id; -CREATE SEQUENCE dossier_id - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; -CREATE SEQUENCE dossier_sent_email_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; -ALTER SEQUENCE dossier_sent_email_id_seq OWNED BY dossier_sent_email.id; -CREATE SEQUENCE s_modid - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; -CREATE SEQUENCE seq_jnt_use_dos - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; -CREATE SEQUENCE seq_priv_user - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; -CREATE SEQUENCE users_id - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; diff --git a/include/sql/account_repository/table.sql b/include/sql/account_repository/table.sql index 59e07421e..e69de29bb 100644 --- a/include/sql/account_repository/table.sql +++ b/include/sql/account_repository/table.sql @@ -1,70 +0,0 @@ -CREATE TABLE ac_dossier ( - dos_id integer DEFAULT nextval(('dossier_id'::text)::regclass) NOT NULL, - dos_name text NOT NULL, - dos_description text, - dos_email integer DEFAULT (-1) -); -CREATE TABLE ac_users ( - use_id integer DEFAULT nextval(('users_id'::text)::regclass) NOT NULL, - use_first_name text, - use_name text, - use_login text NOT NULL, - use_active integer DEFAULT 0, - use_pass text, - use_admin integer DEFAULT 0, - use_email text, - CONSTRAINT ac_users_use_active_check CHECK (((use_active = 0) OR (use_active = 1))) -); -CREATE TABLE audit_connect ( - ac_id integer NOT NULL, - ac_user text, - ac_date timestamp without time zone DEFAULT now(), - ac_ip text, - ac_state text, - ac_module text, - ac_url text, - CONSTRAINT valid_state CHECK ((((ac_state = 'FAIL'::text) OR (ac_state = 'SUCCESS'::text)) OR (ac_state = 'AUDIT'::text))) -); -CREATE TABLE dossier_sent_email ( - id integer NOT NULL, - de_date character varying(8) NOT NULL, - de_sent_email integer NOT NULL, - dos_id integer NOT NULL -); -CREATE TABLE jnt_use_dos ( - jnt_id integer DEFAULT nextval(('seq_jnt_use_dos'::text)::regclass) NOT NULL, - use_id integer NOT NULL, - dos_id integer NOT NULL -); -CREATE TABLE modeledef ( - mod_id integer DEFAULT nextval(('s_modid'::text)::regclass) NOT NULL, - mod_name text NOT NULL, - mod_desc text -); -CREATE TABLE progress ( - p_id character varying(16) NOT NULL, - p_value numeric(5,2) NOT NULL, - p_created timestamp without time zone DEFAULT now() -); -CREATE TABLE recover_pass ( - use_id bigint NOT NULL, - request text NOT NULL, - password text NOT NULL, - created_on timestamp with time zone, - created_host text, - recover_on timestamp with time zone, - recover_by text -); -CREATE TABLE theme ( - the_name text NOT NULL, - the_filestyle text, - the_filebutton text -); -CREATE TABLE user_global_pref ( - user_id text NOT NULL, - parameter_type text NOT NULL, - parameter_value text -); -CREATE TABLE version ( - val integer NOT NULL -); diff --git a/include/sql/mod1/make-sql b/include/sql/mod1/make-sql index bdc3e2e59..c56ace0f4 100755 --- a/include/sql/mod1/make-sql +++ b/include/sql/mod1/make-sql @@ -34,7 +34,7 @@ sed -i -e "/REVOKE /d" -e "/GRANT /d" -e "/ALTER TABLE.*/d" -e "/ADD CONSTRAINT/ grep setval schema.sql >> sequence.sql -echo "set search_path = public, comptaproc,pg_catalog ;" > data.sql +echo "set search_path = public,comptaproc,pg_catalog ;" > data.sql pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql