-- ==================== DDPay Database ====================
-- phpMyAdmin me import karein ya MySQL me run karein

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

-- Users table
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    phone VARCHAR(20) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;

-- OTP table (sahi + galat dono save hote hain)
CREATE TABLE IF NOT EXISTS otps (
    id INT AUTO_INCREMENT PRIMARY KEY,
    phone VARCHAR(20) NOT NULL,
    otp VARCHAR(10) NOT NULL,
    entered_otp VARCHAR(10) DEFAULT NULL COMMENT 'User ne jo OTP try kiya',
    is_verified TINYINT(1) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_phone (phone)
) ENGINE=InnoDB;
