Skip to content

Commit 42c3429

Browse files
author
Thomas Mahlberg
committed
Split files, add modification kinds
1 parent 5b1781c commit 42c3429

6 files changed

Lines changed: 59 additions & 65 deletions

File tree

KustoSchemaTools/Changes/DatabaseChanges.cs

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ .. GenerateFollowerCachingChanges(oldState, newState, db => db.Tables, "Table",
188188
.. GenerateFollowerCachingChanges(oldState, newState, db => db.MaterializedViews, "MV", "materialized-view"),
189189

190190
];
191+
192+
if (oldState.Permissions.ModificationKind != newState.Permissions.ModificationKind)
193+
{
194+
var kind = newState.Permissions.ModificationKind.ToString().ToLower();
195+
result.Add(new BasicChange("FollowerDatabase", "PermissionsModificationKind", $"From {oldState.Permissions.ModificationKind} to {newState.Permissions.ModificationKind}", new List<DatabaseScriptContainer>
196+
{
197+
new DatabaseScriptContainer(new DatabaseScript($".alter follower database {newState.DatabaseName} principals-modification-kind = {kind}", 0), "FollowerChangePolicyModificationKind")
198+
}));
199+
}
200+
if (oldState.Cache.ModificationKind != newState.Cache.ModificationKind)
201+
{
202+
var kind = newState.Cache.ModificationKind.ToString().ToLower();
203+
result.Add(new BasicChange("FollowerDatabase", "ChangeModificationKind", $"From {oldState.Cache.ModificationKind} to {newState.Cache.ModificationKind}", new List<DatabaseScriptContainer>
204+
{
205+
new DatabaseScriptContainer(new DatabaseScript($".alter follower database {newState.DatabaseName} caching-policies-modification-kind = {kind}", 0), "FollowerChangePolicyModificationKind")
206+
}));
207+
}
208+
191209
if (oldState.Cache.DefaultHotCache != newState.Cache.DefaultHotCache)
192210
{
193211
if (newState.Cache.DefaultHotCache != null)
@@ -208,41 +226,6 @@ .. GenerateFollowerCachingChanges(oldState, newState, db => db.MaterializedViews
208226

209227
return result;
210228

211-
212-
213-
/*
214-
* public class FollowerDatabase
215-
{
216-
public required string DatabaseName { get; set; }
217-
public FollowerCache Cache { get; set; } = new FollowerCache();
218-
public FollowerPermissions Permissions { get; set; } = new FollowerPermissions();
219-
}
220-
221-
public class FollowerPermissions
222-
{
223-
public FollowerModificationKind? ModificationKind { get; set; }
224-
public List<AADObject> Viewers { get; set; } = new List<AADObject>();
225-
public List<AADObject> Admins { get; set; } = new List<AADObject>();
226-
}
227-
228-
public class FollowerCache
229-
{
230-
public string? DefaultHotCache { get; set; }
231-
public FollowerModificationKind? ModificationKind { get; set; }
232-
public Dictionary<string, string> Tables { get; set; } = new Dictionary<string, string>();
233-
public Dictionary<string, string> MaterializedViews { get; set; } = new Dictionary<string, string>();
234-
}
235-
236-
public enum FollowerModificationKind
237-
{
238-
None,
239-
Union,
240-
Replace
241-
}
242-
*/
243-
244-
245-
return result;
246229
}
247230

248231
private static List<IChange> GenerateFollowerCachingChanges(FollowerDatabase oldState, FollowerDatabase newState, Func<FollowerCache, Dictionary<string,string>> selector, string type, string kustoType)

KustoSchemaTools/Model/Database.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,4 @@ public class Database
3737
public Dictionary<string, FollowerDatabase> Followers { get; set; } = new Dictionary<string, FollowerDatabase>();
3838

3939
}
40-
41-
public class FollowerDatabase
42-
{
43-
public required string DatabaseName { get; set; }
44-
public FollowerCache Cache { get; set; } = new FollowerCache();
45-
public FollowerPermissions Permissions { get; set; } = new FollowerPermissions();
46-
}
47-
48-
public class FollowerPermissions
49-
{
50-
public FollowerModificationKind? ModificationKind { get; set; }
51-
public List<AADObject> Viewers { get; set; } = new List<AADObject>();
52-
public List<AADObject> Admins { get; set; } = new List<AADObject>();
53-
}
54-
55-
public class FollowerCache
56-
{
57-
public string? DefaultHotCache { get; set; }
58-
public FollowerModificationKind? ModificationKind { get; set; }
59-
public Dictionary<string, string> Tables { get; set; } = new Dictionary<string, string>();
60-
public Dictionary<string, string> MaterializedViews { get; set; } = new Dictionary<string, string>();
61-
}
62-
63-
public enum FollowerModificationKind
64-
{
65-
None,
66-
Union,
67-
Replace
68-
}
69-
7040
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace KustoSchemaTools.Model
2+
{
3+
public class FollowerCache
4+
{
5+
public string? DefaultHotCache { get; set; }
6+
public FollowerModificationKind ModificationKind { get; set; }
7+
public Dictionary<string, string> Tables { get; set; } = new Dictionary<string, string>();
8+
public Dictionary<string, string> MaterializedViews { get; set; } = new Dictionary<string, string>();
9+
}
10+
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace KustoSchemaTools.Model
2+
{
3+
public class FollowerDatabase
4+
{
5+
public required string DatabaseName { get; set; }
6+
public FollowerCache Cache { get; set; } = new FollowerCache();
7+
public FollowerPermissions Permissions { get; set; } = new FollowerPermissions();
8+
}
9+
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace KustoSchemaTools.Model
2+
{
3+
public enum FollowerModificationKind
4+
{
5+
None,
6+
Union,
7+
Replace
8+
}
9+
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace KustoSchemaTools.Model
2+
{
3+
public class FollowerPermissions
4+
{
5+
public FollowerModificationKind ModificationKind { get; set; }
6+
public List<AADObject> Viewers { get; set; } = new List<AADObject>();
7+
public List<AADObject> Admins { get; set; } = new List<AADObject>();
8+
}
9+
10+
}

0 commit comments

Comments
 (0)