diff --git a/sql/upgrade.sql b/sql/upgrade.sql index c5b7c81b0..bbbe57920 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,4 +1,5 @@ begin; + create or replace function correct_sequence ( p_sequence text,p_col text, p_table text ) returns integer as @@ -46,6 +47,19 @@ comment on function correct_sequence (text,text,text) is ' Often the primary key select correct_sequence('s_jnt_fic_att_value','jft_id','jnt_fic_att_value'); +-- add a pk to the table jnt_fic_attr +alter table jnt_fic_attr add jnt_id int8; +create sequence s_jnt_id; +alter table jnt_fic_attr alter jnt_id set default nextval('s_jnt_id'); +update jnt_fic_attr set jnt_id=nextval('s_jnt_id'); +alter table jnt_fic_attr add constraint pk_jnt_fic_attr primary key (jnt_id); + +-- remove duplicate attr +delete from jnt_fic_attr where jnt_id in ( select a.jnt_id from jnt_fic_attr a join jnt_fic_attr b on (a.fd_id=b.fd_id and a.ad_id=b.ad_id) where a.jnt_id > b.jnt_id); + + + + commit; \ No newline at end of file