新增删除备份表
This commit is contained in:
		| @@ -34,10 +34,13 @@ namespace Chenfeng.MES.Archiver.Commands | ||||
|         [CommandOption("restore", Description = "回复表")] | ||||
|         public bool Restore { get; set; } = false; | ||||
|  | ||||
|         [CommandOption("rm-backup", Description = "删除备份表")] | ||||
|         public bool RemoveBackup { get; set; } | ||||
|  | ||||
|         [CommandOption("timeout", Description = "sql命令超时时间")] | ||||
|         public int Timeout { get; set; } = 3; | ||||
|  | ||||
|  | ||||
|         | ||||
|  | ||||
|         public ValueTask ExecuteAsync(IConsole console) | ||||
|         { | ||||
| @@ -51,7 +54,11 @@ namespace Chenfeng.MES.Archiver.Commands | ||||
|  | ||||
|             SqlMapper.Settings.CommandTimeout = 60 * Timeout; | ||||
|  | ||||
|             if (Restore) | ||||
|             if (RemoveBackup) | ||||
|             { | ||||
|                 console.Output.WriteLine("删除备份表"); | ||||
|             } | ||||
|             else if (Restore) | ||||
|             { | ||||
|                 console.Output.WriteLine("还原备份表"); | ||||
|             } | ||||
| @@ -175,7 +182,11 @@ namespace Chenfeng.MES.Archiver.Commands | ||||
|  | ||||
|             foreach (var item in list) | ||||
|             { | ||||
|                 if (Restore) | ||||
|                 if (RemoveBackup) | ||||
|                 { | ||||
|                     Db.Execute($"DROP TABLE IF EXISTS `{item.Table}_bak`"); | ||||
|                 } | ||||
|                 else if (Restore) | ||||
|                 { | ||||
|                     Db.Execute($"DROP TABLE IF EXISTS `{item.Table}`"); | ||||
|                     Db.Execute($"RENAME TABLE `{item.Table}_bak` TO `{item.Table}`"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 xief
					xief