feat(dal): Applications добавлен уникальный ключ на поле Name

This commit is contained in:
Mikhail Kuznetsov
2024-02-05 16:02:15 +10:00
parent 3d20db4284
commit 745183fc71
4 changed files with 2926 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblApplicationAddIndexNameClmn : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "IP",
table: "Hosts",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.CreateIndex(
name: "IX_Applications_Name",
table: "Applications",
column: "Name",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Applications_Name",
table: "Applications");
migrationBuilder.AlterColumn<string>(
name: "IP",
table: "Hosts",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
}
}

View File

@@ -459,6 +459,9 @@ namespace PARR.DAL.Migrations
b.HasIndex("ApplicationTypeId"); b.HasIndex("ApplicationTypeId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Applications"); b.ToTable("Applications");
}); });
@@ -1621,7 +1624,6 @@ namespace PARR.DAL.Migrations
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<string>("IP") b.Property<string>("IP")
.IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<DateTimeOffset?>("LastLogon") b.Property<DateTimeOffset?>("LastLogon")

View File

@@ -1,10 +1,12 @@
using PARR.DAL.Models.Base; using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models namespace PARR.DAL.Models
{ {
[Table("Applications")] [Table("Applications")]
[Index(nameof(Name), IsUnique = true)]
public class Application : IBase public class Application : IBase
{ {
[Key] [Key]