From 00e7bb4010c85445786a4bd4611f99eb9f810b89 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 17 Sep 2014 00:53:14 +0200 Subject: [PATCH] add script for table Distribution keys --- sql/upgrade.sql | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sql/upgrade.sql b/sql/upgrade.sql index ed45527a9..0649fd404 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -23,3 +23,35 @@ INSERT INTO menu_ref(me_code, me_menu, me_file, me_type,me_description_etendue insert into profile_menu(me_code,p_id,p_type_display,pm_default,me_code_dep,p_order) values ('ANCKEY',1,'E',0,'ANC',15); insert into profile_menu(me_code,p_id,p_type_display,pm_default,me_code_dep,p_order) values ('ANCKEY',2,'E',0,'ANC',15); + +create table key_distribution ( + kd_id serial primary key, + kd_name text, + kd_description text); + +create table key_distribution_ledger ( + kl_id serial primary key, + kd_id bigint not null references key_distribution(kd_id) on update cascade on delete cascade, + jrn_def_id bigint not null references jrn_def(jrn_def_id) on update cascade on delete cascade + ); + +create table key_distribution_detail( + ke_id serial primary key, + kd_id bigint not null references key_distribution(kd_id) on update cascade on delete cascade, + ke_row integer not null, + ke_percent numeric(20,4) not null + + ); + +create table key_distribution_activity +( + ka_id serial primary key, + ke_id bigint not null references key_distribution_detail(ke_id) on update cascade on delete cascade, + po_id bigint references poste_analytique(po_id) on update cascade on delete cascade, + pa_id bigint not null references plan_analytique(pa_id) on update cascade on delete cascade +); + +comment on table key_distribution is 'Distribution key for analytic'; +comment on table key_distribution_ledger is 'Legder where the distribution key can be used' ; +comment on table key_distribution_detail is 'Row of activity and percent'; +comment on table key_distribution_activity is 'activity (account) linked to the row';