-- Database: makewpcx_matchify

CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    full_name VARCHAR(100) NOT NULL,
    email VARCHAR(100) UNIQUE NOT NULL,
    phone VARCHAR(20) NOT NULL,
    birthday DATE,
    password VARCHAR(255) NOT NULL,
    gender ENUM('erkek', 'kadin') DEFAULT NULL,
    preference ENUM('erkek', 'kadin') DEFAULT NULL,
    is_suspended TINYINT(1) DEFAULT 0,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    INDEX (email),
    INDEX (gender),
    INDEX (preference),
    INDEX (is_suspended)
);

CREATE TABLE IF NOT EXISTS investments (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    amount DECIMAL(10, 2) NOT NULL,
    description TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS admins (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) UNIQUE NOT NULL,
    password VARCHAR(255) NOT NULL
);

-- Default admin (change password in production)
-- password: admin123
INSERT INTO admins (username, password) VALUES ('admin', '$2y$10$v0r7eXy0r7eXy0r7eXy0re6tJb9gGj.X0v0r7eXy0r7eXy0r7eXy0'); 
