Menu

#735 SqlExtension will incorrectly drop an existing database!

v3.0
closed
2012-09-15
2006-11-28
Rob
No

The SqlExtension will delete an existing database on rollback (this is an existing bug). However... if the ConfirmOverwrite attribute is set to "yes" and the user answers "No" to the prompt "Database X already exists do you wish to continue" the install is halted and rolled back.

This results in the database being deleted!

Here's the xml:

<Sql:SqlDatabase Id="db01" Server="." Database="Payroll" CreateOnInstall="yes" ConfirmOverwrite="yes" DropOnUninstall="no"/>

Deleting an existing database without explicit instructions to do so is a very bad thing. On a production SQL server the database could be quite important (eg. DeveloperPayrollDb) and possibly not backed up. This could result in a serious data loss situation (just an ugly scenario).

The SQL extension may need to record its intention to create a database, and then the rollback "drop database" would only be invoked if there was an intention to create a database. Maybe this means the check of an existing database and confirm overwrite will need to move into an earlier phase (where it can write a property).

Discussion

  • Michael Osmond

    Michael Osmond - 2006-12-18

    Logged In: YES
    user_id=1463519
    Originator: NO

    Need to add here that this also effects Major Upgrades. At the moment when you are doing the install part of the upgrade and there is some sort of error and rollback, the SQL Custom action will drop the database, that it was meant to upgrade.

    At the moment I have modified the CA and commented out the call to schedule the drop database on rollback.

    Recommendation - given the number of scenarios that exist for the rollback of a database on install being possible; ie: clean install with existing target, clean instal with no database, install phase of a major upgrade; I think it would be best that the drop on rollback be controlled by a property that the author could control.

    Or perhaps - there are options for DropDatabaseOnRollback that include "never,onlyOnCreate,prompt,always" (onlyOnCreate would be where the CA actually performed the Create statement).

     
  • Rob Mensching

    Rob Mensching - 2007-01-09

    Logged In: YES
    user_id=991639
    Originator: NO

    This has been fixed in WiX v2 by only scheduling the rollback of the database, if the database does not exist before the install. Dropping a database that existed before the install of the same database is a great way to lose data.

    Anyway, this will be fixed when I port all the WiX v2 fixes up to WiX v3.

     
  • Peter Varga

    Peter Varga - 2007-02-28

    Logged In: YES
    user_id=1530533
    Originator: NO

    At the moment I show a warning dialog before the installation begins with a text something like this:

    If a valid XCB database already exists and you want to use it further on, please make a backup of it. Do not select XCB to be installed in this case. If XCB already exists and you choose to install the database, it will be replaced by a new and empty one.

    Because of a bug in Windows Installer the existing XCB database will be dropped during the rollback if the installation fails also if you cancel the installation.

    But I'm afraid this is not a very elegant solution to deliver a project to the customer.

    When do you think are you ready with the fix for v3?

    Regards

     
  • pmarcu

    pmarcu - 2007-10-04

    Logged In: YES
    user_id=1612676
    Originator: NO

    This should have been ported to WiX v3 by now.

     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 15 days (the time period specified by
    the administrator of this Tracker).