# Host:
# Database: test
# Table: 'stock'
#
CREATE TABLE `stock` (
  `uid` BIGINT UNSIGNED NOT NULL,
  `order_id` BIGINT UNSIGNED NOT NULL,
  `explanation_uid` BIGINT UNSIGNED,
  `node_uid` BIGINT UNSIGNED,
  `section_uid` BIGINT UNSIGNED,
  `payment_uid` BIGINT UNSIGNED,
  `function_uid` BIGINT UNSIGNED,
  `project_uid` BIGINT UNSIGNED,
  `funding_uid` BIGINT UNSIGNED,
  `ledger_uid` BIGINT UNSIGNED,
  `payment_request_uid` BIGINT UNSIGNED,
  `mirror_section_uid` BIGINT UNSIGNED,
  `mirror_node_uid` BIGINT UNSIGNED,
  `resource_uid` BIGINT UNSIGNED,
  `quantity` real,
  `is_cancellation` BOOLEAN,
  `is_accountable` BOOLEAN,
  `date` datetime,
  `mirror_date` datetime,
  `total_price` real ,
  `portal_type` VARCHAR(255),
  `simulation_state` varchar(255) default '',
  `variation_text` VARCHAR(255),
  `sub_variation_text` VARCHAR(255),
  `is_source` BOOLEAN,
  PRIMARY KEY (`uid`, `order_id`),
  KEY `quantity` (`quantity`),
  KEY `section_uid_portal_type_mirror_section_uid` (`section_uid`, `portal_type`, `mirror_section_uid`),
  KEY `mirror_section_uid` (`mirror_section_uid`),
  KEY `mirror_node_uid` (`mirror_node_uid`),
  KEY `node_uid` (`node_uid`),
  KEY `payment_uid` (`payment_uid`),
  KEY `function_uid` (`function_uid`),
  KEY `payment_request_uid` (`payment_request_uid`),
  KEY `project_uid` (`project_uid`),
  KEY `funding_uid` (`funding_uid`),
  KEY `explanation_uid` (`explanation_uid`),
  KEY `state_section_node_date` (`simulation_state`, `section_uid`, `node_uid`, `date`),
  KEY `resource_node_uid` (`resource_uid`, `node_uid`),
  KEY `resource_section_node_uid` (`resource_uid`, `section_uid`, `node_uid`, `simulation_state`),
  KEY `date` (`date`)
) ENGINE=InnoDB;
