Skip to content

Commit

Permalink
on delete no action for bibleVerseId (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
elisabeth-shakespeare authored Dec 9, 2024
1 parent 6418fd2 commit 73f6845
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 91 deletions.
11 changes: 11 additions & 0 deletions src/Aquifer.Data/Entities/VersificationMappingEntity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Aquifer.Data.EventHandlers;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Aquifer.Data.Entities;

[EntityTypeConfiguration(typeof(VersificationMappingEntityConfiguration))]
public class VersificationMappingEntity : IHasUpdatedTimestamp
{
public int Id { get; private set; }
Expand All @@ -18,4 +21,12 @@ public class VersificationMappingEntity : IHasUpdatedTimestamp

[SqlDefaultValue("getutcdate()")]
public DateTime Updated { get; set; } = DateTime.UtcNow;
}

public class VersificationMappingEntityConfiguration : IEntityTypeConfiguration<VersificationMappingEntity>
{
public void Configure(EntityTypeBuilder<VersificationMappingEntity> builder)
{
builder.HasOne(p => p.BibleVerse).WithMany().OnDelete(DeleteBehavior.NoAction);
}
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Aquifer.Data.Migrations
{
/// <inheritdoc />
public partial class AddVersificationMappingAndExclusion : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddForeignKey(
name: "FK_VersificationExclusions_Bibles_BibleId",
table: "VersificationExclusions",
column: "BibleId",
principalTable: "Bibles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);

migrationBuilder.AddForeignKey(
name: "FK_VersificationExclusions_Verses_VerseId",
table: "VersificationExclusions",
column: "VerseId",
principalTable: "Verses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);

migrationBuilder.AddForeignKey(
name: "FK_VersificationMappings_Bibles_BibleId",
table: "VersificationMappings",
column: "BibleId",
principalTable: "Bibles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);

migrationBuilder.AddForeignKey(
name: "FK_VersificationMappings_Verses_BaseVerseId",
table: "VersificationMappings",
column: "BaseVerseId",
principalTable: "Verses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);

migrationBuilder.AddForeignKey(
name: "FK_VersificationMappings_Verses_BibleVerseId",
table: "VersificationMappings",
column: "BibleVerseId",
principalTable: "Verses",
principalColumn: "Id");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_VersificationExclusions_Bibles_BibleId",
table: "VersificationExclusions");

migrationBuilder.DropForeignKey(
name: "FK_VersificationExclusions_Verses_VerseId",
table: "VersificationExclusions");

migrationBuilder.DropForeignKey(
name: "FK_VersificationMappings_Bibles_BibleId",
table: "VersificationMappings");

migrationBuilder.DropForeignKey(
name: "FK_VersificationMappings_Verses_BaseVerseId",
table: "VersificationMappings");

migrationBuilder.DropForeignKey(
name: "FK_VersificationMappings_Verses_BibleVerseId",
table: "VersificationMappings");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2718,7 +2718,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasOne("Aquifer.Data.Entities.VerseEntity", "BibleVerse")
.WithMany()
.HasForeignKey("BibleVerseId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();

b.Navigation("BaseVerse");
Expand Down

0 comments on commit 73f6845

Please sign in to comment.