-
Notifications
You must be signed in to change notification settings - Fork 0
/
KustoMigrationSqlGenerator.cs
49 lines (43 loc) · 1.71 KB
/
KustoMigrationSqlGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Update;
using Microsoft.EntityFrameworkCore.Metadata;
namespace EFCore.Azure.Kusto
{
public class KustoMigrationSqlGenerator : MigrationsSqlGenerator
{
public KustoMigrationSqlGenerator(MigrationsSqlGeneratorDependencies dependencies) : base(dependencies)
{
}
protected override void Generate(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)
{
builder.Append("CREATE TABLE ")
.Append(operation.Name)
.AppendLine(" (");
// Add columns
foreach (var column in operation.Columns)
{
builder.Append(column.Name)
.Append(" ")
.Append(column.ColumnType)
.AppendLine(",");
}
builder.AppendLine(");");
}
// Implement other SQL generation methods as needed
protected override void Generate(DropTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)
{
builder.Append("DROP TABLE ")
.Append(operation.Name)
.AppendLine(";");
}
protected override void Generate(RenameTableOperation operation, IModel model, MigrationCommandListBuilder builder)
{
builder.Append("RENAME TABLE ")
.Append(operation.Name)
.Append(" TO ")
.Append(operation.NewName)
.AppendLine(";");
}
}
}