Projet

Général

Profil

Anomalie #10852

Mis à jour par Ludovic ARAUJO il y a plus de 5 ans

Réaliser pour le CD45 

 a modifier :  


 ~~~ 
 CREATE TABLE redirected_baskets 
       ( 
       id serial NOT NULL, 
       actual_user_id INTEGER NOT NULL, 
       owner_user_id INTEGER NOT NULL, 
       basket_id character varying(255) NOT NULL, 
       group_id INTEGER NOT NULL, 
       CONSTRAINT redirected_baskets_pkey PRIMARY KEY (id), 
       CONSTRAINT redirected_baskets_unique_key UNIQUE (owner_user_id, basket_id, group_id) 
       ) 
       WITH (OIDS=FALSE); 

       INSERT INTO redirected_baskets (owner_user_id, actual_user_id, basket_id, group_id) SELECT users.id, us.id, user_abs.basket_id, usergroups.id FROM usergroups, usergroup_content, user_abs, groupbasket, users, users us 
         where usergroup_content.group_id = usergroups.group_id 
         and usergroup_content.user_id = user_abs.user_abs 
         and users.user_id = user_abs.user_abs 
         and us.user_id = user_abs.new_user 
         and groupbasket.group_id = usergroup_content.group_id 
         and groupbasket.basket_id = user_abs.basket_id; 
 ~~~ 


 Remplacer par : 


 



 ~~~ 


 CREATE TABLE redirected_baskets 
         ( 
         id serial NOT NULL, 
         actual_user_id INTEGER NOT NULL, 
         owner_user_id INTEGER NOT NULL, 
         basket_id character varying(255) NOT NULL, 
         group_id INTEGER NOT NULL, 
         CONSTRAINT redirected_baskets_pkey PRIMARY KEY (id)--, 
         --CONSTRAINT redirected_baskets_unique_key UNIQUE (owner_user_id, basket_id, group_id) 
         ) 
         WITH (OIDS=FALSE); 

         --Insertion des lignes (avec les doublons dans la table) 
         INSERT INTO redirected_baskets (owner_user_id, actual_user_id, basket_id, group_id) SELECT users.id, us.id, user_abs.basket_id, usergroups.id FROM usergroups, usergroup_content, user_abs, groupbasket, users, users us 
         where usergroup_content.group_id = usergroups.group_id 
         and usergroup_content.user_id = user_abs.user_abs 
         and users.user_id = user_abs.user_abs 
         and us.user_id = user_abs.new_user 
         and groupbasket.group_id = usergroup_content.group_id 
         and groupbasket.basket_id = user_abs.basket_id; 

         --suppression des lignes en doublons 
         DELETE FROM redirected_baskets a USING redirected_baskets b where a.id > b.id 
         AND a.actual_user_id = b.actual_user_id 
         AND a.owner_user_id = b.owner_user_id 
         AND a.basket_id = b.basket_id; 

 ~~~

Retour