
CREATE TABLE `was_stripe_subscription_schedule` (
 `stripe_subscription_schedule_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `stripe_subscription_id` int(11) unsigned NOT NULL,
 `stripe_price_id` varchar(64) DEFAULT NULL,
 `schedule_start_date` int(11) unsigned NOT NULL,
 `schedule_metadata` text DEFAULT NULL,
 `subscription_metadata` text DEFAULT NULL,
 `schedule_status` enum('pending', 'created') NOT NULL DEFAULT 'pending',
 `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_schedule_id`),
 KEY `idx_stripe_subscription_id` (`stripe_subscription_id`),
 KEY `idx_schedule_status` (`schedule_status`)
) ENGINE=InnoDB;

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