feat(dal): таблицы Users, Roles

This commit is contained in:
Mikhail Trubnikov
2023-12-01 10:05:54 +10:00
parent e00826c398
commit 78f2310199
12 changed files with 6111 additions and 5 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,92 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class TblUsersRoles : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Ip = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UsersInRoles",
columns: table => new
{
RoleId = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UsersInRoles", x => new { x.RoleId, x.UserId });
table.ForeignKey(
name: "FK_UsersInRoles_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UsersInRoles_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Users_Ip",
table: "Users",
column: "Ip",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_UsersInRoles_UserId",
table: "UsersInRoles",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UsersInRoles");
migrationBuilder.DropTable(
name: "Roles");
migrationBuilder.DropTable(
name: "Users");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class TblRolesInitData : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "Roles",
columns: new[] { "Id", "DateCreated", "Description", "Name" },
values: new object[,]
{
{ new Guid("13bca225-7fa4-42fa-9d80-d2d46de261fe"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Робот ЕСПП", "espp-robot" },
{ new Guid("c8f2f144-e6c2-45d7-ba66-5e9bbd376376"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), "Администратор", "administrator" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "Roles",
keyColumn: "Id",
keyValue: new Guid("13bca225-7fa4-42fa-9d80-d2d46de261fe"));
migrationBuilder.DeleteData(
table: "Roles",
keyColumn: "Id",
keyValue: new Guid("c8f2f144-e6c2-45d7-ba66-5e9bbd376376"));
}
}
}

View File

@@ -2079,6 +2079,44 @@ namespace PARR.DAL.Migrations
});
});
modelBuilder.Entity("PARR.DAL.Models.Role", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Roles");
b.HasData(
new
{
Id = new Guid("c8f2f144-e6c2-45d7-ba66-5e9bbd376376"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Администратор",
Name = "administrator"
},
new
{
Id = new Guid("13bca225-7fa4-42fa-9d80-d2d46de261fe"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Робот ЕСПП",
Name = "espp-robot"
});
});
modelBuilder.Entity("PARR.DAL.Models.Setting", b =>
{
b.Property<string>("Name")
@@ -2301,6 +2339,49 @@ namespace PARR.DAL.Migrations
b.ToTable("Tnks");
});
modelBuilder.Entity("PARR.DAL.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("Ip")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Ip")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("PARR.DAL.Models.UsersInRole", b =>
{
b.Property<Guid>("RoleId")
.HasColumnType("uuid");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("RoleId", "UserId");
b.HasIndex("UserId");
b.ToTable("UsersInRoles");
});
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
{
b.Property<Guid>("Id")
@@ -2606,6 +2687,25 @@ namespace PARR.DAL.Migrations
b.Navigation("Subprocess");
});
modelBuilder.Entity("PARR.DAL.Models.UsersInRole", b =>
{
b.HasOne("PARR.DAL.Models.Role", "Role")
.WithMany("Users")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.User", "User")
.WithMany("Roles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
{
b.HasOne("PARR.DAL.Models.Tnk", "Tnk")
@@ -2717,6 +2817,11 @@ namespace PARR.DAL.Migrations
b.Navigation("RobotConfigurations");
});
modelBuilder.Entity("PARR.DAL.Models.Role", b =>
{
b.Navigation("Users");
});
modelBuilder.Entity("PARR.DAL.Models.Subprocess", b =>
{
b.Navigation("Tnks");
@@ -2743,6 +2848,11 @@ namespace PARR.DAL.Migrations
b.Navigation("Works");
});
modelBuilder.Entity("PARR.DAL.Models.User", b =>
{
b.Navigation("Roles");
});
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
{
b.Navigation("ApplicationsInWorks");