-- Migration: Create api_providers table
-- Description: Stores third-party API provider configurations
-- Date: 2026-01-26

CREATE TABLE IF NOT EXISTS api_providers (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  short_name VARCHAR(100),
  description TEXT,
  api_url VARCHAR(255) NOT NULL,
  api_key TEXT NOT NULL,
  status ENUM('active', 'inactive') DEFAULT 'active',
  last_synced_at TIMESTAMP NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  INDEX idx_name (name),
  INDEX idx_short_name (short_name),
  INDEX idx_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Insert default Owlet provider (will be created by sync if not exists)
-- INSERT INTO api_providers (name, short_name, api_url, api_key, status)
-- VALUES ('Owlet SMM', 'owlet', 'https://the-owlet.com/api/v2', 'YOUR_API_KEY', 'active');
