-- Criação de tabelas para links de pagamento e mapa de clientes Asaas
CREATE TABLE IF NOT EXISTS asaas_customer_map (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  client_id BIGINT UNSIGNED NOT NULL,
  asaas_customer_id VARCHAR(64) NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_client (client_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS asaas_payment_links (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  sale_id VARCHAR(64) NOT NULL,
  client_id BIGINT UNSIGNED NOT NULL,
  asaas_payment_id VARCHAR(64) NOT NULL,
  asaas_link_id VARCHAR(64) NULL,
  link_url VARCHAR(512) NULL,
  status VARCHAR(64) NOT NULL DEFAULT 'aguardando compensação',
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;