예제 #1
0
        public void applyScripts(ScriptVersion currentVersion)
        {
            foreach (IScript <ITextScriptTarget> script in scriptSource.Scripts)
            {
                if (script.Version.Major < currentVersion.Major)
                {
                    if (skippedMajor.Contains(script.Version.Major))
                    {
                        continue;
                    }

                    skippedMajor.Add(script.Version.Major);
                    Console.WriteLine("Skipping release: {0}.x", script.Version.Major);
                }
                else if (script.Version.Major == currentVersion.Major && script.Version.Minor < currentVersion.Minor)
                {
                    if (skippedMinor.Contains(script.Version.Minor))
                    {
                        continue;
                    }

                    skippedMinor.Add(script.Version.Minor);
                    Console.WriteLine("Skipping release: {0}.{1}", script.Version.Major, script.Version.Minor);
                }
                else if (options.MaxPatch != null && script.Version.Patch > options.MaxPatch.Value)
                {
                    Console.WriteLine("Stopping at maximum patch {0}", options.MaxPatch);
                    return;
                }
                else
                {
                    existingPatches = existingPatches ?? scriptTarget.getPatches(currentVersion.Major, currentVersion.Minor);
                    if (existingPatches.Contains(script.Version))
                    {
                        Console.WriteLine("Skipping patch: {0}", script);
                        continue;
                    }

                    Console.WriteLine("Running: {0}", script);
                    script.apply(scriptTarget, options);

                    if (scriptTarget.CurrentVersion.CompareTo(currentVersion) > 0)
                    {
                        currentVersion = scriptTarget.CurrentVersion;
                    }
                }
            }
        }
예제 #2
0
        public static void executeRelease(Options options)
        {
            SqlDatabase scriptTarget = new SqlDatabase(options);

            String releasePath = Path.Combine(options.Path, "Release");

            ScriptVersion currentVersion = scriptTarget.CurrentVersion;                                                     // only reads version once and relies on scripts executing in proper order

            foreach (String releaseDirectoryPath in Directory.GetDirectories(options.Path, "*"))
            {
                if (!releaseDirectoryPath.startsWithIgnoreCase(releasePath))        // case insensitive directory scan
                {
                    continue;
                }

                IScriptSource <ITextScriptTarget> scriptSource = new FolderContainingNumberedSqlScripts(releaseDirectoryPath, "*.sql");
                Updater updater = new Updater(scriptSource, scriptTarget, options);
                updater.applyScripts(currentVersion);
            }
        }
 public NumberedTextScript(FileInfo fileInfo, int major, int minor, long scriptNumber, string description)
 {
     path    = fileInfo.FullName;
     Version = new ScriptVersion(major, minor, scriptNumber, fileInfo.LastWriteTime, Environment.MachineName, description);
 }