-- Database: `youtubedonusturu_sa`
CREATE DATABASE IF NOT EXISTS `youtubedonusturu_sa` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE `youtubedonusturu_sa`;

-- Tablo: `users` (Admin Kullanıcıları)
CREATE TABLE IF NOT EXISTS `users` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `username` VARCHAR(50) NOT NULL UNIQUE,
  `email` VARCHAR(100) NOT NULL UNIQUE,
  `password` VARCHAR(255) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Varsayılan Admin Kullanıcısı (Kullanıcı Adı: admin, Şifre: AdminPassword123!)
INSERT INTO `users` (`username`, `email`, `password`)
VALUES ('admin', 'admin@example.com', '$2y$10$wN9QjA7gL1L.B3P4rF9pBeoJp1mZ7gV5q7x4n7d3w5z9a1b2c3d4e')
ON DUPLICATE KEY UPDATE `username`=`username`;

-- Tablo: `iletisim_bilgileri` (İletişim Mesajları)
CREATE TABLE IF NOT EXISTS `iletisim_bilgileri` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `isim` VARCHAR(50),
  `soyisim` VARCHAR(50),
  `email` VARCHAR(100),
  `telefon` VARCHAR(20),
  `tel` VARCHAR(20),
  `konu` VARCHAR(100),
  `mesaj` TEXT,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `contact_messages` (Yedek İletişim Tablosu)
CREATE TABLE IF NOT EXISTS `contact_messages` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100),
  `email` VARCHAR(100),
  `phone` VARCHAR(20),
  `subject` VARCHAR(150),
  `message` TEXT,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `conversions` (İndirme/Dönüştürme İstatistikleri)
CREATE TABLE IF NOT EXISTS `conversions` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `url` TEXT,
  `format` VARCHAR(20),
  `token` VARCHAR(64),
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `ziyaretler` (Ziyaretçi Takip Tablosu)
CREATE TABLE IF NOT EXISTS `ziyaretler` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `ip` VARCHAR(45),
  `user_agent` TEXT,
  `visited_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `anasayfa_metni`
CREATE TABLE IF NOT EXISTS `anasayfa_metni` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `metin` TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `banners`
CREATE TABLE IF NOT EXISTS `banners` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `banner_type` VARCHAR(50),
  `banner_url` VARCHAR(255),
  `width` INT,
  `height` INT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `logo`
CREATE TABLE IF NOT EXISTS `logo` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `dosya_yolu` VARCHAR(255),
  `ad` VARCHAR(100)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `products`
CREATE TABLE IF NOT EXISTS `products` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `name` VARCHAR(100),
  `description` TEXT,
  `price` DECIMAL(10,2)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tablo: `reklamlar`
CREATE TABLE IF NOT EXISTS `reklamlar` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `resim_yolu` VARCHAR(255),
  `hedef_link` VARCHAR(255)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
