新增删除备份表

This commit is contained in:
xief 2022-01-08 16:14:40 +08:00
parent d494013dd6
commit 66569ddec1

View File

@ -34,6 +34,9 @@ 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;
@ -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}`");