-- api-bikinappku/database.sql

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` varchar(100) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `mobile` varchar(20) DEFAULT NULL,
  `password` varchar(255) NOT NULL,
  `avatar` varchar(255) DEFAULT NULL, 
  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
);

-- ALTER TABLE users ADD COLUMN avatar VARCHAR(255) DEFAULT NULL;

-- TABEL APP SETTINGS
CREATE TABLE IF NOT EXISTS `app_settings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` varchar(100) NOT NULL, -- UID Pemilik Aplikasi
  `store_name` varchar(255) DEFAULT 'GOPEK',
  `app_name` varchar(255) DEFAULT 'GOPEKU',
  `package_name` varchar(255) DEFAULT 'com.gopeku',
  `main_color` varchar(7) DEFAULT '#257DDE',
  `app_logo` varchar(255) DEFAULT NULL,
  `require_login` tinyint(1) DEFAULT 1,
  `google_auth` tinyint(1) DEFAULT 0,
  `hp_otp` tinyint(1) DEFAULT 1,
  `email_verification` tinyint(1) DEFAULT 0,
  `dropshipper_active` tinyint(1) DEFAULT 1,
  `manual_moderation` tinyint(1) DEFAULT 0,
  `member_balance` tinyint(1) DEFAULT 1,
  `online_shop_website` tinyint(1) DEFAULT 1,
  `maintenance_mode` tinyint(1) DEFAULT 0,
  `show_stock` tinyint(1) DEFAULT 1,
  `show_location` tinyint(1) DEFAULT 0,
  `show_empty_stock` tinyint(1) DEFAULT 0,
  `latest_apk_url` varchar(255) DEFAULT NULL,
  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
);

-- TABEL PRODUCTS
CREATE TABLE IF NOT EXISTS `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` varchar(100) NOT NULL, -- UID Pemilik Produk/Aplikasi
  `name` varchar(255) NOT NULL,
  `price` int(11) NOT NULL,
  `stock` int(11) NOT NULL,
  `category` varchar(100) DEFAULT NULL,
  `color` varchar(7) DEFAULT '#6366F1',
  `sold` varchar(50) DEFAULT '0',
  `image` varchar(255) DEFAULT NULL,
  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
);

-- TABEL CATEGORIES
CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` varchar(100) NOT NULL, -- UID Pemilik Aplikasi
  `name` varchar(100) NOT NULL,
  `icon` varchar(50) DEFAULT 'category', -- Icon name for Flutter
  `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
);
