CREATE TABLE IF NOT EXISTS `bespoke_form` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) NOT NULL,
  `Hide_Title` tinyint(4) NOT NULL default '0',
  `Terms_Page_ID` int(11) NOT NULL,
  `Add_To_Subscribers` int(11) NOT NULL default '0',
  `Subscribers_Name_Field` int(11) NOT NULL default '0',
  `Subscribers_Email_Field` int(11) NOT NULL default '0',
  `Email_Subject` varchar(255) NOT NULL,
  `Email_Body` text NOT NULL,
  `Success_Message` text,
  `Error_Message` text,
  `Updated` datetime NOT NULL,
  `Created` datetime NOT NULL,
  PRIMARY KEY  (`ID`),
  KEY `Subscribers_Name_Field` (`Subscribers_Name_Field`),
  KEY `Subscribers_Email_Field` (`Subscribers_Email_Field`),
  KEY `Terms_Page_ID` (`Terms_Page_ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

CREATE TABLE IF NOT EXISTS `bespoke_form_elements` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) NOT NULL,
  `Hide_Title` tinyint(4) NOT NULL default '0',
  `Section_ID` int(11) NOT NULL,
  `Type` varchar(255) NOT NULL,
  `Required` tinyint(4) NOT NULL default '0',
  `Updated` datetime NOT NULL,
  `Created` datetime NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

CREATE TABLE IF NOT EXISTS `bespoke_form_element_types` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) NOT NULL,
  `Has_Options` tinyint(4) NOT NULL,
  `Updated` datetime NOT NULL,
  `Created` datetime NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

INSERT INTO `bespoke_form_element_types` (`ID`, `Title`, `Has_Options`, `Updated`, `Created`) VALUES
(1, 'Text', 0, '2015-04-15 10:17:15', '2015-04-15 10:16:55'),
(2, 'Textarea', 0, '2015-04-15 10:17:07', '2015-04-15 10:17:07'),
(3, 'Select', 1, '2015-04-15 10:17:30', '2015-04-15 10:17:30'),
(4, 'Radio', 1, '2015-04-15 10:17:42', '2015-04-15 10:17:41'),
(5, 'Checkbox', 1, '2015-04-15 10:17:56', '2015-04-15 10:17:55'),
(6, 'Date', 0, '2015-04-15 10:23:24', '2015-04-15 10:23:23');

CREATE TABLE IF NOT EXISTS `bespoke_form_options` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) NOT NULL,
  `Element_ID` int(11) NOT NULL,
  `Value` varchar(255) NOT NULL,
  `Updated` datetime NOT NULL,
  `Created` datetime NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=23 ;

CREATE TABLE IF NOT EXISTS `bespoke_form_sections` (
  `ID` int(11) NOT NULL auto_increment,
  `Title` varchar(255) NOT NULL,
  `Hide_Title` tinyint(4) NOT NULL default '0',
  `Section_Type` int(11) NOT NULL default '0',
  `Section_Background` int(11) NOT NULL default '0',
  `Form_ID` tinyint(4) NOT NULL,
  `Order_By` int(11) NOT NULL default '0',
  `Updated` datetime NOT NULL,
  `Created` datetime NOT NULL,
  PRIMARY KEY  (`ID`),
  KEY `Order` (`Order_By`),
  KEY `Form_ID` (`Form_ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;


ALTER TABLE `page` ADD `Form_ID` int(11);