CREATE TABLE directory_contact_roles_new (
  contact_id INTEGER NOT NULL,
  role TEXT NOT NULL CHECK(role IN ('fa','benevole','dirigeant','veterinaire','cabinet','crematorium','adoptant','deposant','fourriere')),
  PRIMARY KEY(contact_id,role),
  FOREIGN KEY(contact_id) REFERENCES directory_contacts(id) ON DELETE CASCADE
);
INSERT INTO directory_contact_roles_new(contact_id,role) SELECT contact_id,role FROM directory_contact_roles;
DROP TABLE directory_contact_roles;
ALTER TABLE directory_contact_roles_new RENAME TO directory_contact_roles;
CREATE INDEX idx_directory_role ON directory_contact_roles(role,contact_id);
