-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for add/drop views and functions, and sprocs
- Loading branch information
Showing
18 changed files
with
313 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace Dgmjr.EntityFrameworkCore.Migrations; | ||
|
||
using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||
|
||
public class CreateProcedureOperation(string schema, string name, SqlArgument[] arguments, string body) | ||
: SqlOperation | ||
{ | ||
public string Schema { get; set; } = schema; | ||
public string Name { get; set; } = name; | ||
public SqlArgument[] Arguments { get; set; } = arguments; | ||
public string Body { get; set; } = body; | ||
|
||
public override string Sql => | ||
Format(CreateOrAlterProcedurePattern, Schema, Name, Arguments.Join(", "), Body); | ||
|
||
public CreateProcedureOperation( | ||
MethodInfo mi, | ||
string body, | ||
string schema = DboSchema.ShortName, | ||
string? name = default, | ||
SqlArgument[]? arguments = default | ||
) | ||
: this( | ||
schema, | ||
name ?? mi.Name, | ||
arguments | ||
?? mi.GetParameters() | ||
.Select(arg => (SqlArgument)arg) | ||
.ToArray(), | ||
body | ||
) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
// namespace Dgmjr.EntityFrameworkCore.Migrations; | ||
namespace Dgmjr.EntityFrameworkCore.Migrations; | ||
|
||
// public class CreateViewOperation(string schema, string name, params Column[] columns) : SqlOperation | ||
// { | ||
// public string Schema { get; set; } = schema; | ||
// public string Name { get; set; } = name; | ||
// public Column[] Columns { get; set; } = columns; | ||
// public Expression | ||
// } | ||
public class CreateViewOperation(string schema, string name, string selectStatement) : SqlOperation | ||
{ | ||
public string Schema { get; set; } = schema; | ||
public string Name { get; set; } = name; | ||
public string SelectStatement { get; set; } = selectStatement; | ||
|
||
// public record struct Column(string DataType, string SourceTable, string ColumnName); | ||
public override string Sql => Format(CreateOrAlterViewPattern, Schema, Name, SelectStatement); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Dgmjr.EntityFrameworkCore.Migrations; | ||
|
||
public class DropOperation(string thingKind, string schema, string name) : SqlOperation | ||
{ | ||
public string ThingKind { get; set; } = thingKind; | ||
public string Schema { get; set; } = schema; | ||
public string Name { get; set; } = name; | ||
public override bool IsDestructiveChange => true; | ||
|
||
public override string Sql => Format(DropSomethingIfExistsPattern, ThingKind, Schema, Name); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Dgmjr.EntityFrameworkCore.Migrations; | ||
|
||
using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||
|
||
public class DropProcedureOperation(string schema, string name) : DropOperation(Procedure, schema, name) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Dgmjr.EntityFrameworkCore.Migrations; | ||
|
||
using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||
|
||
public class DropViewOperation(string schema, string name) : DropOperation(View, schema, name) | ||
{ | ||
} |
Oops, something went wrong.