public static bool CheckDatabase(IDbConnection connection, IDatabaseImplementation implementation, IDatabaseSchemaFactory databaseSchemaFactory, string requiredProduct, string requiredVersion)
        {
            DatabaseManager manager = new DatabaseManager(connection, implementation, databaseSchemaFactory, requiredProduct);

            string fromVersion;

            // Get the current version of the database:
            if (manager.VersionTableExists())
            {
                try
                {
                    DatabaseVersion version = manager.GetVersion();

                    fromVersion = version.Version;
                }
                catch (DatabaseVersionTableInvalidException ex)
                {
                    using (WindowsDatabaseUpgrader upgrader = new WindowsDatabaseUpgrader())
                    {
                        upgrader.ShowError("Database Version Problem", ex.Message);
                        upgrader.ShowDialog();

                        return false;
                    }
                }
            }
            else
            {
                fromVersion = DatabaseManager.UninitialisedVersion;
            }

            // Exit unless an upgrade is needed:
            if (fromVersion == requiredVersion) return true;

            // Try to upgrade:
            if (!manager.CanUpgrade(fromVersion, requiredVersion))
            {
                using (WindowsDatabaseUpgrader upgrader = new WindowsDatabaseUpgrader())
                {
                    upgrader.ShowError("No Upgrade Available", String.Format(
                        "There is no upgrade available from version {0} to " +
                        "version {1}. This database can not be used.",
                        fromVersion, requiredVersion));
                    upgrader.ShowDialog();

                    return false;
                }
            }

            using (WindowsDatabaseUpgrader upgrader = new WindowsDatabaseUpgrader())
            {
                upgrader._manager = manager;
                upgrader._fromVersion = fromVersion;
                upgrader._toVersion = requiredVersion;

                DialogResult result = upgrader.ShowDialog();

                return result == DialogResult.OK;
            }
        }
        public void UpdateIfRequired(DatabaseManager.UpgradeProgressDelegate progressDelegate)
        {
            string fromVersion = GetVersion();

            // Exit unless an upgrade is needed:
            if (fromVersion == _requiredVersion) return;

            _manager.Upgrade(fromVersion, _requiredVersion, progressDelegate);
        }
 public DatabaseUpgrader(IDbConnection connection, IDatabaseImplementation implementation, IDatabaseSchemaFactory factory, string requiredProduct, string requiredVersion)
 {
     _manager = new DatabaseManager(connection, implementation, factory, requiredProduct);
     _requiredVersion = requiredVersion;
 }