@@ -35,47 +35,19 @@ 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 var ago = DateTime . UtcNow . AddDays ( - GlobalConst . LadderActivityDays ) ;
4043 db . Accounts . Where ( x => x . LastLogin > ago ) . ForEach ( x =>
4144 {
4245 x . Rank = Math . Max ( 0 , Math . Min ( 7 , ( int ) ( x . AccountRatings . Where ( a => a . RatingCategory == RatingCategory . Casual ) . Select ( a => a . RealElo ) . DefaultIfEmpty ( 1500 ) . FirstOrDefault ( ) - 1000 ) / 200 ) ) ;
4346 } ) ;
4447 db . SaveChanges ( ) ;
45-
46- // This method will be called after migrating to the latest version.
47- if ( GlobalConst . Mode == ModeType . Local )
48- {
49- // fill local DB with some basic test data
50- db . MiscVars . AddOrUpdate (
51- x => x . VarName ,
52- new MiscVar { VarName = "NightwatchPassword" , VarValue = "dummy" } ,
53- new MiscVar { VarName = "GithubHookKey" , VarValue = "secret" } ) ;
54-
55- if ( ! db . MiscVars . Any ( y=> y . VarName == "SteamBuildPassword" ) )
56- db . MiscVars . AddOrUpdate ( x => x . VarName , new MiscVar { VarName = "SteamBuildPassword" , VarValue = "secret" } ) ;
57-
58- if ( ! db . MiscVars . Any ( y => y . VarName == "GlacierSecretKey" ) )
59- db . MiscVars . AddOrUpdate ( x => x . VarName , new MiscVar { VarName = "GlacierSecretKey" , VarValue = "secret" } ) ;
60-
61-
62- db . Accounts . AddOrUpdate (
63- x => x . Name ,
64- new Account
65- {
66- Name = "TestPlayer" ,
67- NewPasswordPlain = "test" ,
68- AdminLevel = AdminLevel . SuperAdmin ,
69- Kudos = 200 ,
70- Level = 255 ,
71- Xp = 1325900 ,
72- Rank = 3 ,
73- Country = "cz" ,
74- Avatar = "amphimpulse" ,
75- DevLevel = DevLevel . CoreDeveloper ,
76- } ,
77- new Account { Name = GlobalConst . NightwatchName , NewPasswordPlain = "dummy" , IsBot = true , AdminLevel = AdminLevel . SuperAdmin } ) ;
78- }
48+ db . Database . ExecuteSqlCommand ( $ "truncate table { nameof ( LogEntries ) } ") ;
49+
50+ if ( GlobalConst . Mode == ModeType . Local ) LocalSeed ( db ) ;
7951
8052 db . Resources . AddOrUpdate ( x=> x . InternalName , new Resource ( )
8153 {
@@ -137,5 +109,36 @@ protected override void Seed(ZkDataContext db) {
137109 db . SaveChanges ( ) ;
138110
139111 }
112+
113+ private static void LocalSeed ( ZkDataContext db )
114+ {
115+ // fill local DB with some basic test data
116+ db . MiscVars . AddOrUpdate ( x => x . VarName ,
117+ new MiscVar { VarName = "NightwatchPassword" , VarValue = "dummy" } ,
118+ new MiscVar { VarName = "GithubHookKey" , VarValue = "secret" } ) ;
119+
120+ if ( ! db . MiscVars . Any ( y => y . VarName == "SteamBuildPassword" ) )
121+ db . MiscVars . AddOrUpdate ( x => x . VarName , new MiscVar { VarName = "SteamBuildPassword" , VarValue = "secret" } ) ;
122+
123+ if ( ! db . MiscVars . Any ( y => y . VarName == "GlacierSecretKey" ) )
124+ db . MiscVars . AddOrUpdate ( x => x . VarName , new MiscVar { VarName = "GlacierSecretKey" , VarValue = "secret" } ) ;
125+
126+ db . Accounts . AddOrUpdate ( x => x . Name ,
127+ new Account
128+ {
129+ Name = "TestPlayer" ,
130+ NewPasswordPlain = "test" ,
131+ AdminLevel = AdminLevel . SuperAdmin ,
132+ Kudos = 200 ,
133+ Level = 255 ,
134+ Xp = 1325900 ,
135+ Rank = 3 ,
136+ Country = "cz" ,
137+ Avatar = "amphimpulse" ,
138+ DevLevel = DevLevel . CoreDeveloper ,
139+ } ,
140+ new Account { Name = "test" , NewPasswordPlain = "test" , AdminLevel = AdminLevel . SuperAdmin , Kudos = 200 , Level = 50 , Country = "cz" } ,
141+ new Account { Name = GlobalConst . NightwatchName , NewPasswordPlain = "dummy" , IsBot = true , AdminLevel = AdminLevel . SuperAdmin } ) ;
142+ }
140143 }
141144}
0 commit comments