CREATE TABLE IF NOT EXISTS settings (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  company_id BIGINT UNSIGNED NOT NULL DEFAULT 1,
  setting_key VARCHAR(100) NOT NULL,
  setting_value TEXT NULL,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_settings_key (company_id, setting_key)
);

INSERT INTO settings (company_id, setting_key, setting_value) VALUES
(1, 'company_name', 'KopierS LLC'),
(1, 'default_currency', 'USD'),
(1, 'date_format', 'm/d/Y'),
(1, 'language', 'en'),
(1, 'timezone', 'America/New_York'),
(1, 'storage_folder', 'storage/statements'),
(1, 'enable_auto_categorization', '1'),
(1, 'low_confidence_threshold', '70'),
(1, 'keep_original_pdf', '1'),
(1, 'temporary_exports', '1'),
(1, 'ocr_enabled', '0'),
(1, 'backup_enabled', '0')
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value);
