
CREATE TABLE `was_stripe_subscription_pending_update` (
  `stripe_subscription_pending_update_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `stripe_subscription_id` int(11) unsigned NOT NULL,
  `stripe_price_id` varchar(64) DEFAULT NULL,
  `stripe_invoice_id` varchar(64) DEFAULT NULL,
  `invoice_amount` decimal(9,2) DEFAULT 0,
  `invoice_status` enum('open', 'paid', 'uncollectible', 'void') NOT NULL DEFAULT 'open',
  `subscription_metadata` text DEFAULT NULL,
  `update_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`stripe_subscription_pending_update_id`),
  KEY `idx_stripe_subscription_id` (`stripe_subscription_id`),
  KEY `idx_stripe_invoice_id` (`stripe_invoice_id`),
  KEY `idx_invoice_status` (`invoice_status`)
) ENGINE=InnoDB;

CREATE TRIGGER `was_stripe_subscription_pending_update_insert_timestamp` 
BEFORE INSERT ON `was_stripe_subscription_pending_update` FOR EACH ROW SET NEW.insert_timestamp = NOW();
