#!/usr/bin/env ruby
 
usage = <<US
create-httptrans <trace table>
Example: create-httptrans ABCD_20090201
Will create ABCD_20090201_HttpTransactions from ABCD_20090201_Flows
US
 
trace = ARGV[0] || abort('Expecting trace name: ' + usage)
 
sql = <<SQL
DROP TABLE IF EXISTS `#{trace}_HttpTransactions`;
CREATE TABLE `#{trace}_HttpTransactions` (
  `HttpTransactionId` bigint unsigned NOT NULL auto_increment,
  `FlowId` int NOT NULL,
  `Method` enum('OPTIONS','GET','HEAD','POST','PUT','DELETE','TRACE') NOT NULL,
  `Url` mediumtext NOT NULL,
  `Host` varchar(255) NOT NULL,
  `UserAgent` varchar(255) NOT NULL,
  `ResponseCode` smallint NOT NULL,
  `ContentType` varchar(255) NOT NULL,
  `ContentLength` int NOT NULL,
  `Server` varchar(255) NOT NULL,
  `RequestTs` double NOT NULL,
  `ResponseTs` double NOT NULL,
  PRIMARY KEY  (`HttpTransactionId`),
  KEY `FlowId` (`FlowId`)
);
SQL
puts sql
