PageRenderTime 17ms CodeModel.GetById 15ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1<cfcomponent extends="Abstract">
 2
 3	<cfset variables.sqlTypes = {}>
 4	<cfset variables.sqlTypes['primaryKey'] = "SERIAL PRIMARY KEY">
 5	<cfset variables.sqlTypes['binary'] = {name='BYTEA'}>
 6	<cfset variables.sqlTypes['boolean'] = {name='BOOLEAN'}>
 7	<cfset variables.sqlTypes['date'] = {name='DATE'}>
 8	<cfset variables.sqlTypes['datetime'] = {name='TIMESTAMP'}>
 9	<cfset variables.sqlTypes['decimal'] = {name='DECIMAL'}>
10	<cfset variables.sqlTypes['float'] = {name='FLOAT'}>
11	<cfset variables.sqlTypes['integer'] = {name='INTEGER'}>
12	<cfset variables.sqlTypes['string'] = {name='CHARACTER VARYING',limit=255}>
13	<cfset variables.sqlTypes['text'] = {name='TEXT'}>
14	<cfset variables.sqlTypes['time'] = {name='TIME'}>
15	<cfset variables.sqlTypes['timestamp'] = {name='TIMESTAMP'}>
16
17	<cffunction name="adapterName" returntype="string" access="public" hint="name of database adapter">
18		<cfreturn "PostgreSQL">
19	</cffunction>
20
21	<!--- postgres uses double quotes --->
22	<cffunction name="quoteColumnName" returntype="string" access="public" hint="surrounds column names with quotes">
23		<cfargument name="name" type="string" required="true" hint="column name">
24		<cfreturn '"#arguments.name#"'>
25	</cffunction>
26
27	<!--- createTable - use default --->
28	
29	<cffunction name="renameTable" returntype="string" access="public" hint="generates sql to rename a table">
30		<cfargument name="oldName" type="string" required="true" hint="old table name">
31		<cfargument name="newName" type="string" required="true" hint="new table name">
32		<cfreturn "ALTER TABLE #quoteTableName(arguments.oldName)# RENAME TO #quoteTableName(arguments.newName)#">
33	</cffunction>
34
35	<!--- dropTable - use default --->
36	
37	<!--- NOTE FOR addColumnToTable & changeColumnInTable 
38		  Rails adaptor appears to be applying default/nulls in separate queries
39		  Need to check if that is necessary --->
40	<!--- addColumnToTable - ? --->
41	<!--- changeColumnInTable - ? --->
42	
43	<!--- renameColumnInTable - use default --->
44	
45	<!--- dropColumnFromTable - use default --->
46	
47	<!--- addForeignKeyToTable - use default --->
48	
49	<cffunction name="dropForeignKeyFromTable" returntype="string" access="public" hint="generates sql to add a foreign key constraint to a table">
50		<cfargument name="name" type="string" required="true" hint="table name">
51		<cfargument name="keyName" type="any" required="true" hint="foreign key name">
52		<cfreturn "ALTER TABLE #quoteTableName(LCase(arguments.name))# DROP CONSTRAINT #quoteTableName(arguments.keyname)#">
53	</cffunction>
54	
55	<!--- foreignKeySQL - use default --->
56	
57	<!--- addIndex - use default --->
58	
59	<!--- removeIndex - use default --->
60
61</cfcomponent>