Editor povezava na db

This commit is contained in:
David Štaleker
2024-02-27 07:27:47 +01:00
parent 4df426dc10
commit e92956075f
24 changed files with 1033 additions and 47 deletions

View File

@@ -0,0 +1,405 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using ZpcBulletinBoard.Data;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240227053725_3")]
partial class _3
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderKey")
.HasColumnType("varchar(255)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<int>("RoleId")
.HasColumnType("int");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");
b.Property<string>("LoginProvider")
.HasColumnType("varchar(255)");
b.Property<string>("Name")
.HasColumnType("varchar(255)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Property<int>("IdBulletinBoard")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<Guid>("Guid")
.HasColumnType("char(36)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Ratio")
.HasColumnType("int");
b.HasKey("IdBulletinBoard");
b.ToTable("BulletinBoards");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Property<int>("IdBulletinBoardPage")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("IdBulletinBoardPage");
b.HasIndex("IdBulletinBoard");
b.ToTable("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Height")
.HasColumnType("int");
b.Property<int>("IdBulletinBoardPage")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("longtext");
b.Property<int>("Width")
.HasColumnType("int");
b.Property<int>("X")
.HasColumnType("int");
b.Property<int>("Y")
.HasColumnType("int");
b.HasKey("IdNote");
b.HasIndex("IdBulletinBoardPage");
b.ToTable("Notes");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.IdentityApplicationRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<bool>("Active")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("ZpcBulletinBoard.Models.IdentityApplicationUser", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<bool>("Active")
.HasColumnType("tinyint(1)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<DateTime>("DateCreated")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DateValidUntil")
.HasColumnType("datetime(6)");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("ZpcBulletinBoard.Models.IdentityApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Pages")
.HasForeignKey("IdBulletinBoard")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoard");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Notes")
.HasForeignKey("IdBulletinBoardPage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Pages");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Navigation("Notes");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,94 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ZpcBulletinBoard.Migrations
{
/// <inheritdoc />
public partial class _3 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Notes_BulletinBoards_IdBulletinBoard",
table: "Notes");
migrationBuilder.RenameColumn(
name: "IdBulletinBoard",
table: "Notes",
newName: "IdBulletinBoardPage");
migrationBuilder.RenameIndex(
name: "IX_Notes_IdBulletinBoard",
table: "Notes",
newName: "IX_Notes_IdBulletinBoardPage");
migrationBuilder.CreateTable(
name: "BulletinBoardPage",
columns: table => new
{
IdBulletinBoardPage = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
IdBulletinBoard = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Duration = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BulletinBoardPage", x => x.IdBulletinBoardPage);
table.ForeignKey(
name: "FK_BulletinBoardPage_BulletinBoards_IdBulletinBoard",
column: x => x.IdBulletinBoard,
principalTable: "BulletinBoards",
principalColumn: "IdBulletinBoard",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_BulletinBoardPage_IdBulletinBoard",
table: "BulletinBoardPage",
column: "IdBulletinBoard");
migrationBuilder.AddForeignKey(
name: "FK_Notes_BulletinBoardPage_IdBulletinBoardPage",
table: "Notes",
column: "IdBulletinBoardPage",
principalTable: "BulletinBoardPage",
principalColumn: "IdBulletinBoardPage",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Notes_BulletinBoardPage_IdBulletinBoardPage",
table: "Notes");
migrationBuilder.DropTable(
name: "BulletinBoardPage");
migrationBuilder.RenameColumn(
name: "IdBulletinBoardPage",
table: "Notes",
newName: "IdBulletinBoard");
migrationBuilder.RenameIndex(
name: "IX_Notes_IdBulletinBoardPage",
table: "Notes",
newName: "IX_Notes_IdBulletinBoard");
migrationBuilder.AddForeignKey(
name: "FK_Notes_BulletinBoards_IdBulletinBoard",
table: "Notes",
column: "IdBulletinBoard",
principalTable: "BulletinBoards",
principalColumn: "IdBulletinBoard",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -139,6 +139,29 @@ namespace ZpcBulletinBoard.Migrations
b.ToTable("BulletinBoards");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Property<int>("IdBulletinBoardPage")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("Duration")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("IdBulletinBoardPage");
b.HasIndex("IdBulletinBoard");
b.ToTable("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.Property<int>("IdNote")
@@ -152,7 +175,7 @@ namespace ZpcBulletinBoard.Migrations
b.Property<int>("Height")
.HasColumnType("int");
b.Property<int>("IdBulletinBoard")
b.Property<int>("IdBulletinBoardPage")
.HasColumnType("int");
b.Property<string>("Title")
@@ -170,7 +193,7 @@ namespace ZpcBulletinBoard.Migrations
b.HasKey("IdNote");
b.HasIndex("IdBulletinBoard");
b.HasIndex("IdBulletinBoardPage");
b.ToTable("Notes");
});
@@ -342,10 +365,10 @@ namespace ZpcBulletinBoard.Migrations
.IsRequired();
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoard", "BulletinBoard")
.WithMany("Notes")
.WithMany("Pages")
.HasForeignKey("IdBulletinBoard")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -353,7 +376,23 @@ namespace ZpcBulletinBoard.Migrations
b.Navigation("BulletinBoard");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.Note", b =>
{
b.HasOne("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", "BulletinBoardPage")
.WithMany("Notes")
.HasForeignKey("IdBulletinBoardPage")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BulletinBoardPage");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoard", b =>
{
b.Navigation("Pages");
});
modelBuilder.Entity("ZpcBulletinBoard.Models.Editor.BulletinBoardPage", b =>
{
b.Navigation("Notes");
});