feat(db): EF migration AddTemplateFolders
This commit is contained in:
1282
src/ScadaLink.ConfigurationDatabase/Migrations/20260511144239_AddTemplateFolders.Designer.cs
generated
Normal file
1282
src/ScadaLink.ConfigurationDatabase/Migrations/20260511144239_AddTemplateFolders.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ScadaLink.ConfigurationDatabase.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddTemplateFolders : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "FolderId",
|
||||||
|
table: "Templates",
|
||||||
|
type: "int",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "TemplateFolders",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||||
|
ParentFolderId = table.Column<int>(type: "int", nullable: true),
|
||||||
|
SortOrder = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_TemplateFolders", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_TemplateFolders_TemplateFolders_ParentFolderId",
|
||||||
|
column: x => x.ParentFolderId,
|
||||||
|
principalTable: "TemplateFolders",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Templates_FolderId",
|
||||||
|
table: "Templates",
|
||||||
|
column: "FolderId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_TemplateFolders_ParentFolderId_Name",
|
||||||
|
table: "TemplateFolders",
|
||||||
|
columns: new[] { "ParentFolderId", "Name" },
|
||||||
|
unique: true,
|
||||||
|
filter: "[ParentFolderId] IS NOT NULL");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Templates_TemplateFolders_FolderId",
|
||||||
|
table: "Templates",
|
||||||
|
column: "FolderId",
|
||||||
|
principalTable: "TemplateFolders",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Templates_TemplateFolders_FolderId",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "TemplateFolders");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Templates_FolderId",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "FolderId",
|
||||||
|
table: "Templates");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -845,6 +845,9 @@ namespace ScadaLink.ConfigurationDatabase.Migrations
|
|||||||
.HasMaxLength(2000)
|
.HasMaxLength(2000)
|
||||||
.HasColumnType("nvarchar(2000)");
|
.HasColumnType("nvarchar(2000)");
|
||||||
|
|
||||||
|
b.Property<int?>("FolderId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(200)
|
.HasMaxLength(200)
|
||||||
@@ -855,6 +858,8 @@ namespace ScadaLink.ConfigurationDatabase.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("FolderId");
|
||||||
|
|
||||||
b.HasIndex("Name")
|
b.HasIndex("Name")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
@@ -982,6 +987,34 @@ namespace ScadaLink.ConfigurationDatabase.Migrations
|
|||||||
b.ToTable("TemplateCompositions");
|
b.ToTable("TemplateCompositions");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.TemplateFolder", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("nvarchar(200)");
|
||||||
|
|
||||||
|
b.Property<int?>("ParentFolderId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SortOrder")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ParentFolderId", "Name")
|
||||||
|
.IsUnique()
|
||||||
|
.HasFilter("[ParentFolderId] IS NOT NULL");
|
||||||
|
|
||||||
|
b.ToTable("TemplateFolders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.TemplateScript", b =>
|
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.TemplateScript", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -1152,6 +1185,11 @@ namespace ScadaLink.ConfigurationDatabase.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.Template", b =>
|
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.Template", b =>
|
||||||
{
|
{
|
||||||
|
b.HasOne("ScadaLink.Commons.Entities.Templates.TemplateFolder", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("FolderId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
b.HasOne("ScadaLink.Commons.Entities.Templates.Template", null)
|
b.HasOne("ScadaLink.Commons.Entities.Templates.Template", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("ParentTemplateId")
|
.HasForeignKey("ParentTemplateId")
|
||||||
@@ -1191,6 +1229,14 @@ namespace ScadaLink.ConfigurationDatabase.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.TemplateFolder", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ScadaLink.Commons.Entities.Templates.TemplateFolder", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ParentFolderId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.TemplateScript", b =>
|
modelBuilder.Entity("ScadaLink.Commons.Entities.Templates.TemplateScript", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ScadaLink.Commons.Entities.Templates.Template", null)
|
b.HasOne("ScadaLink.Commons.Entities.Templates.Template", null)
|
||||||
|
|||||||
Reference in New Issue
Block a user