TikiWashed

Tiki Database Column Name Search and Replace

Created by: Anonymous, Last modification: 07 May 2004 (20:47 UTC) by Andrew Slater
As an experiment related to our recent discussion about database column names I created a simple script which uses a search and replace utility to recursively replace all camelCapped column names so they would appear as: camel_capped. I used this great utility to do the searching/replacing. Here is an excerpt from the script:

Upgrading from Bonnie to ReleaseOne? Check out BonnieToReleaseOne for a script to update your database for use with a ReleaseOne install.


  1. tiki_categorized_objects
rrpl.sh catObjectId cat_object_id
rrpl.sh objId obj_id

  1. tiki_category_sites
rrpl.sh siteId site_id

  1. tiki_chart_items
rrpl.sh itemId item_id

  1. tiki_charts
rrpl.sh chartId chart_id
rrpl.sh singleItemVotes single_item_votes
rrpl.sh singleChartVotes single_chart_votes
rrpl.sh autoValidate auto_validate
rrpl.sh topN top_n
rrpl.sh maxVoteValue max_vote_value
rrpl.sh showAverage show_average
rrpl.sh isActive is_active
rrpl.sh showVotes show_votes
rrpl.sh useCookies use_cookies
rrpl.sh lastChart last_chart
rrpl.sh voteAgainAfter vote_again_after

  1. tiki_charts_rankings
rrpl.sh lastPosition last_position

  1. tiki_chat_channels
rrpl.sh channelId channel_id

  1. tiki_chat_messages
rrpl.sh messageId message_id
rrpl.sh channelId channel_id


and here is rrpl.sh (probably could have just used an alias):

  1. !/bin/sh
rpl -R $1 $2 *


It does a case-sensitive search and replace on all offending column names. Inital results look good. Fresh install went fine and nothing seems to be broken. Some variable names were changed as a side-effect (e.g. anywhere we had a variable named $blogId would now be $blog_id)

You can find the results of these changes here. If possible we should hammer away and make sure nothing was inadvertently broken. I tried to be as accurate as possible when writing the script but there is a chance of a misspelling in one of the 500+ lines. Anyone want to proof-read? (:wink:) SEWilco: fixed spelling in this paragraph (:cool:)