ALTER TABLE  `tt_tweets` ADD  `network` VARCHAR( 10 ) NOT NULL DEFAULT  'twitter';
ALTER TABLE  `tt_follows` ADD  `network` VARCHAR( 10 ) NOT NULL DEFAULT  'twitter';
ALTER TABLE  `tt_users` ADD  `network` VARCHAR( 10 ) NOT NULL DEFAULT  'twitter';
ALTER TABLE  `tt_user_errors` ADD  `network` VARCHAR( 10 ) NOT NULL DEFAULT  'twitter';

CREATE TABLE  `tt_plugins` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 255 ) NOT NULL ,
`folder_name` VARCHAR( 255 ) NOT NULL ,
`description` VARCHAR( 255 ),
`author` VARCHAR( 255 ),
`homepage` VARCHAR( 255 ),
`version` VARCHAR( 255 ),
`is_active` TINYINT NOT NULL ,
PRIMARY KEY (  `id` )
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


CREATE TABLE  `tt_plugin_options` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`plugin_id` INT NOT NULL ,
`option_name` VARCHAR( 255 ) NOT NULL ,
`option_value` VARCHAR( 255 ) NOT NULL ,
INDEX (  `plugin_id` )
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

INSERT INTO  `tt_plugins` (`name` , `folder_name` , `description` , `author` , `homepage` , `version` , `is_active` )
VALUES ('Twitter',  'twitter',  'Twitter support',  'Gina Trapani',  'http://thinktankapp.com',  '0.01',  '1');

RENAME TABLE `tt_tweets` TO `tt_posts`; 
ALTER TABLE  `tt_posts` CHANGE  `status_id`  `post_id` BIGINT( 11 ) NOT NULL;
ALTER TABLE  `tt_posts` CHANGE  `tweet_text`  `post_text` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;
ALTER TABLE  `tt_posts` DROP `tweet_html`;
ALTER TABLE  `tt_posts` CHANGE  `in_reply_to_status_id`  `in_reply_to_post_id` BIGINT( 11 ) NULL DEFAULT NULL;
ALTER TABLE  `tt_posts` CHANGE  `in_retweet_of_status_id`  `in_retweet_of_post_id` BIGINT( 11 ) NULL DEFAULT NULL;

ALTER TABLE  `tt_links` CHANGE  `status_id`  `post_id` BIGINT( 11 ) NULL DEFAULT NULL;

RENAME TABLE `tt_tweet_errors` TO `tt_post_errors`; 
ALTER TABLE  `tt_post_errors` CHANGE  `status_id`  `post_id` BIGINT( 20 ) NOT NULL;

CREATE TABLE IF NOT EXISTS `tt_replies` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `reply_id` bigint(11) NOT NULL,
  `author_user_id` int(11) NOT NULL,
  `author_username` varchar(50) COLLATE utf8_bin NOT NULL,
  `author_fullname` varchar(50) COLLATE utf8_bin NOT NULL,
  `author_avatar` varchar(255) COLLATE utf8_bin NOT NULL,
  `post_text` varchar(160) COLLATE utf8_bin NOT NULL,
  `source` varchar(255) COLLATE utf8_bin NOT NULL,
  `pub_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `in_reply_to_user_id` int(11) DEFAULT NULL,
  `in_reply_to_post_id` bigint(11) DEFAULT NULL,
  `in_retweet_of_post_id` bigint(11) DEFAULT NULL,
  `network` varchar(10) COLLATE utf8_bin NOT NULL DEFAULT 'twitter',
  PRIMARY KEY (`id`),
  UNIQUE KEY `reply_id` (`reply_id`),
  KEY `author_username` (`author_username`),
  KEY `pub_date` (`pub_date`),
  KEY `author_user_id` (`author_user_id`),
  KEY `in_reply_to_user_id` (`in_reply_to_user_id`),
  KEY `in_retweet_of_post_id` (`in_retweet_of_post_id`),
  FULLTEXT KEY `post_fulltext` (`post_text`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

ALTER TABLE  `tt_users` CHANGE  `tweet_count` `post_count` int(11) NOT NULL;

ALTER TABLE  `tt_instances` CHANGE  `twitter_user_id` `network_user_id` int(11) NOT NULL;
ALTER TABLE  `tt_instances` CHANGE  `twitter_username` `network_username` varchar(255) collate utf8_bin NOT NULL;
ALTER TABLE  `tt_instances` CHANGE  `total_tweets_in_system` `total_posts_in_system` int(11) default '0';
ALTER TABLE  `tt_instances` CHANGE  `total_tweets_by_owner` `total_posts_by_owner` int(11) default '0';
ALTER TABLE  `tt_instances` CHANGE  `earliest_tweet_in_system` `earliest_post_in_system` datetime default NULL;
ALTER TABLE  `tt_instances` ADD  `network` VARCHAR( 10 ) NOT NULL DEFAULT  'twitter';

ALTER TABLE `tt_follows`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_instances`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_links`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_owners`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_owner_instances`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_plugins`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_plugin_options`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_posts`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_post_errors`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_replies`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_users`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_user_errors`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `tt_follows`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_instances`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_links`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_owners`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_owner_instances`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_plugins`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_plugin_options`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_posts`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_post_errors`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_user_errors`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_users`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `tt_replies`  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `tt_follows` CHANGE `network` `network` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'twitter';

ALTER TABLE `tt_instances` CHANGE `network_username` `network_username` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `network` `network` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'twitter';

ALTER TABLE `tt_links` CHANGE `url` `url` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `expanded_url` `expanded_url` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `title` `title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

ALTER TABLE `tt_owners` CHANGE `full_name` `full_name` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `user_name` `user_name` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `user_pwd` `user_pwd` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `user_email` `user_email` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `country` `country` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

ALTER TABLE `tt_plugins` CHANGE `name` `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `folder_name` `folder_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `description` `description` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `author` `author` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `homepage` `homepage` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `version` `version` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;

ALTER TABLE `tt_plugin_options` CHANGE `option_name` `option_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `option_value` `option_value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

ALTER TABLE `tt_posts` CHANGE `author_username` `author_username` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `author_fullname` `author_fullname` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `author_avatar` `author_avatar` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `post_text` `post_text` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `source` `source` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `network` `network` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'twitter';

ALTER TABLE `tt_replies` CHANGE `author_username` `author_username` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `author_fullname` `author_fullname` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `author_avatar` `author_avatar` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `post_text` `post_text` VARCHAR( 160 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `source` `source` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
CHANGE `network` `network` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'twitter';

ALTER TABLE `tt_users` CHANGE `user_name` `user_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `full_name` `full_name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `avatar` `avatar` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `location` `location` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `description` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
CHANGE `url` `url` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
CHANGE `network` `network` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'twitter',
CHANGE `found_in` `found_in` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;


