Skip to content

Instantly share code, notes, and snippets.

@mhenke
Created April 14, 2011 15:21
Show Gist options
  • Save mhenke/919701 to your computer and use it in GitHub Desktop.
Save mhenke/919701 to your computer and use it in GitHub Desktop.
db migrations for wheels to rename columns
<cfcomponent extends="plugins.dbmigrate.Migration" hint="change primary keys to tablenameid">
<cffunction name="up">
<cfscript>
t = renameColumn(table='products',columnName='id',newColumnName='productid');
t = renameColumn(table='productlines',columnName='id',newColumnName='productlinesid');
t = renameColumn(table='departments',columnName='id',newColumnName='departmentsid');
t = renameColumn(table='categories',columnName='id',newColumnName='categoryid');
t = renameColumn(table='classes',columnName='id',newColumnName='classid');
t = renameColumn(table='subclasses',columnName='id',newColumnName='subclassid');
t.change();
</cfscript>
</cffunction>
<cffunction name="down">
<cfscript>
t = renameColumn(table='products',columnName='productid',newColumnName='id');
t = renameColumn(table='productlines',columnName='productlinesid',newColumnName='id');
t = renameColumn(table='departments',columnName='departmentsid',newColumnName='id');
t = renameColumn(table='categories',columnName='categoryid',newColumnName='id');
t = renameColumn(table='classes',columnName='classid',newColumnName='id');
t = renameColumn(table='subclasses',columnName='subclassid',newColumnName='id');
t.change();
</cfscript>
</cffunction>
</cfcomponent>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment