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