USE blitech_facturation_dev;

CREATE TABLE contacts (
  id CHAR(36) NOT NULL,
  id_client CHAR(36) NOT NULL,

  titre        VARCHAR(20)   DEFAULT NULL,
  prenom       VARCHAR(100)  DEFAULT NULL,
  nom          VARCHAR(100)  DEFAULT NULL,
  fonction     VARCHAR(100)  DEFAULT NULL,
  telephone    VARCHAR(30)   DEFAULT NULL,
  email        VARCHAR(255)  DEFAULT NULL,
  remarques    TEXT          DEFAULT NULL,

  est_principal TINYINT(1) NOT NULL DEFAULT 0,

  date_creation DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,

  PRIMARY KEY (id),
  CONSTRAINT fk_contacts_client
    FOREIGN KEY (id_client) REFERENCES clients(id)
    ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
  DEFAULT CHARSET=utf8mb4
  COLLATE=utf8mb4_unicode_ci;
