Modif BDD Discussion

This commit is contained in:
2026-06-11 00:56:32 +02:00
parent 4e06dc5f23
commit f1cdc5de19
16 changed files with 65 additions and 165 deletions
@@ -1,160 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Knots.Migrations
{
/// <inheritdoc />
public partial class RemoveDiscussionFromGroup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Groups_Discussions_DiscussionId",
table: "Groups");
migrationBuilder.DropForeignKey(
name: "FK_UserDiscussions_Users_UserId",
table: "UserDiscussions");
migrationBuilder.DropIndex(
name: "IX_Groups_DiscussionId",
table: "Groups");
migrationBuilder.DropColumn(
name: "DiscussionId",
table: "Groups");
migrationBuilder.DropColumn(
name: "KeyId",
table: "Groups");
migrationBuilder.AddColumn<int>(
name: "GroupId",
table: "Discussions",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "GroupUsers",
columns: table => new
{
GroupId = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false),
RoleId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GroupUsers", x => new { x.GroupId, x.UserId });
table.ForeignKey(
name: "FK_GroupUsers_Groups_GroupId",
column: x => x.GroupId,
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GroupUsers_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_GroupUsers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Discussions_GroupId",
table: "Discussions",
column: "GroupId");
migrationBuilder.CreateIndex(
name: "IX_GroupUsers_RoleId",
table: "GroupUsers",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_GroupUsers_UserId",
table: "GroupUsers",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_Discussions_Groups_GroupId",
table: "Discussions",
column: "GroupId",
principalTable: "Groups",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_UserDiscussions_Users_UserId",
table: "UserDiscussions",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Discussions_Groups_GroupId",
table: "Discussions");
migrationBuilder.DropForeignKey(
name: "FK_UserDiscussions_Users_UserId",
table: "UserDiscussions");
migrationBuilder.DropTable(
name: "GroupUsers");
migrationBuilder.DropIndex(
name: "IX_Discussions_GroupId",
table: "Discussions");
migrationBuilder.DropColumn(
name: "GroupId",
table: "Discussions");
migrationBuilder.AddColumn<int>(
name: "DiscussionId",
table: "Groups",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "KeyId",
table: "Groups",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Groups_DiscussionId",
table: "Groups",
column: "DiscussionId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Groups_Discussions_DiscussionId",
table: "Groups",
column: "DiscussionId",
principalTable: "Discussions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_UserDiscussions_Users_UserId",
table: "UserDiscussions",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Knots.Migrations
{
[DbContext(typeof(KnotsDbContext))]
[Migration("20260610224254_RemoveDiscussionFromGroup")]
partial class RemoveDiscussionFromGroup
[Migration("20260610224937_FixGroupDiscussion")]
partial class FixGroupDiscussion
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -57,6 +57,9 @@ namespace Knots.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DiscussionId")
.HasColumnType("int");
b.Property<int>("MembersAmount")
.HasColumnType("int");
@@ -70,6 +73,8 @@ namespace Knots.Migrations
b.HasKey("Id");
b.HasIndex("DiscussionId");
b.ToTable("Groups");
});
@@ -119,6 +124,9 @@ namespace Knots.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AuthorId")
.HasColumnType("int");
b.Property<string>("Contenu")
.IsRequired()
.HasMaxLength(1000)
@@ -241,6 +249,17 @@ namespace Knots.Migrations
b.Navigation("Group");
});
modelBuilder.Entity("Knots.Models.Group", b =>
{
b.HasOne("Knots.Models.Discussion", "Discussion")
.WithMany()
.HasForeignKey("DiscussionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Discussion");
});
modelBuilder.Entity("Knots.Models.GroupUser", b =>
{
b.HasOne("Knots.Models.Group", "Group")
@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Knots.Migrations
{
/// <inheritdoc />
public partial class FixGroupDiscussion : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "AuthorId",
table: "Messages",
type: "int",
nullable: false,
defaultValue: 0);
}
}
}
@@ -54,6 +54,9 @@ namespace Knots.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DiscussionId")
.HasColumnType("int");
b.Property<int>("MembersAmount")
.HasColumnType("int");
@@ -67,6 +70,8 @@ namespace Knots.Migrations
b.HasKey("Id");
b.HasIndex("DiscussionId");
b.ToTable("Groups");
});
@@ -116,6 +121,9 @@ namespace Knots.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AuthorId")
.HasColumnType("int");
b.Property<string>("Contenu")
.IsRequired()
.HasMaxLength(1000)
@@ -238,6 +246,17 @@ namespace Knots.Migrations
b.Navigation("Group");
});
modelBuilder.Entity("Knots.Models.Group", b =>
{
b.HasOne("Knots.Models.Discussion", "Discussion")
.WithMany()
.HasForeignKey("DiscussionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Discussion");
});
modelBuilder.Entity("Knots.Models.GroupUser", b =>
{
b.HasOne("Knots.Models.Group", "Group")
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Knots")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4f994ba183ab4a079dd7e762d3b7cacca26f8f75")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4e06dc5f235e9c9c699b247eb56dccf3eeed81f8")]
[assembly: System.Reflection.AssemblyProductAttribute("Knots")]
[assembly: System.Reflection.AssemblyTitleAttribute("Knots")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
aa1c1119a88f3e3b5738f6ea6f67686474d5c6d7e7b2612859a07f3ee65ef199
45989a1b023b2a60770db7a1baceef9c56c487cca0e44ae9d0d75cdde668b8cc
@@ -1 +1 @@
bab9e1ed6ec5ae3422f4377cfa8a1795b3c9881cbfdada74a84426e15b5819ff
1afb5c57f375954b5501d52f6ccbfcdd0c9a4a7d75abca85439c878c12264607
@@ -519,3 +519,4 @@ C:\Users\dogge\RiderProjects\Knots\Knots\obj\Debug\net8.0\Knots.pdb
C:\Users\dogge\RiderProjects\Knots\Knots\obj\Debug\net8.0\Knots.genruntimeconfig.cache
C:\Users\dogge\RiderProjects\Knots\Knots\obj\Debug\net8.0\ref\Knots.dll
C:\Users\dogge\RiderProjects\Knots\Knots\bin\Debug\net8.0\System.Net.WebSockets.WebSocketProtocol.dll
C:\Users\Carte\RiderProjects\Knots\Knots\bin\Debug\net8.0\System.Net.WebSockets.WebSocketProtocol.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.