Models Update
This commit is contained in:
@@ -10,8 +10,8 @@ using Models;
|
||||
namespace Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(LuminousContext))]
|
||||
[Migration("20210314081427_IntialMigration")]
|
||||
partial class IntialMigration
|
||||
[Migration("20210317183331_InitialMigration")]
|
||||
partial class InitialMigration
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -21,6 +21,21 @@ namespace Data.Migrations
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
modelBuilder.Entity("Data.Models.RolePermission", b =>
|
||||
{
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PermisionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RoleId", "PermisionId");
|
||||
|
||||
b.HasIndex("PermisionId");
|
||||
|
||||
b.ToTable("RolePermission");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Deal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -55,16 +70,11 @@ namespace Data.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("RoleId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Permission");
|
||||
});
|
||||
|
||||
@@ -173,6 +183,21 @@ namespace Data.Migrations
|
||||
b.ToTable("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Data.Models.RolePermission", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.Permission", "Permission")
|
||||
.WithMany("Role")
|
||||
.HasForeignKey("PermisionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Models.Models.Role", "Roles")
|
||||
.WithMany("Permissions")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Deal", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.User", "User")
|
||||
@@ -182,13 +207,6 @@ namespace Data.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Permission", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.Role", null)
|
||||
.WithMany("Permissions")
|
||||
.HasForeignKey("RoleId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.Deal", null)
|
@@ -3,10 +3,23 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Data.Migrations
|
||||
{
|
||||
public partial class IntialMigration : Migration
|
||||
public partial class InitialMigration : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Permission",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Permission", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Role",
|
||||
columns: table => new
|
||||
@@ -21,23 +34,27 @@ namespace Data.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Permission",
|
||||
name: "RolePermission",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(nullable: false),
|
||||
RoleId = table.Column<int>(nullable: true)
|
||||
RoleId = table.Column<int>(nullable: false),
|
||||
PermisionId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Permission", x => x.Id);
|
||||
table.PrimaryKey("PK_RolePermission", x => new { x.RoleId, x.PermisionId });
|
||||
table.ForeignKey(
|
||||
name: "FK_Permission_Role_RoleId",
|
||||
name: "FK_RolePermission_Permission_PermisionId",
|
||||
column: x => x.PermisionId,
|
||||
principalTable: "Permission",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RolePermission_Role_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "Role",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@@ -141,11 +158,6 @@ namespace Data.Migrations
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Permission_RoleId",
|
||||
table: "Permission",
|
||||
column: "RoleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Product_DealId",
|
||||
table: "Product",
|
||||
@@ -168,6 +180,11 @@ namespace Data.Migrations
|
||||
column: "Name",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RolePermission_PermisionId",
|
||||
table: "RolePermission",
|
||||
column: "PermisionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Stock_UserId",
|
||||
table: "Stock",
|
||||
@@ -188,10 +205,10 @@ namespace Data.Migrations
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Permission");
|
||||
name: "Product");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Product");
|
||||
name: "RolePermission");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Deal");
|
||||
@@ -199,6 +216,9 @@ namespace Data.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Stock");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Permission");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "User");
|
||||
|
@@ -19,6 +19,21 @@ namespace Data.Migrations
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
modelBuilder.Entity("Data.Models.RolePermission", b =>
|
||||
{
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PermisionId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("RoleId", "PermisionId");
|
||||
|
||||
b.HasIndex("PermisionId");
|
||||
|
||||
b.ToTable("RolePermission");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Deal", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -53,16 +68,11 @@ namespace Data.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("RoleId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Name")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("Permission");
|
||||
});
|
||||
|
||||
@@ -171,6 +181,21 @@ namespace Data.Migrations
|
||||
b.ToTable("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Data.Models.RolePermission", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.Permission", "Permission")
|
||||
.WithMany("Role")
|
||||
.HasForeignKey("PermisionId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Models.Models.Role", "Roles")
|
||||
.WithMany("Permissions")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Deal", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.User", "User")
|
||||
@@ -180,13 +205,6 @@ namespace Data.Migrations
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Permission", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.Role", null)
|
||||
.WithMany("Permissions")
|
||||
.HasForeignKey("RoleId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Models.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("Models.Models.Deal", null)
|
||||
|
Reference in New Issue
Block a user