ALTER TABLE ref_species ADD COLUMN is_system INTEGER NOT NULL DEFAULT 0 CHECK(is_system IN (0,1));

UPDATE ref_species SET is_system=1
WHERE code IN ('chat','chien','lapin','furet','cobaye','oiseau','reptile','animal-ferme','faune-sauvage','autre');

DELETE FROM ref_species
WHERE code IN ('cat','dog')
  AND NOT EXISTS (SELECT 1 FROM animals a WHERE lower(trim(a.species))=ref_species.code);
