I am creating installer for Creating the databaase using WIX. But I could not able to find a way to run the udate script during Upgrade.
Code for Create DB
<Directory Id="DFDB" Name="DealFoundryDataBase" FileSource="$(var.SolutionDir)DealFoundrySetup/DataBaseScripts">
<Component Id='SqlComponent_Files' Guid='{07DB58E6-5AFC-4BB0-84EC-C5EC6B0E5CA7}' KeyPath='yes'>
<File Id="CreateTable_sql" Name="CreateTable.sql"/>
<File Id="InsertStatements_sql" Name="InsertStatements.sql"/>
<File Id="DFCoreScript_sql" Name="DFCoreScript.sql"/>
</Component>
<Component Id='SqlComponent' Guid='{C5412828-84FB-4CC5-AC71-AC246B9D09E8}' KeyPath='yes'>
<Condition><![CDATA[NOT OLDER_VERSION_FOUND]]> </Condition>
<sql:SqlDatabase Id='SqlDatabase' Database='[PRO_DFDATABASE_NAME]' User='SQLUser' Server='[PRO_DFDATABASE_SOURCE]'
CreateOnInstall='yes' DropOnUninstall='yes' ContinueOnError='yes'>
<sql:SqlScript Id='CreateTable' BinaryKey='CreateTable' ExecuteOnInstall='yes' />
<!--<sql:SqlScript Id='InsertStatements' BinaryKey='InsertStatements' ExecuteOnInstall='yes'/>-->
</sql:SqlDatabase>
</Component>
</Directory>
<Binary Id ='CreateTable' SourceFile='$(var.SolutionDir)DealFoundrySetup/DataBaseScripts/DFCoreScript.sql'/>
<Binary Id ='InsertStatements' SourceFile='$(var.SolutionDir)DealFoundrySetup/DataBaseScripts/InsertStatements.sql'/>
<Binary Id ='MasterData' SourceFile='$(var.SolutionDir)DealFoundrySetup/DataBaseScripts/MasterData.sql'/>
<util:User Id='SQLUser' Name='[PRO_DFDATABASE_USERID]' Password='[PRO_DFDATABASE_PASSWORD]' />
The above lines of code is working fine for creting the DB on Install, but I want to run the update script during upgrade on Existing DB Plz Help me. Thanks in Advance.
Ahh... Versioning. So much fun.
First, make sure you have your tags set in the installer. Here is what I usually do (and this is rather complicated because you might want to check for specific versions to do different upgrade scripts):
You can have as many of these "versions" defined as you want, and maybe each one will run a different upgrade script for your database. They will set the properties defined in this list.
Secondly, WiX defines a well known value 'Installed' that is only used when you are doing an uninstall or upgrade: http://msdn.microsoft.com/library/aa369297.aspx
So if you wish to only run it ONLY while doing an upgrade, you should use this:
If you want to run it if you are doing an upgrade or installing, it should be this way:
Which is the same as not having a condition at all since it will always be true.