
CREATE TABLE `was_hashcash` (
  `hashcash_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `hashcash_origin` varchar(32) NOT NULL,
  `hashcash_ipaddress` varchar(46) NOT NULL,
  `hashcash_stamp` char(32) NOT NULL,
  `hashcash_zeros` int(11) NOT NULL,
  `hashcash_hash` varchar(64) DEFAULT NULL,
  `hashcash_created_date` int(11) unsigned DEFAULT NULL,
  `hashcash_solved_date` int(11) unsigned DEFAULT NULL,
  `user_id` int(11) unsigned 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 (`hashcash_id`),
  UNIQUE KEY `unq_hashcash_stamp` (`hashcash_stamp`),
  KEY `idx_hashcash_origin_ipaddress` (`hashcash_origin`, `hashcash_ipaddress`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB;


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