Skip to content

Commit 67d1741

Browse files
committed
db seed truncates trace logs for sanity
1 parent 871099b commit 67d1741

1 file changed

Lines changed: 25 additions & 30 deletions

File tree

ZkData/Migrations/Configuration.cs

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,17 @@ private static void InitializeBattleRatings(ZkDataContext db)
3535
});
3636
}
3737

38+
/// <summary>
39+
/// This method is called after migration to latest version
40+
/// </summary>
3841
protected override void Seed(ZkDataContext db) {
3942
/*InitializeBattleRatings(db); //remove this after execution
4043
db.SaveChanges();*/
4144

42-
// This method will be called after migrating to the latest version.
43-
if (GlobalConst.Mode == ModeType.Local)
44-
{
45-
// fill local DB with some basic test data
46-
db.MiscVars.AddOrUpdate(
47-
x => x.VarName,
48-
new MiscVar { VarName = "NightwatchPassword", VarValue = "dummy" },
49-
new MiscVar { VarName = "GithubHookKey", VarValue = "secret" });
50-
51-
if (!db.MiscVars.Any(y=>y.VarName=="SteamBuildPassword"))
52-
db.MiscVars.AddOrUpdate(x => x.VarName, new MiscVar { VarName = "SteamBuildPassword", VarValue = "secret" });
53-
54-
if (!db.MiscVars.Any(y => y.VarName == "GlacierSecretKey"))
55-
db.MiscVars.AddOrUpdate(x => x.VarName, new MiscVar { VarName = "GlacierSecretKey", VarValue = "secret" });
56-
57-
58-
db.Accounts.AddOrUpdate(
59-
x => x.Name,
60-
new Account
61-
{
62-
Name = "test",
63-
NewPasswordPlain = "test",
64-
AdminLevel = AdminLevel.SuperAdmin,
65-
Kudos = 200,
66-
Level = 50,
67-
Country = "cz"
68-
},
69-
new Account { Name = GlobalConst.NightwatchName, NewPasswordPlain = "dummy", IsBot = true, AdminLevel = AdminLevel.SuperAdmin});
70-
}
71-
45+
db.Database.ExecuteSqlCommand($"truncate table {nameof(LogEntries)}");
46+
47+
if (GlobalConst.Mode == ModeType.Local) LocalSeed(db);
48+
7249
db.Resources.AddOrUpdate(x=>x.InternalName, new Resource()
7350
{
7451
InternalName = "Zero-K $VERSION",
@@ -129,5 +106,23 @@ protected override void Seed(ZkDataContext db) {
129106
db.SaveChanges();
130107

131108
}
109+
110+
private static void LocalSeed(ZkDataContext db)
111+
{
112+
// fill local DB with some basic test data
113+
db.MiscVars.AddOrUpdate(x => x.VarName,
114+
new MiscVar { VarName = "NightwatchPassword", VarValue = "dummy" },
115+
new MiscVar { VarName = "GithubHookKey", VarValue = "secret" });
116+
117+
if (!db.MiscVars.Any(y => y.VarName == "SteamBuildPassword"))
118+
db.MiscVars.AddOrUpdate(x => x.VarName, new MiscVar { VarName = "SteamBuildPassword", VarValue = "secret" });
119+
120+
if (!db.MiscVars.Any(y => y.VarName == "GlacierSecretKey"))
121+
db.MiscVars.AddOrUpdate(x => x.VarName, new MiscVar { VarName = "GlacierSecretKey", VarValue = "secret" });
122+
123+
db.Accounts.AddOrUpdate(x => x.Name,
124+
new Account { Name = "test", NewPasswordPlain = "test", AdminLevel = AdminLevel.SuperAdmin, Kudos = 200, Level = 50, Country = "cz" },
125+
new Account { Name = GlobalConst.NightwatchName, NewPasswordPlain = "dummy", IsBot = true, AdminLevel = AdminLevel.SuperAdmin });
126+
}
132127
}
133128
}

0 commit comments

Comments
 (0)