Lubert
Posts: 14
Joined: Mon Jan 04, 2021 8:36 am

Database lost on upgrade

Mon Jan 04, 2021 9:50 am

We have created an installer for an application that uses a database.

The installer creates some tables on installation and removes them on deinstallation...
(simple sql-scripts executed on install/uninstall)

Now we want to create an upgrade for some installations of our application. Unfortunately the
database is being removed and then created new when an upgrade is being installed.

Thats bad, because all the stored data is gone then...:(
Is there a way to keep the old database on an upgrade?

If that is not possible, how should we design our installer that it would be possible in the future?

Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Database lost on upgrade

Wed Jan 06, 2021 2:12 pm

Hi and welcome to our forums.

Indeed, during an uninstall/upgrade, all the files installed by the old version are removed from the machine. Is your database removed by an SQL script or it is just a file that should be kept on the machine?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Lubert
Posts: 14
Joined: Mon Jan 04, 2021 8:36 am

Re: Database lost on upgrade

Thu Jan 07, 2021 8:32 am

The database is being removed by a SQL script - executed on uninstall...

Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Database lost on upgrade

Thu Jan 07, 2021 12:43 pm

Hi,

In order to skip an SQL Script execution during an uninstall, you can uncheck the "at uninstall" execution option for it.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Lubert
Posts: 14
Joined: Mon Jan 04, 2021 8:36 am

Re: Database lost on upgrade

Thu Jan 07, 2021 5:01 pm

I know but our first version had that checkbox checked. If we now install an upgrade - the old version
will removed and so that sql-script will be executed and the database is lost...

Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Database lost on upgrade

Mon Jan 11, 2021 1:02 pm

Hi,

Indeed, if a true condition was set for that SQL script in the old version, it will be executed on the uninstall of that version.

In this case, you can try to preserve the database by using one of the methods below:
- add an SQL Query before the "Remove Resources" action group from the "Custom Actions" page that will preserve the database before it is removed
- create a custom action that backs up the database's related file before the uninstall of the old version and restores it after the installation of the new version

Let me know if this helped, otherwise give me more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Lubert
Posts: 14
Joined: Mon Jan 04, 2021 8:36 am

Re: Database lost on upgrade

Tue Jan 12, 2021 3:31 pm

Hello Eusebiu,

The solution you described helped. We also discoverd another way to keep the existing database:

We just kept the old version (Upgrades->Customize Advaned Installer upgrade rules->Upgrade Action=Detect only, placing results in property) :-)

Thanks and BR
Lubert

Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Database lost on upgrade

Thu Jan 14, 2021 3:37 pm

You're welcome, Lubert. I'm glad you solved this.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”