

CREATE TABLE `packages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `duration` int(11) NOT NULL COMMENT 'in days',
  `daily_limit` int(11) NOT NULL,
  `monthly_limit` int(11) NOT NULL,
  `supports_envato` tinyint(1) NOT NULL DEFAULT 0,
  `supports_freepik` tinyint(1) NOT NULL DEFAULT 0,
  `status` tinyint(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`)
);

CREATE TABLE `downloads` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `platform` varchar(20) NOT NULL,
  `url` varchar(255) NOT NULL,
  `download_url` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `downloads_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
);

CREATE TABLE `payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `payment_id` varchar(100) NOT NULL,
  `status` varchar(20) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
);

CREATE TABLE `pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `slug` varchar(100) NOT NULL,
  `content` text NOT NULL,
  `is_visible` tinyint(1) NOT NULL DEFAULT 1,
  `show_in_sidebar` tinyint(1) NOT NULL DEFAULT 1,
  `order` int(11) NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `slug` (`slug`)
);

INSERT INTO `pages` (`title`, `slug`, `content`, `is_visible`, `show_in_sidebar`, `order`) VALUES
('Hakkımızda', 'hakkimizda', '<h1>Hakkımızda</h1><p>Bu sayfa site hakkında bilgiler içerir.</p>', 1, 1, 1),
('Yardım', 'yardim', '<h1>Yardım</h1><p>Yardım ve destek bilgileri.</p>', 1, 1, 2),
('Şartlar ve Koşullar', 'sartlar-ve-kosullar', '<h1>Şartlar ve Koşullar</h1><p>Site kullanım şartları ve koşulları.</p>', 1, 0, 3);