-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
167 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "7.0.202" | ||
"version": "7.0.203" | ||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/Miru/Databases/Migrations/FluentMigrator/ForeignKeyReferenceExtensions.cs
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,42 @@ | ||
using System.Data; | ||
using FluentMigrator.Builders.Alter.Column; | ||
using FluentMigrator.Builders.Alter.Table; | ||
using FluentMigrator.Builders.Create.Table; | ||
|
||
namespace Miru.Databases.Migrations.FluentMigrator; | ||
|
||
public static class ForeignKeyReferenceExtensions | ||
{ | ||
public static ICreateTableColumnOptionOrForeignKeyCascadeOrWithColumnSyntax AsForeignKeyReference( | ||
this ICreateTableColumnAsTypeSyntax column, | ||
string foreignTable, | ||
string idColumn = "Id", | ||
bool deleteOnCascade = false) | ||
{ | ||
var attrs = column.AsInt64().Indexed().ForeignKey(foreignTable, idColumn); | ||
|
||
return deleteOnCascade ? attrs.OnDelete(Rule.Cascade) : attrs; | ||
} | ||
|
||
public static IAlterTableColumnOptionOrAddColumnOrAlterColumnSyntax AsForeignKeyReference( | ||
this IAlterTableColumnAsTypeSyntax column, | ||
string foreignTable, | ||
string idColumn = "Id", | ||
bool deleteOnCascade = false) | ||
{ | ||
var attrs = column.AsInt64().Indexed().ForeignKey(foreignTable, idColumn); | ||
|
||
return deleteOnCascade ? attrs.OnDelete(Rule.Cascade) : attrs; | ||
} | ||
|
||
public static IAlterColumnOptionOrForeignKeyCascadeSyntax AsForeignKeyReference( | ||
this IAlterColumnAsTypeOrInSchemaSyntax column, | ||
string foreignTable, | ||
string idColumn = "Id", | ||
bool deleteOnCascade = false) | ||
{ | ||
var attrs = column.AsInt64().Indexed().ForeignKey(foreignTable, idColumn); | ||
|
||
return deleteOnCascade ? attrs.OnDelete(Rule.Cascade) : attrs; | ||
} | ||
} |
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