Permalink
Browse files

Making -v parameter optional

  • Loading branch information...
1 parent a060657 commit 116a6731945e03cf679486d82f9f614c2dbda8f4 @yurigorokhov committed Jun 15, 2012
Showing with 27 additions and 41 deletions.
  1. +24 −27 src/mindtouch.db/updateDb.cs
  2. +3 −14 src/mindtouch.dream/Data/ADataUpdater.cs
@@ -125,7 +125,6 @@ internal class DBConnection {
// If there are no custom methods specified we need a version number
if(customMethod == null) {
- CheckArg(targetVersion, "No version specified");
CheckArg(dbname, "No Database was specified");
}
@@ -220,34 +219,32 @@ internal class DBConnection {
}
// Execute update methods
- if(targetVersion != null) {
- site.LoadMethods(dllAssembly);
- List<string> methods;
- if(checkdb) {
- methods = site.GetDataIntegrityMethods();
- } else {
- methods = site.GetMethods();
- }
+ site.LoadMethods(dllAssembly);
+ List<string> methods;
+ if(checkdb) {
+ methods = site.GetDataIntegrityMethods();
+ } else {
+ methods = site.GetMethods();
+ }
- // Execute each method
- foreach(var method in methods) {
- if(verbose) {
- Console.WriteLine(String.Format("Executing method: {0}", method));
+ // Execute each method
+ foreach(var method in methods) {
+ if(verbose) {
+ Console.WriteLine(String.Format("Executing method: {0}", method));
+ }
+ if(!dryrun) {
+ try { site.TestConnection(); } catch(Exception) {
+ System.Threading.Thread.Sleep(5000);
+ site.TestConnection();
}
- if(!dryrun) {
- try { site.TestConnection(); } catch(Exception) {
- System.Threading.Thread.Sleep(5000);
- site.TestConnection();
- }
- try {
- site.ExecuteMethod(method);
- } catch(Exception ex) {
- Console.WriteLine(string.Format("\n --- Error occured in method {0}: \n\n{1}", method, ex.StackTrace));
- if(checkdb) {
- continue;
- } else {
- break;
- }
+ try {
+ site.ExecuteMethod(method);
+ } catch(Exception ex) {
+ Console.WriteLine(string.Format("\n --- Error occured in method {0}: \n\n{1}", method, ex.StackTrace));
+ if(checkdb) {
+ continue;
+ } else {
+ break;
}
}
}
@@ -96,10 +96,7 @@ public abstract class ADataUpdater : IDataUpdater {
/// <returns> The string representation of the target version</returns>
public string TargetVersion {
get {
- if(_targetVersion == null) {
- return "";
- }
- return _targetVersion.ToString();
+ return _targetVersion == null ? "" : _targetVersion.ToString();
}
set {
_targetVersion = new VersionInfo(value);
@@ -115,10 +112,7 @@ public abstract class ADataUpdater : IDataUpdater {
/// <returns> The string representation of the source version</returns>
public string SourceVersion {
get {
- if(_sourceVersion == null) {
- return "";
- }
- return _sourceVersion.ToString();
+ return _sourceVersion == null ? "" : _sourceVersion.ToString();
}
set {
_sourceVersion = new VersionInfo(value);
@@ -171,11 +165,6 @@ public abstract class ADataUpdater : IDataUpdater {
/// <returns></returns>
public virtual void LoadMethods(Assembly updateAssembly) {
- // Make sure we have a defined version
- if(_targetVersion == null) {
- throw new VersionInfoException(_targetVersion);
- }
-
// get all the members of the Assembly
var types = updateAssembly.GetTypes();
@@ -205,7 +194,7 @@ public abstract class ADataUpdater : IDataUpdater {
} else {
continue;
}
- if(version.CompareTo(_targetVersion).Change != VersionChange.Upgrade &&
+ if( (_targetVersion == null || version.CompareTo(_targetVersion).Change != VersionChange.Upgrade ) &&
(_sourceVersion == null || version.CompareTo(_sourceVersion).Change != VersionChange.Downgrade )) {
_methodList.Add(new DbMethod(methodInfo, version, type));
}

0 comments on commit 116a673

Please sign in to comment.