-- Customer lables + pagination follow-up
CREATE TABLE IF NOT EXISTS customer_lable (
  id INT AUTO_INCREMENT PRIMARY KEY,
  account_id INT NOT NULL,
  name VARCHAR(120) NOT NULL,
  color VARCHAR(20) DEFAULT '#1a3a6f',
  status TINYINT(1) DEFAULT 1,
  date_created DATETIME DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_customer_lable_account_name (account_id, name),
  KEY idx_customer_lable_account (account_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS customer_lable_customers (
  id INT AUTO_INCREMENT PRIMARY KEY,
  account_id INT NOT NULL,
  customer_id INT NOT NULL,
  lable_id INT NOT NULL,
  date_created DATETIME DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_customer_lable_customer (account_id, customer_id, lable_id),
  KEY idx_customer_lable_customer (account_id, customer_id),
  KEY idx_customer_lable_lable (account_id, lable_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
