Branch ile BranchUsers arasında ilişki kaldırıldı

This commit is contained in:
Sedat Öztürk 2025-10-11 02:19:21 +03:00
parent c01f6964b4
commit 293abf86ba
7 changed files with 19 additions and 75 deletions

View file

@ -109,7 +109,7 @@ public static class PlatformConsts
public static string BranchValues = public static string BranchValues =
$"SELECT \"{SelectCommandByTableName("Branch")}\".\"Id\" AS \"Key\", " + $"SELECT \"{SelectCommandByTableName("Branch")}\".\"Id\" AS \"Key\", " +
$"\"{SelectCommandByTableName("Branch")}\".\"Name\" as \"Name\" " + $"\"{SelectCommandByTableName("Branch")}\".\"Name\" as \"Name\" " +
$"FROM \"{SelectCommandByTableName("Branch")}\" " + $"FROM \"KURS\".\"dbo\".\"{SelectCommandByTableName("Branch")}\" " +
$"WHERE \"{SelectCommandByTableName("Branch")}\".\"TenantId\" = '@TENANTID' " + $"WHERE \"{SelectCommandByTableName("Branch")}\".\"TenantId\" = '@TENANTID' " +
$"AND \"{SelectCommandByTableName("Branch")}\".\"Id\" IN ( " + $"AND \"{SelectCommandByTableName("Branch")}\".\"Id\" IN ( " +
$"SELECT [BranchId] " + $"SELECT [BranchId] " +

View file

@ -12,6 +12,4 @@ public class BranchUsers : Entity<Guid>, IMultiTenant
public Guid UserId { get; set; } public Guid UserId { get; set; }
Guid? IMultiTenant.TenantId => TenantId; Guid? IMultiTenant.TenantId => TenantId;
public virtual Branch Branch { get; set; }
} }

View file

@ -25,6 +25,4 @@ public class Branch : FullAuditedEntity<Guid>
public string Email { get; set; } public string Email { get; set; }
public string Website { get; set; } public string Website { get; set; }
public bool? IsActive { get; set; } public bool? IsActive { get; set; }
public virtual ICollection<BranchUsers> Users { get; set; }
} }

View file

@ -237,11 +237,6 @@ public class PlatformDbContext :
b.Property(a => a.Email).HasMaxLength(128); b.Property(a => a.Email).HasMaxLength(128);
b.Property(a => a.Website).HasMaxLength(128); b.Property(a => a.Website).HasMaxLength(128);
b.Property(a => a.IsActive).HasDefaultValue(true); b.Property(a => a.IsActive).HasDefaultValue(true);
b.HasMany(x => x.Users)
.WithOne(x => x.Branch)
.HasForeignKey(x => x.BranchId)
.OnDelete(DeleteBehavior.Cascade);
}); });
builder.Entity<BranchUsers>(b => builder.Entity<BranchUsers>(b =>

View file

@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace Kurs.Platform.Migrations namespace Kurs.Platform.Migrations
{ {
[DbContext(typeof(PlatformDbContext))] [DbContext(typeof(PlatformDbContext))]
[Migration("20251010064947_Initial")] [Migration("20251010230305_Initial")]
partial class Initial partial class Initial
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -1369,8 +1369,6 @@ namespace Kurs.Platform.Migrations
b.HasKey("UserId", "BranchId"); b.HasKey("UserId", "BranchId");
b.HasIndex("BranchId");
b.ToTable("PBranchUsers", (string)null); b.ToTable("PBranchUsers", (string)null);
}); });
@ -8650,17 +8648,6 @@ namespace Kurs.Platform.Migrations
b.Navigation("Category"); b.Navigation("Category");
}); });
modelBuilder.Entity("Kurs.Platform.Entities.BranchUsers", b =>
{
b.HasOne("Kurs.Platform.Entities.Branch", "Branch")
.WithMany("Users")
.HasForeignKey("BranchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Branch");
});
modelBuilder.Entity("Kurs.Platform.Entities.City", b => modelBuilder.Entity("Kurs.Platform.Entities.City", b =>
{ {
b.HasOne("Kurs.Platform.Entities.Country", null) b.HasOne("Kurs.Platform.Entities.Country", null)
@ -9113,11 +9100,6 @@ namespace Kurs.Platform.Migrations
b.Navigation("Posts"); b.Navigation("Posts");
}); });
modelBuilder.Entity("Kurs.Platform.Entities.Branch", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("Kurs.Platform.Entities.City", b => modelBuilder.Entity("Kurs.Platform.Entities.City", b =>
{ {
b.Navigation("Districts"); b.Navigation("Districts");

View file

@ -1306,6 +1306,20 @@ namespace Kurs.Platform.Migrations
table.PrimaryKey("PK_PBranch", x => x.Id); table.PrimaryKey("PK_PBranch", x => x.Id);
}); });
migrationBuilder.CreateTable(
name: "PBranchUsers",
columns: table => new
{
BranchId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PBranchUsers", x => new { x.UserId, x.BranchId });
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "PClassroom", name: "PClassroom",
columns: table => new columns: table => new
@ -2606,26 +2620,6 @@ namespace Kurs.Platform.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateTable(
name: "PBranchUsers",
columns: table => new
{
BranchId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PBranchUsers", x => new { x.UserId, x.BranchId });
table.ForeignKey(
name: "FK_PBranchUsers_PBranch_BranchId",
column: x => x.BranchId,
principalTable: "PBranch",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "PClassroomAttandance", name: "PClassroomAttandance",
columns: table => new columns: table => new
@ -3857,11 +3851,6 @@ namespace Kurs.Platform.Migrations
columns: new[] { "TableName", "Order" }, columns: new[] { "TableName", "Order" },
unique: true); unique: true);
migrationBuilder.CreateIndex(
name: "IX_PBranchUsers_BranchId",
table: "PBranchUsers",
column: "BranchId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_PClassroom_ScheduledStartTime", name: "IX_PClassroom_ScheduledStartTime",
table: "PClassroom", table: "PClassroom",
@ -4239,6 +4228,9 @@ namespace Kurs.Platform.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "PBackgroundWorker_MailQueueEvents"); name: "PBackgroundWorker_MailQueueEvents");
migrationBuilder.DropTable(
name: "PBranch");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "PBranchUsers"); name: "PBranchUsers");
@ -4377,9 +4369,6 @@ namespace Kurs.Platform.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "PBackgroundWorker_MailQueue"); name: "PBackgroundWorker_MailQueue");
migrationBuilder.DropTable(
name: "PBranch");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "PClassroom"); name: "PClassroom");

View file

@ -1366,8 +1366,6 @@ namespace Kurs.Platform.Migrations
b.HasKey("UserId", "BranchId"); b.HasKey("UserId", "BranchId");
b.HasIndex("BranchId");
b.ToTable("PBranchUsers", (string)null); b.ToTable("PBranchUsers", (string)null);
}); });
@ -8647,17 +8645,6 @@ namespace Kurs.Platform.Migrations
b.Navigation("Category"); b.Navigation("Category");
}); });
modelBuilder.Entity("Kurs.Platform.Entities.BranchUsers", b =>
{
b.HasOne("Kurs.Platform.Entities.Branch", "Branch")
.WithMany("Users")
.HasForeignKey("BranchId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Branch");
});
modelBuilder.Entity("Kurs.Platform.Entities.City", b => modelBuilder.Entity("Kurs.Platform.Entities.City", b =>
{ {
b.HasOne("Kurs.Platform.Entities.Country", null) b.HasOne("Kurs.Platform.Entities.Country", null)
@ -9110,11 +9097,6 @@ namespace Kurs.Platform.Migrations
b.Navigation("Posts"); b.Navigation("Posts");
}); });
modelBuilder.Entity("Kurs.Platform.Entities.Branch", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("Kurs.Platform.Entities.City", b => modelBuilder.Entity("Kurs.Platform.Entities.City", b =>
{ {
b.Navigation("Districts"); b.Navigation("Districts");