Modify quant_fin , we add a column j_id to have a fk to jrnx and operation_currency

This commit is contained in:
Dany De Bontridder 2018-11-27 22:05:20 +01:00
parent ffa1b5af34
commit c155f87b65
4 changed files with 23 additions and 12 deletions

View file

@ -28,3 +28,14 @@ ALTER TABLE public.jrn_def ALTER COLUMN currency_id SET NOT NULL;
ALTER TABLE public.jrn_def ADD CONSTRAINT jrn_def_currency_fk FOREIGN KEY (currency_id) REFERENCES public.currency(id);
COMMENT ON COLUMN public.jrn_def.currency_id IS 'Default currency for financial ledger';
alter table quant_fin add j_id bigint;
with j_fin as (
select jrnx.j_id,quant_fin.qf_id from quant_fin join jrn using (jr_id) join jrnx on (j_grpt=jr_grpt_id and f_id=qf_other)
)
update quant_fin set j_id =j_fin.j_id from j_fin where j_fin.qf_id=quant_fin.qf_id;
alter table quant_fin add constraint jrnx_j_id_fk foreign key (j_id ) references jrnx(j_id) on delete cascade on update cascade;