CREATE DATABASE IF NOT EXISTS dollr_demo CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE dollr_demo;

CREATE TABLE IF NOT EXISTS payments (
  id INT AUTO_INCREMENT PRIMARY KEY,
  customer_name VARCHAR(150) NOT NULL,
  customer_phone VARCHAR(30) NOT NULL,
  customer_email VARCHAR(150) NULL,
  service_name VARCHAR(150) NOT NULL,
  currency VARCHAR(3) NOT NULL DEFAULT 'USD',
  amount DECIMAL(12,2) NOT NULL,
  reference_id VARCHAR(64) NOT NULL UNIQUE,
  source_type VARCHAR(30) NULL,
  source_id INT NULL,
  source_number VARCHAR(80) NULL,
  source_status VARCHAR(40) DEFAULT 'CREATED',
  checkout_url TEXT NULL,
  raw_response JSON NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
