-- Run this once in phpMyAdmin.
-- Static Paylinks: unlike the existing "Instant PayLink" (auth/payment_link.php)
-- which creates ONE order and expires in 10 minutes, a static paylink is a
-- permanent, reusable link a merchant can share anywhere (poster, bio,
-- WhatsApp status). Every time someone opens it, a fresh order is created
-- for that same fixed amount, until it expires or is disabled.

CREATE TABLE IF NOT EXISTS `static_paylinks` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `link_id` VARCHAR(20) NOT NULL UNIQUE,
  `user_token` VARCHAR(191) NOT NULL,
  `title` VARCHAR(60) NOT NULL,
  `description` VARCHAR(150) DEFAULT NULL,
  `amount` DECIMAL(10,2) NOT NULL,
  `paylink_type` ENUM('normal','redirect') NOT NULL DEFAULT 'normal',
  `redirect_url` VARCHAR(255) DEFAULT NULL,
  `collect_name` TINYINT(1) NOT NULL DEFAULT 0,
  `collect_mobile` TINYINT(1) NOT NULL DEFAULT 0,
  `collect_email` TINYINT(1) NOT NULL DEFAULT 0,
  `validity` VARCHAR(10) NOT NULL DEFAULT '7d',
  `expires_at` DATETIME DEFAULT NULL,
  `status` ENUM('Active','Disabled') NOT NULL DEFAULT 'Active',
  `orders_count` INT(11) NOT NULL DEFAULT 0,
  `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
