Exemplo n.º 1
0
        public bool UpgradeSchema(SqlSchemaUpgradeScripts scripts)
        {
            Validate();
            if (scripts.UpgradeScripts == null || scripts.UpgradeScripts.Length == 0)
                return false;

            String currentVersion = GetCurrentSchemaVersion();

            List<ScriptInfo> sortedScripts = PrepareScripts(scripts.UpgradeScripts);
            sortedScripts = sortedScripts.OrderBy(a => a.Version).ThenBy(a => a.Script.Name).ToList();
            var targetVersion = sortedScripts.Last().Version;
            if (String.Compare(currentVersion, targetVersion) >= 0)
            {
                Logger.TraceFormat("Database schema is up to date. (Version: '{0}')", currentVersion);
                return false;
            }

            return DoUpgrade(currentVersion, targetVersion, sortedScripts, scripts.AfterUpgradeScripts);
        }