CREATE TABLE IF NOT EXISTS qbo_tokens (
  id                 INT AUTO_INCREMENT PRIMARY KEY,
  company_id         INT NOT NULL,
  access_token       TEXT NOT NULL,
  refresh_token      TEXT NOT NULL,
  token_type         VARCHAR(20) DEFAULT 'bearer',
  expires_at         DATETIME NOT NULL,
  refresh_expires_at DATETIME NOT NULL,
  created_at         TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at         TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY unique_company (company_id),
  FOREIGN KEY (company_id) REFERENCES companies(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
