Add logical partitions by media.

This commit is contained in:
2020-06-11 01:55:48 +01:00
parent 7a258246bf
commit e31a8c4480
8 changed files with 5015 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,67 @@
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Marechai.Database.Migrations
{
public partial class AddLogicalPartitionsByMedia : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("LogicalPartitionsByMedia", table => new
{
Id = table.Column<ulong>(nullable: false).
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
CreatedOn = table.Column<DateTime>(nullable: false).
Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
UpdatedOn = table.Column<DateTime>(nullable: false).
Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.ComputedColumn),
MediaId = table.Column<ulong>(nullable: false), PartitionId = table.Column<ulong>(nullable: false)
}, constraints: table =>
{
table.PrimaryKey("PK_LogicalPartitionsByMedia", x => x.Id);
table.ForeignKey("FK_LogicalPartitionsByMedia_Media_MediaId", x => x.MediaId, "Media", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_LogicalPartitionsByMedia_LogicalPartitions_PartitionId", x => x.PartitionId,
"LogicalPartitions", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_LogicalPartitionsByMedia_MediaId", "LogicalPartitionsByMedia", "MediaId");
migrationBuilder.CreateIndex("IX_LogicalPartitionsByMedia_PartitionId", "LogicalPartitionsByMedia",
"PartitionId");
}
protected override void Down(MigrationBuilder migrationBuilder) =>
migrationBuilder.DropTable("LogicalPartitionsByMedia");
}
}

View File

@@ -1279,6 +1279,27 @@ namespace Marechai.Database.Migrations
b.ToTable("LogicalPartitions"); b.ToTable("LogicalPartitions");
}); });
modelBuilder.Entity("Marechai.Database.Models.LogicalPartitionsByMedia", b =>
{
b.Property<ulong>("Id").ValueGeneratedOnAdd().HasColumnType("bigint unsigned");
b.Property<DateTime>("CreatedOn").ValueGeneratedOnAdd().HasColumnType("datetime(6)");
b.Property<ulong>("MediaId").HasColumnType("bigint unsigned");
b.Property<ulong>("PartitionId").HasColumnType("bigint unsigned");
b.Property<DateTime>("UpdatedOn").ValueGeneratedOnAddOrUpdate().HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("MediaId");
b.HasIndex("PartitionId");
b.ToTable("LogicalPartitionsByMedia");
});
modelBuilder.Entity("Marechai.Database.Models.Machine", b => modelBuilder.Entity("Marechai.Database.Models.Machine", b =>
{ {
b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)"); b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)");
@@ -2962,6 +2983,15 @@ namespace Marechai.Database.Migrations
HasForeignKey("ProcessorId").HasConstraintName("fk_extension_processor_id").IsRequired(); HasForeignKey("ProcessorId").HasConstraintName("fk_extension_processor_id").IsRequired();
}); });
modelBuilder.Entity("Marechai.Database.Models.LogicalPartitionsByMedia", b =>
{
b.HasOne("Marechai.Database.Models.Media", "Media").WithMany("LogicalPartitions").
HasForeignKey("MediaId").OnDelete(DeleteBehavior.Cascade).IsRequired();
b.HasOne("Marechai.Database.Models.LogicalPartition", "Partition").WithMany("Media").
HasForeignKey("PartitionId").OnDelete(DeleteBehavior.Cascade).IsRequired();
});
modelBuilder.Entity("Marechai.Database.Models.Machine", b => modelBuilder.Entity("Marechai.Database.Models.Machine", b =>
{ {
b.HasOne("Marechai.Database.Models.Company", "Company").WithMany("Machines").HasForeignKey("CompanyId"). b.HasOne("Marechai.Database.Models.Company", "Company").WithMany("Machines").HasForeignKey("CompanyId").

View File

@@ -41,5 +41,6 @@ namespace Marechai.Database.Models
public string Scheme { get; set; } public string Scheme { get; set; }
public virtual ICollection<FilesystemsByLogicalPartition> Filesystems { get; set; } public virtual ICollection<FilesystemsByLogicalPartition> Filesystems { get; set; }
public virtual ICollection<LogicalPartitionsByMedia> Media { get; set; }
} }
} }

View File

@@ -0,0 +1,37 @@
/******************************************************************************
// MARECHAI: Master repository of computing history artifacts information
// ----------------------------------------------------------------------------
//
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2003-2020 Natalia Portillo
*******************************************************************************/
using System.ComponentModel.DataAnnotations;
namespace Marechai.Database.Models
{
public class LogicalPartitionsByMedia : BaseModel<ulong>
{
[Required]
public virtual Media Media { get; set; }
[Required]
public virtual LogicalPartition Partition { get; set; }
}
}

View File

@@ -1672,6 +1672,13 @@ namespace Marechai.Database.Models
entity.HasIndex(e => e.Revision); entity.HasIndex(e => e.Revision);
entity.HasIndex(e => e.Firmware); entity.HasIndex(e => e.Firmware);
}); });
modelBuilder.Entity<LogicalPartitionsByMedia>(entity =>
{
entity.HasOne(d => d.Partition).WithMany(p => p.Media).OnDelete(DeleteBehavior.Cascade);
entity.HasOne(d => d.Media).WithMany(p => p.LogicalPartitions).OnDelete(DeleteBehavior.Cascade);
});
} }
} }
} }

View File

@@ -24,6 +24,7 @@
*******************************************************************************/ *******************************************************************************/
using System; using System;
using System.Collections.Generic;
using Aaru.CommonTypes; using Aaru.CommonTypes;
namespace Marechai.Database.Models namespace Marechai.Database.Models
@@ -54,5 +55,7 @@ namespace Marechai.Database.Models
public int? LogicalBlockSize { get; set; } public int? LogicalBlockSize { get; set; }
public JsonObject<VariableBlockSize[]> BlockSizes { get; set; } public JsonObject<VariableBlockSize[]> BlockSizes { get; set; }
public StorageInterface? StorageInterface { get; set; } public StorageInterface? StorageInterface { get; set; }
public virtual ICollection<LogicalPartitionsByMedia> LogicalPartitions { get; set; }
} }
} }

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Version>4.0.0.1681</Version> <Version>4.0.0.1684</Version>
<Company>Canary Islands Computer Museum</Company> <Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright> <Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product> <Product>Canary Islands Computer Museum Website</Product>