Actions
Anomalie #10852
fermé[Migration MaarchCourrier] sql/1904.sql en erreur
Début:
04/06/2019
Echéance:
Description
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;
Actions