BonnieToReleaseOne
Script used to rename
Created by: Andrew Slater, Last modification: 07 May 2004 (20:44 UTC)
Here's a script which will generate a SQL script which can be used to rename all the column names in a bonnie db so they are compatible with a ReleaseOne install. Just run it the same directory as bitweaver_Bonnie_mysql.sql and it will output bonnie_to_clyde.sql. Import this sql script into your database interpreter and your database should be all set and ready to go!
<?php
// Andrew Slater 5/7/2004
// - Creates a SQL script for renaming all bonnie db table names to ReleaseOne db table names (bonnie_to_clyde.sql)
// - Requires bitweaver_Bonnie_mysql.sql to be present in the same path as this script is executed
$nameMap = array( 'activity_id' => 'activityId',
'p_id' => 'pId',
'is_auto_routed' => 'isAutoRouted',
'flow_num' => 'flowNum',
'is_interactive' => 'isInteractive',
'instance_id' => 'instanceId',
'c_id' => 'cId',
'next_activity' => 'nextActivity',
'next_user' => 'nextUser',
'is_valid' => 'isValid',
'is_active' => 'isActive',
'role_id' => 'roleId',
'act_from_id' => 'actFromId',
'act_to_id' => 'actToId',
'item_id' => 'itemId',
'order_id' => 'orderId',
'last_modified' => 'lastModif',
'page_name' => 'pageName',
'article_id' => 'articleId',
'author_name' => 'authorName',
'topic_id' => 'topicId',
'topic_name' => 'topicName',
'use_image' => 'useImage',
'publish_date' => 'publishDate',
'expire_date' => 'expireDate',
'is_float' => 'isFloat',
'banner_id' => 'bannerId',
'image_data' => 'imageData',
'image_type' => 'imageType',
'image_name' => 'imageName',
'html_data' => 'HTMLData',
'fixed_url_data' => 'fixedURLData',
'text_data' => 'textData',
'from_date' => 'fromDate',
'to_date' => 'toDate',
'use_dates' => 'useDates',
'hour_from' => 'hourFrom',
'hour_to' => 'hourTo',
'max_impressions' => 'maxImpressions',
'ban_id' => 'banId',
'content_id' => 'contentId',
'blog_id' => 'blogId',
'post_id' => 'postId',
'user_id' => 'userId',
'image_id' => 'imgId',
'post_id' => 'postId',
'max_posts' => 'maxPosts',
'cal_cat_id' => 'calcatId',
'calendar_id' => 'calendarId',
'cal_item_id' => 'calitemId',
'start_time' => 'startTime',
'end_time' => 'endTime',
'location_id' => 'locationId',
'category_id' => 'categoryId',
'cal_loc_id' => 'callocId',
'category_id' => 'categId',
'parent_id' => 'parentId',
'cat_object_id' => 'catObjectId',
'obj_id' => 'objId',
'site_id' => 'siteId',
'item_id' => 'itemId',
'chart_id' => 'chartId',
'single_item_votes' => 'singleItemVotes',
'single_chart_votes' => 'singleChartVotes',
'auto_validate' => 'autoValidate',
'top_n' => 'topN',
'max_vote_value' => 'maxVoteValue',
'show_average' => 'showAverage',
'is_active' => 'isActive',
'show_votes' => 'showVotes',
'use_cookies' => 'useCookies',
'last_chart' => 'lastChart',
'vote_again_after' => 'voteAgainAfter',
'last_position' => 'lastPosition',
'channel_id' => 'channelId',
'message_id' => 'messageId',
'channel_id' => 'channelId',
'thread_id' => 'threadId',
'object_type' => 'objectType',
'parent_id' => 'parentId',
'user_name' => 'userName',
'comment_date' => 'commentDate',
'content_id' => 'contentId',
'template_id' => 'templateId',
'cookie_id' => 'cookieId',
'copyright_id' => 'copyrightId',
'user_name' => 'userName',
'children_type' => 'childrenType',
'viewable_children' => 'viewableChildren',
'allow_sites' => 'allowSites',
'show_count' => 'showCount',
'editor_group' => 'editorGroup',
'site_id' => 'siteId',
'is_valid' => 'isValid',
'draw_id' => 'drawId',
'dsn_id' => 'dsnId',
'eph_id' => 'ephId',
'is_file' => 'isFile',
'extwiki_id' => 'extwikiId',
'question_id' => 'questionId',
'faq_id' => 'faqId',
'can_suggest' => 'canSuggest',
'gallery_id' => 'galleryId',
'max_rows' => 'maxRows',
'file_id' => 'fileId',
'att_id' => 'attId',
'thread_id' => 'threadId',
'q_id' => 'qId',
'forum_id' => 'forumId',
'last_post' => 'lastPost',
'control_flood' => 'controlFlood',
'flood_interval' => 'floodInterval',
'use_mail' => 'useMail',
'use_prune_unreplied' => 'usePruneUnreplied',
'prune_unreplied_age' => 'pruneUnrepliedAge',
'use_prune_old' => 'usePruneOld',
'prune_max_age' => 'pruneMaxAge',
'topics_per_page' => 'topicsPerPage',
'topics_ordering' => 'topicsOrdering',
'thread_ordering' => 'threadOrdering',
'q_id' => 'qId',
'parent_id' => 'parentId',
'forum_id' => 'forumId',
'gallery_id' => 'galleryId',
'row_images' => 'rowImages',
'thumb_size_x' => 'thumbSizeX',
'thumb_size_y' => 'thumbSizeY',
'game_name' => 'gameName',
'group_name' => 'groupName',
'include_group' => 'includeGroup',
'page_name' => 'pageName',
'image_id' => 'imageId',
'rep_id' => 'repID',
'rule_id' => 'ruleID',
'rep_id' => 'repID',
'module_id' => 'moduleId',
'cache_id' => 'cacheId',
'from_page' => 'fromPage',
'to_page' => 'toPage',
'event_id' => 'eventId',
'req_id' => 'reqId',
'seq_id' => 'seqId',
'sender_id' => 'senderId',
'c_id' => 'cId',
'msg_id' => 'msgId',
'mod_id' => 'modId',
'req_id' => 'reqId',
'account_id' => 'accountId',
'use_auth' => 'useAuth',
'smtp_port' => 'smtpPort',
'menu_id' => 'menuId',
'option_id' => 'optionId',
'menu_id' => 'menuId',
'event_id' => 'eventId',
'start_time' => 'startTime',
'end_time' => 'endTime',
'topic_id' => 'topicId',
'topic_id' => 'topicId',
'is_icon' => 'isIcon',
'module_id' => 'moduleId',
'nl_id' => 'nlId',
'last_sent' => 'lastSent',
'allow_user_sub' => 'allowUserSub',
'allow_any_sub' => 'allowAnySub',
'unsub_msg' => 'unsubMsg',
'validate_addr' => 'validateAddr',
'server_id' => 'serverId',
'group_name' => 'groupName',
'page_rank' => 'pageRank',
'poll_id' => 'pollId',
'option_id' => 'optionId',
'publish_date' => 'publishDate',
'message_id' => 'messageId',
'to_nickname' => 'toNickname',
'p_id' => 'pId',
'content_id' => 'contentId',
'publish_date' => 'publishDate',
'tag_id' => 'tagId',
'option_id' => 'optionId',
'question_id' => 'questionId',
'option_text' => 'optionText',
'quiz_id' => 'quizId',
'max_points' => 'maxPoints',
'result_id' => 'resultId',
'from_points' => 'fromPoints',
'to_points' => 'toPoints',
'quiz_name' => 'quizName',
'times_taken' => 'timesTaken',
'can_repeat' => 'canRepeat',
'store_results' => 'storeResults',
'questions_per_page' => 'questionsPerPage',
'time_limited' => 'timeLimited',
'time_limit' => 'timeLimit',
'received_article_id' => 'receivedArticleId',
'received_from_site' => 'receivedFromSite',
'received_from_user' => 'receivedFromUser',
'received_date' => 'receivedDate',
'author_name' => 'authorName',
'use_image' => 'useImage',
'publish_date' => 'publishDate',
'expire_date' => 'expireDate',
'received_page_id' => 'receivedPageId',
'related_to' => 'relatedTo',
'rss_ver' => 'rssVer',
'last_updated' => 'lastUpdated',
'rss_id' => 'rssId',
'last_updated' => 'lastUpdated',
'show_title' => 'showTitle',
'show_pub_date' => 'showPubDate',
'last_used' => 'lastUsed',
'last_updated' => 'lastUpdated',
'sem_name' => 'semName',
'edition_id' => 'editionId',
'session_id' => 'sessionId',
'msg_id' => 'msgId',
'sub_id' => 'subId',
'author_name' => 'authorName',
'topic_id' => 'topicId',
'topic_name' => 'topicName',
'use_image' => 'useImage',
'sfq_id' => 'sfqId',
'faq_id' => 'faqId',
'option_id' => 'optionId',
'question_id' => 'questionId',
'survey_id' => 'surveyId',
'tag_name' => 'tagName',
'obj_id' => 'objId',
'field_id' => 'fieldId',
'tracker_id' => 'trackerId',
'is_main' => 'isMain',
'is_table_visible' => 'isTblVisible',
'att_id' => 'attId',
'comment_id' => 'commentId',
'item_id' => 'itemId',
'show_status' => 'showStatus',
'show_last_modif' => 'showLastModif',
'use_comments' => 'useComments',
'use_attachments' => 'useAttachments',
'show_created' => 'showCreated',
'user_result_id' => 'userResultId',
'question_id' => 'questionId',
'folder_id' => 'folderId',
'parent_id' => 'parentId',
'url_id' => 'urlId',
'last_updated' => 'lastUpdated',
'account_id' => 'accountId',
'menu_id' => 'menuId',
'note_id' => 'noteId',
'pref_name' => 'prefName',
'time_taken' => 'timeTaken',
'max_points' => 'maxPoints',
'result_id' => 'resultId',
'user_result_id' => 'userResultId',
'task_id' => 'taskId',
'file_id' => 'fileId',
'is_file' => 'isFile',
'contact_id' => 'contactId',
'first_name' => 'firstName',
'last_name' => 'lastName',
'mail_id' => 'mailId',
'is_read' => 'isRead',
'is_replied' => 'isReplied',
'is_flagged' => 'isFlagged',
'group_name' => 'groupName',
'perm_name' => 'permName',
'group_home' => 'groupHome',
'group_desc' => 'groupDesc',
'object_type' => 'objectType',
'object_id' => 'objectId',
'perm_desc' => 'permDesc',
'real_name' => 'realName',
'last_login' => 'lastLogin',
'current_login' => 'currentLogin',
'registration_date' => 'registrationDate',
'avatar_name' => 'avatarName',
'avatar_size' => 'avatarSize',
'avatar_file_type' => 'avatarFileType',
'avatar_data' => 'avatarData',
'avatar_lib_name' => 'avatarLibName',
'avatar_type' => 'avatarType');
$fDatabase = fopen('bitweaver_Bonnie_mysql.sql','r');
if (!$fDatabase) {
print("Could not find bitweaver_Bonnie_mysql.sql");
exit();
}
$fScript = fopen('bonnie_to_clyde.sql','w');
if (!$fScript) {
print("Unable to open file for writing: bonnie_to_clyde.sql");
exit();
}
// Used to see if a line is declaring a column - if it's something else (such as an PRIMARY KEY def. etc.) it will return false
function IsGoodLine($token, $ignoreList) {
foreach ($ignoreList as $val) {
if (ereg($val,$token))
return false;
}
return true;
}
$ignoreList = array('PRIMARY', 'UNIQUE', 'KEY', '--', 'TYPE', 'FULLTEXT', 'DROP', 'AUTO_INCREMENT', 'IF');
while (!feof($fDatabase)) {
$line = fgets($fDatabase, 4096);
if (ereg('CREATE TABLE', $line)) {
$tokens = explode(' ',$line);
$tokens2 = ereg_replace('##PREFIX##','',$tokens2);
$curTable = str_replace('(','',$tokens2);
$curTable = trim($curTable);
fwrite($fScript,"\n-- $curTable\n");
} else {
$tokens = explode(' ',$line);
if (IsGoodLine($tokens2,$ignoreList))
if ($tokens2) {
$oldName = $tokens2;
$newName = trim(array_search($oldName, $nameMap));
if ($newName)
fwrite($fScript, "ALTER TABLE $curTable RENAME COLUMN \"$oldName\" TO $newName;\n");
}
}
}
fclose($fDatabase);
fclose($fScript);
?>
<?php
// Andrew Slater 5/7/2004
// - Creates a SQL script for renaming all bonnie db table names to ReleaseOne db table names (bonnie_to_clyde.sql)
// - Requires bitweaver_Bonnie_mysql.sql to be present in the same path as this script is executed
$nameMap = array( 'activity_id' => 'activityId',
'p_id' => 'pId',
'is_auto_routed' => 'isAutoRouted',
'flow_num' => 'flowNum',
'is_interactive' => 'isInteractive',
'instance_id' => 'instanceId',
'c_id' => 'cId',
'next_activity' => 'nextActivity',
'next_user' => 'nextUser',
'is_valid' => 'isValid',
'is_active' => 'isActive',
'role_id' => 'roleId',
'act_from_id' => 'actFromId',
'act_to_id' => 'actToId',
'item_id' => 'itemId',
'order_id' => 'orderId',
'last_modified' => 'lastModif',
'page_name' => 'pageName',
'article_id' => 'articleId',
'author_name' => 'authorName',
'topic_id' => 'topicId',
'topic_name' => 'topicName',
'use_image' => 'useImage',
'publish_date' => 'publishDate',
'expire_date' => 'expireDate',
'is_float' => 'isFloat',
'banner_id' => 'bannerId',
'image_data' => 'imageData',
'image_type' => 'imageType',
'image_name' => 'imageName',
'html_data' => 'HTMLData',
'fixed_url_data' => 'fixedURLData',
'text_data' => 'textData',
'from_date' => 'fromDate',
'to_date' => 'toDate',
'use_dates' => 'useDates',
'hour_from' => 'hourFrom',
'hour_to' => 'hourTo',
'max_impressions' => 'maxImpressions',
'ban_id' => 'banId',
'content_id' => 'contentId',
'blog_id' => 'blogId',
'post_id' => 'postId',
'user_id' => 'userId',
'image_id' => 'imgId',
'post_id' => 'postId',
'max_posts' => 'maxPosts',
'cal_cat_id' => 'calcatId',
'calendar_id' => 'calendarId',
'cal_item_id' => 'calitemId',
'start_time' => 'startTime',
'end_time' => 'endTime',
'location_id' => 'locationId',
'category_id' => 'categoryId',
'cal_loc_id' => 'callocId',
'category_id' => 'categId',
'parent_id' => 'parentId',
'cat_object_id' => 'catObjectId',
'obj_id' => 'objId',
'site_id' => 'siteId',
'item_id' => 'itemId',
'chart_id' => 'chartId',
'single_item_votes' => 'singleItemVotes',
'single_chart_votes' => 'singleChartVotes',
'auto_validate' => 'autoValidate',
'top_n' => 'topN',
'max_vote_value' => 'maxVoteValue',
'show_average' => 'showAverage',
'is_active' => 'isActive',
'show_votes' => 'showVotes',
'use_cookies' => 'useCookies',
'last_chart' => 'lastChart',
'vote_again_after' => 'voteAgainAfter',
'last_position' => 'lastPosition',
'channel_id' => 'channelId',
'message_id' => 'messageId',
'channel_id' => 'channelId',
'thread_id' => 'threadId',
'object_type' => 'objectType',
'parent_id' => 'parentId',
'user_name' => 'userName',
'comment_date' => 'commentDate',
'content_id' => 'contentId',
'template_id' => 'templateId',
'cookie_id' => 'cookieId',
'copyright_id' => 'copyrightId',
'user_name' => 'userName',
'children_type' => 'childrenType',
'viewable_children' => 'viewableChildren',
'allow_sites' => 'allowSites',
'show_count' => 'showCount',
'editor_group' => 'editorGroup',
'site_id' => 'siteId',
'is_valid' => 'isValid',
'draw_id' => 'drawId',
'dsn_id' => 'dsnId',
'eph_id' => 'ephId',
'is_file' => 'isFile',
'extwiki_id' => 'extwikiId',
'question_id' => 'questionId',
'faq_id' => 'faqId',
'can_suggest' => 'canSuggest',
'gallery_id' => 'galleryId',
'max_rows' => 'maxRows',
'file_id' => 'fileId',
'att_id' => 'attId',
'thread_id' => 'threadId',
'q_id' => 'qId',
'forum_id' => 'forumId',
'last_post' => 'lastPost',
'control_flood' => 'controlFlood',
'flood_interval' => 'floodInterval',
'use_mail' => 'useMail',
'use_prune_unreplied' => 'usePruneUnreplied',
'prune_unreplied_age' => 'pruneUnrepliedAge',
'use_prune_old' => 'usePruneOld',
'prune_max_age' => 'pruneMaxAge',
'topics_per_page' => 'topicsPerPage',
'topics_ordering' => 'topicsOrdering',
'thread_ordering' => 'threadOrdering',
'q_id' => 'qId',
'parent_id' => 'parentId',
'forum_id' => 'forumId',
'gallery_id' => 'galleryId',
'row_images' => 'rowImages',
'thumb_size_x' => 'thumbSizeX',
'thumb_size_y' => 'thumbSizeY',
'game_name' => 'gameName',
'group_name' => 'groupName',
'include_group' => 'includeGroup',
'page_name' => 'pageName',
'image_id' => 'imageId',
'rep_id' => 'repID',
'rule_id' => 'ruleID',
'rep_id' => 'repID',
'module_id' => 'moduleId',
'cache_id' => 'cacheId',
'from_page' => 'fromPage',
'to_page' => 'toPage',
'event_id' => 'eventId',
'req_id' => 'reqId',
'seq_id' => 'seqId',
'sender_id' => 'senderId',
'c_id' => 'cId',
'msg_id' => 'msgId',
'mod_id' => 'modId',
'req_id' => 'reqId',
'account_id' => 'accountId',
'use_auth' => 'useAuth',
'smtp_port' => 'smtpPort',
'menu_id' => 'menuId',
'option_id' => 'optionId',
'menu_id' => 'menuId',
'event_id' => 'eventId',
'start_time' => 'startTime',
'end_time' => 'endTime',
'topic_id' => 'topicId',
'topic_id' => 'topicId',
'is_icon' => 'isIcon',
'module_id' => 'moduleId',
'nl_id' => 'nlId',
'last_sent' => 'lastSent',
'allow_user_sub' => 'allowUserSub',
'allow_any_sub' => 'allowAnySub',
'unsub_msg' => 'unsubMsg',
'validate_addr' => 'validateAddr',
'server_id' => 'serverId',
'group_name' => 'groupName',
'page_rank' => 'pageRank',
'poll_id' => 'pollId',
'option_id' => 'optionId',
'publish_date' => 'publishDate',
'message_id' => 'messageId',
'to_nickname' => 'toNickname',
'p_id' => 'pId',
'content_id' => 'contentId',
'publish_date' => 'publishDate',
'tag_id' => 'tagId',
'option_id' => 'optionId',
'question_id' => 'questionId',
'option_text' => 'optionText',
'quiz_id' => 'quizId',
'max_points' => 'maxPoints',
'result_id' => 'resultId',
'from_points' => 'fromPoints',
'to_points' => 'toPoints',
'quiz_name' => 'quizName',
'times_taken' => 'timesTaken',
'can_repeat' => 'canRepeat',
'store_results' => 'storeResults',
'questions_per_page' => 'questionsPerPage',
'time_limited' => 'timeLimited',
'time_limit' => 'timeLimit',
'received_article_id' => 'receivedArticleId',
'received_from_site' => 'receivedFromSite',
'received_from_user' => 'receivedFromUser',
'received_date' => 'receivedDate',
'author_name' => 'authorName',
'use_image' => 'useImage',
'publish_date' => 'publishDate',
'expire_date' => 'expireDate',
'received_page_id' => 'receivedPageId',
'related_to' => 'relatedTo',
'rss_ver' => 'rssVer',
'last_updated' => 'lastUpdated',
'rss_id' => 'rssId',
'last_updated' => 'lastUpdated',
'show_title' => 'showTitle',
'show_pub_date' => 'showPubDate',
'last_used' => 'lastUsed',
'last_updated' => 'lastUpdated',
'sem_name' => 'semName',
'edition_id' => 'editionId',
'session_id' => 'sessionId',
'msg_id' => 'msgId',
'sub_id' => 'subId',
'author_name' => 'authorName',
'topic_id' => 'topicId',
'topic_name' => 'topicName',
'use_image' => 'useImage',
'sfq_id' => 'sfqId',
'faq_id' => 'faqId',
'option_id' => 'optionId',
'question_id' => 'questionId',
'survey_id' => 'surveyId',
'tag_name' => 'tagName',
'obj_id' => 'objId',
'field_id' => 'fieldId',
'tracker_id' => 'trackerId',
'is_main' => 'isMain',
'is_table_visible' => 'isTblVisible',
'att_id' => 'attId',
'comment_id' => 'commentId',
'item_id' => 'itemId',
'show_status' => 'showStatus',
'show_last_modif' => 'showLastModif',
'use_comments' => 'useComments',
'use_attachments' => 'useAttachments',
'show_created' => 'showCreated',
'user_result_id' => 'userResultId',
'question_id' => 'questionId',
'folder_id' => 'folderId',
'parent_id' => 'parentId',
'url_id' => 'urlId',
'last_updated' => 'lastUpdated',
'account_id' => 'accountId',
'menu_id' => 'menuId',
'note_id' => 'noteId',
'pref_name' => 'prefName',
'time_taken' => 'timeTaken',
'max_points' => 'maxPoints',
'result_id' => 'resultId',
'user_result_id' => 'userResultId',
'task_id' => 'taskId',
'file_id' => 'fileId',
'is_file' => 'isFile',
'contact_id' => 'contactId',
'first_name' => 'firstName',
'last_name' => 'lastName',
'mail_id' => 'mailId',
'is_read' => 'isRead',
'is_replied' => 'isReplied',
'is_flagged' => 'isFlagged',
'group_name' => 'groupName',
'perm_name' => 'permName',
'group_home' => 'groupHome',
'group_desc' => 'groupDesc',
'object_type' => 'objectType',
'object_id' => 'objectId',
'perm_desc' => 'permDesc',
'real_name' => 'realName',
'last_login' => 'lastLogin',
'current_login' => 'currentLogin',
'registration_date' => 'registrationDate',
'avatar_name' => 'avatarName',
'avatar_size' => 'avatarSize',
'avatar_file_type' => 'avatarFileType',
'avatar_data' => 'avatarData',
'avatar_lib_name' => 'avatarLibName',
'avatar_type' => 'avatarType');
$fDatabase = fopen('bitweaver_Bonnie_mysql.sql','r');
if (!$fDatabase) {
print("Could not find bitweaver_Bonnie_mysql.sql");
exit();
}
$fScript = fopen('bonnie_to_clyde.sql','w');
if (!$fScript) {
print("Unable to open file for writing: bonnie_to_clyde.sql");
exit();
}
// Used to see if a line is declaring a column - if it's something else (such as an PRIMARY KEY def. etc.) it will return false
function IsGoodLine($token, $ignoreList) {
foreach ($ignoreList as $val) {
if (ereg($val,$token))
return false;
}
return true;
}
$ignoreList = array('PRIMARY', 'UNIQUE', 'KEY', '--', 'TYPE', 'FULLTEXT', 'DROP', 'AUTO_INCREMENT', 'IF');
while (!feof($fDatabase)) {
$line = fgets($fDatabase, 4096);
if (ereg('CREATE TABLE', $line)) {
$tokens = explode(' ',$line);
$tokens2 = ereg_replace('##PREFIX##','',$tokens2);
$curTable = str_replace('(','',$tokens2);
$curTable = trim($curTable);
fwrite($fScript,"\n-- $curTable\n");
} else {
$tokens = explode(' ',$line);
if (IsGoodLine($tokens2,$ignoreList))
if ($tokens2) {
$oldName = $tokens2;
$newName = trim(array_search($oldName, $nameMap));
if ($newName)
fwrite($fScript, "ALTER TABLE $curTable RENAME COLUMN \"$oldName\" TO $newName;\n");
}
}
}
fclose($fDatabase);
fclose($fScript);
?>