Skip to content

Commit

Permalink
FC-3053 Option to get all Destructive changes to the db
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Bryant committed Dec 2, 2015
1 parent b90865f commit bbe14fe
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/lib/db.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@
<cfargument name="stDiff" type="struct" required="true" hint="Conflict struct for a table" />
<cfargument name="propertyname" type="string" required="false" hint="Specific property" />
<cfargument name="indexname" type="string" required="false" hint="Specific index" />
<cfargument name="bIncludeDestructive" type="boolean" required="false" default="0" hint="Should we get destructive db changes?" />

<cfset var aChanges = arraynew(1) />
<cfset var stChange = structnew() />
Expand All @@ -865,7 +866,9 @@
</cfcase>
<cfcase value="-">
<!--- Don't drop columns by default. Code left in place as a reference. --->
<!--- <cfset arrayappend(aChanges,createChange(action="dropColumn",schema=arguments.stDiff.newMetadata,propertyname=arguments.propertyname)) /> --->
<cfif arguments.bIncludeDestructive>
<cfset arrayappend(aChanges,createChange(action="dropColumn",schema=arguments.stDiff.newMetadata,propertyname=arguments.propertyname)) />
</cfif>
</cfcase>
</cfswitch>
<cfelseif structkeyexists(arguments,"indexname")>
Expand All @@ -880,7 +883,9 @@
</cfcase>
<cfcase value="-">
<!--- Don't drop indexes by default. Code left in place as a reference. --->
<!--- <cfset arrayappend(aChanges,createChange(action="dropIndex",schema=arguments.stDiff.newMetadata,indexname=arguments.indexname)) /> --->
<cfif arguments.bIncludeDestructive>
<cfset arrayappend(aChanges,createChange(action="dropIndex",schema=arguments.stDiff.newMetadata,indexname=arguments.indexname)) />
</cfif>
</cfcase>
</cfswitch>
<cfelse><!--- Table diff --->
Expand All @@ -891,15 +896,17 @@
</cfcase>
<cfcase value="x">
<cfloop collection="#arguments.stDiff.fields#" item="arguments.propertyname">
<cfset aChanges = mergeChanges(aChanges,getDefaultChanges(stDiff=arguments.stDiff,propertyname=arguments.propertyname)) />
<cfset aChanges = mergeChanges(aChanges,getDefaultChanges(stDiff=arguments.stDiff,propertyname=arguments.propertyname,bIncludeDestructive=arguments.bIncludeDestructive)) />
</cfloop>
<cfloop collection="#arguments.stDiff.indexes#" item="arguments.indexname">
<cfset aChanges = mergeChanges(aChanges,getDefaultChanges(stDiff=arguments.stDiff,indexname=arguments.indexname)) />
<cfset aChanges = mergeChanges(aChanges,getDefaultChanges(stDiff=arguments.stDiff,indexname=arguments.indexname,bIncludeDestructive=arguments.bIncludeDestructive)) />
</cfloop>
</cfcase>
<cfcase value="-">
<!--- Don't drop tables by default. Code left in place as a reference. --->
<!--- <cfset arrayappend(aChanges,createChange(action="dropSchema",schema=arguments.stDiff.oldMetadata)) /> --->
<cfif arguments.bIncludeDestructive>
<cfset arrayappend(aChanges,createChange(action="dropSchema",schema=arguments.stDiff.oldMetadata)) />
</cfif>
</cfcase>
</cfswitch>
</cfif>
Expand Down

0 comments on commit bbe14fe

Please sign in to comment.