simplonco / carto-emploi

Projet de cartographie des emplois du numérique en France
0 stars 3 forks source link

Database doesn't have a primary key #9

Closed annemarie35 closed 9 years ago

annemarie35 commented 9 years ago

Get this message from pgadmin. Maybe something to change later for production ?

_Edit table data without primary key Since the table public.joboffers doesn't have a primary key or OIDs, you can view the data only. Inserting new rows and changing existing rows isn't possible for the Edit Data tool without primary key. In order to edit data, pgAdmin III requires a primary key on the table, which is a good database design practice anyway. Alternatively, the table can be created WITH OIDS. Please note that oids are not guaranteed to be unique over a very long period of time, so using oids as kind-of primary key is only second choice.

annemarie35 commented 9 years ago

Fait en production :

Il faut faire la requête suivante pour ne pas avoir de doublons

DELETE FROM job_offers AS P1 USING job_offers AS P2 WHERE P1.id_key > P2.id_key AND P1.offer_id = P2.offer_id

puis

ALTER TABLE job_offers ADD PRIMARY KEY (offer_id);