CREATE TABLE `partner_credits` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `customer_id` int(10) unsigned NOT NULL,
  `credit_limit` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT 'Maximum credit in Rial',
  `credit_used` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT 'Currently used credit',
  `is_blocked` tinyint(1) NOT NULL DEFAULT 0,
  `blocked_reason` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_customer` (`customer_id`),
  CONSTRAINT `fk_partner_credits_customer` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
