/plugins/dbmigrate/adapters/PostgreSQL.cfc
http://raihan.googlecode.com/ · ColdFusion CFScript · 61 lines · 46 code · 15 blank · 0 comment · 1 complexity · c975093af6ff8ad3ed055f3c1bfa9230 MD5 · raw file
- <cfcomponent extends="Abstract">
- <cfset variables.sqlTypes = {}>
- <cfset variables.sqlTypes['primaryKey'] = "SERIAL PRIMARY KEY">
- <cfset variables.sqlTypes['binary'] = {name='BYTEA'}>
- <cfset variables.sqlTypes['boolean'] = {name='BOOLEAN'}>
- <cfset variables.sqlTypes['date'] = {name='DATE'}>
- <cfset variables.sqlTypes['datetime'] = {name='TIMESTAMP'}>
- <cfset variables.sqlTypes['decimal'] = {name='DECIMAL'}>
- <cfset variables.sqlTypes['float'] = {name='FLOAT'}>
- <cfset variables.sqlTypes['integer'] = {name='INTEGER'}>
- <cfset variables.sqlTypes['string'] = {name='CHARACTER VARYING',limit=255}>
- <cfset variables.sqlTypes['text'] = {name='TEXT'}>
- <cfset variables.sqlTypes['time'] = {name='TIME'}>
- <cfset variables.sqlTypes['timestamp'] = {name='TIMESTAMP'}>
- <cffunction name="adapterName" returntype="string" access="public" hint="name of database adapter">
- <cfreturn "PostgreSQL">
- </cffunction>
- <!--- postgres uses double quotes --->
- <cffunction name="quoteColumnName" returntype="string" access="public" hint="surrounds column names with quotes">
- <cfargument name="name" type="string" required="true" hint="column name">
- <cfreturn '"#arguments.name#"'>
- </cffunction>
- <!--- createTable - use default --->
-
- <cffunction name="renameTable" returntype="string" access="public" hint="generates sql to rename a table">
- <cfargument name="oldName" type="string" required="true" hint="old table name">
- <cfargument name="newName" type="string" required="true" hint="new table name">
- <cfreturn "ALTER TABLE #quoteTableName(arguments.oldName)# RENAME TO #quoteTableName(arguments.newName)#">
- </cffunction>
- <!--- dropTable - use default --->
-
- <!--- NOTE FOR addColumnToTable & changeColumnInTable
- Rails adaptor appears to be applying default/nulls in separate queries
- Need to check if that is necessary --->
- <!--- addColumnToTable - ? --->
- <!--- changeColumnInTable - ? --->
-
- <!--- renameColumnInTable - use default --->
-
- <!--- dropColumnFromTable - use default --->
-
- <!--- addForeignKeyToTable - use default --->
-
- <cffunction name="dropForeignKeyFromTable" returntype="string" access="public" hint="generates sql to add a foreign key constraint to a table">
- <cfargument name="name" type="string" required="true" hint="table name">
- <cfargument name="keyName" type="any" required="true" hint="foreign key name">
- <cfreturn "ALTER TABLE #quoteTableName(LCase(arguments.name))# DROP CONSTRAINT #quoteTableName(arguments.keyname)#">
- </cffunction>
-
- <!--- foreignKeySQL - use default --->
-
- <!--- addIndex - use default --->
-
- <!--- removeIndex - use default --->
- </cfcomponent>