diff --git a/KustoSchemaTools/Changes/DatabaseChanges.cs b/KustoSchemaTools/Changes/DatabaseChanges.cs index ff05d12..17f3a5a 100644 --- a/KustoSchemaTools/Changes/DatabaseChanges.cs +++ b/KustoSchemaTools/Changes/DatabaseChanges.cs @@ -60,6 +60,15 @@ public static List GenerateChanges(Database oldState, Database newState } } + foreach (var mv in newState.MaterializedViews) + { + if (mv.Value.AllowMaterializedViewsWithoutRowLevelSecurity + && oldState.MaterializedViews.ContainsKey(mv.Key)) + { + oldState.MaterializedViews[mv.Key].AllowMaterializedViewsWithoutRowLevelSecurity = true; + } + } + result.AddRange(GenerateScriptCompareChanges(oldState, newState, db => db.Tables, nameof(newState.Tables), log, (oldItem, newItem) => oldItem != null || newItem.Columns?.Any() == true)); var mvChanges = GenerateScriptCompareChanges(oldState, newState, db => db.MaterializedViews, nameof(newState.MaterializedViews), log); foreach(var mvChange in mvChanges) diff --git a/KustoSchemaTools/Model/MaterializedView.cs b/KustoSchemaTools/Model/MaterializedView.cs index c197f93..37cf9a6 100644 --- a/KustoSchemaTools/Model/MaterializedView.cs +++ b/KustoSchemaTools/Model/MaterializedView.cs @@ -25,6 +25,7 @@ public class MaterializedView : IKustoBaseEntity public string? RowLevelSecurity { get; set; } public Policy? Policies { get; set; } public bool Preformatted { get; set; } = false; + public bool AllowMaterializedViewsWithoutRowLevelSecurity { get; set; } = false; public List CreateScripts(string name, bool isNew) { var asyncSetup = isNew && Backfill == true; @@ -36,7 +37,8 @@ public List CreateScripts(string name, bool isNew) "RetentionAndCachePolicy", "RowLevelSecurity", "Policies", - "Preformatted" + "Preformatted", + "AllowMaterializedViewsWithoutRowLevelSecurity" ]); if (!asyncSetup) @@ -52,6 +54,13 @@ public List CreateScripts(string name, bool isNew) .Where(p => !string.IsNullOrWhiteSpace(p.Value?.ToString())) .Select(p => $"{p.Name}=```{p.Value}```")); + if (AllowMaterializedViewsWithoutRowLevelSecurity && isNew) + { + properties = string.IsNullOrEmpty(properties) + ? "allowMaterializedViewsWithoutRowLevelSecurity=true" + : $"{properties}, allowMaterializedViewsWithoutRowLevelSecurity=true"; + } + if (asyncSetup) { scripts.Add(new DatabaseScriptContainer("CreateMaterializedViewAsync", Kind == "table" ? 40 : 41, $".create async ifnotexists materialized-view with ({properties}) {name} on {Kind} {Source} {{ {Query} }}", true));