Add media file.

This commit is contained in:
2020-06-11 04:41:50 +01:00
parent 528500889a
commit 283f4f011b
9 changed files with 5875 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,163 @@
/******************************************************************************
// 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 AddMediaFiles : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
/* TODO: For MariaDB >=10.5.2
migrationBuilder.RenameColumn(
name: "Files",
table: "Filesystems", newName: "FilesCount");
*/
migrationBuilder.DropColumn("Files", "Filesystems");
migrationBuilder.AddColumn<ulong>("FilesCount", "Filesystems", nullable: true);
migrationBuilder.CreateTable("MediaFiles", 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),
Path = table.Column<string>(maxLength: 8192, nullable: false),
Name = table.Column<string>(maxLength: 255, nullable: false),
PathSeparator = table.Column<string>(nullable: false),
IsDirectory = table.Column<bool>(nullable: false),
CreationDate = table.Column<DateTime>(nullable: true),
AccessDate = table.Column<DateTime>(nullable: true),
StatusChangeDate = table.Column<DateTime>(nullable: true),
BackupDate = table.Column<DateTime>(nullable: true),
LastWriteDate = table.Column<DateTime>(nullable: true),
Attributes = table.Column<ulong>(nullable: false), PosixMode = table.Column<ushort>(nullable: true),
DeviceNumber = table.Column<uint>(nullable: true), GroupId = table.Column<ulong>(nullable: true),
UserId = table.Column<ulong>(nullable: true), Inode = table.Column<ulong>(nullable: true),
Links = table.Column<ulong>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_MediaFiles", x => x.Id);
});
migrationBuilder.CreateTable("FileDataStreamsByMediaFile", 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),
FileDataStreamId = table.Column<ulong>(nullable: false),
MediaFileId = table.Column<ulong>(nullable: false)
}, constraints: table =>
{
table.PrimaryKey("PK_FileDataStreamsByMediaFile", x => x.Id);
table.ForeignKey("FK_FileDataStreamsByMediaFile_FileDataStreams_FileDataStreamId",
x => x.FileDataStreamId, "FileDataStreams", "Id", onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_FileDataStreamsByMediaFile_MediaFiles_MediaFileId", x => x.MediaFileId,
"MediaFiles", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable("FilesByFilesystem", 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),
FilesystemId = table.Column<ulong>(nullable: false), FileId = table.Column<ulong>(nullable: false)
}, constraints: table =>
{
table.PrimaryKey("PK_FilesByFilesystem", x => x.Id);
table.ForeignKey("FK_FilesByFilesystem_MediaFiles_FileId", x => x.FileId, "MediaFiles", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_FilesByFilesystem_Filesystems_FilesystemId", x => x.FilesystemId, "Filesystems",
"Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_FileDataStreamsByMediaFile_FileDataStreamId", "FileDataStreamsByMediaFile",
"FileDataStreamId");
migrationBuilder.CreateIndex("IX_FileDataStreamsByMediaFile_MediaFileId", "FileDataStreamsByMediaFile",
"MediaFileId");
migrationBuilder.CreateIndex("IX_FilesByFilesystem_FileId", "FilesByFilesystem", "FileId");
migrationBuilder.CreateIndex("IX_FilesByFilesystem_FilesystemId", "FilesByFilesystem", "FilesystemId");
migrationBuilder.CreateIndex("IX_MediaFiles_AccessDate", "MediaFiles", "AccessDate");
migrationBuilder.CreateIndex("IX_MediaFiles_BackupDate", "MediaFiles", "BackupDate");
migrationBuilder.CreateIndex("IX_MediaFiles_CreationDate", "MediaFiles", "CreationDate");
migrationBuilder.CreateIndex("IX_MediaFiles_GroupId", "MediaFiles", "GroupId");
migrationBuilder.CreateIndex("IX_MediaFiles_IsDirectory", "MediaFiles", "IsDirectory");
migrationBuilder.CreateIndex("IX_MediaFiles_LastWriteDate", "MediaFiles", "LastWriteDate");
migrationBuilder.CreateIndex("IX_MediaFiles_Name", "MediaFiles", "Name");
migrationBuilder.CreateIndex("IX_MediaFiles_Path", "MediaFiles", "Path");
migrationBuilder.CreateIndex("IX_MediaFiles_StatusChangeDate", "MediaFiles", "StatusChangeDate");
migrationBuilder.CreateIndex("IX_MediaFiles_UserId", "MediaFiles", "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("FileDataStreamsByMediaFile");
migrationBuilder.DropTable("FilesByFilesystem");
migrationBuilder.DropTable("MediaFiles");
migrationBuilder.DropColumn("FilesCount", "Filesystems");
migrationBuilder.AddColumn<ulong>("Files", "Filesystems", "bigint unsigned", nullable: true);
}
}
}

View File

@@ -815,6 +815,48 @@ namespace Marechai.Database.Migrations
b.ToTable("FileDataStreams");
});
modelBuilder.Entity("Marechai.Database.Models.FileDataStreamsByMediaFile", b =>
{
b.Property<ulong>("Id").ValueGeneratedOnAdd().HasColumnType("bigint unsigned");
b.Property<DateTime>("CreatedOn").ValueGeneratedOnAdd().HasColumnType("datetime(6)");
b.Property<ulong>("FileDataStreamId").HasColumnType("bigint unsigned");
b.Property<ulong>("MediaFileId").HasColumnType("bigint unsigned");
b.Property<DateTime>("UpdatedOn").ValueGeneratedOnAddOrUpdate().HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("FileDataStreamId");
b.HasIndex("MediaFileId");
b.ToTable("FileDataStreamsByMediaFile");
});
modelBuilder.Entity("Marechai.Database.Models.FilesByFilesystem", b =>
{
b.Property<ulong>("Id").ValueGeneratedOnAdd().HasColumnType("bigint unsigned");
b.Property<DateTime>("CreatedOn").ValueGeneratedOnAdd().HasColumnType("datetime(6)");
b.Property<ulong>("FileId").HasColumnType("bigint unsigned");
b.Property<ulong>("FilesystemId").HasColumnType("bigint unsigned");
b.Property<DateTime>("UpdatedOn").ValueGeneratedOnAddOrUpdate().HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("FileId");
b.HasIndex("FilesystemId");
b.ToTable("FilesByFilesystem");
});
modelBuilder.Entity("Marechai.Database.Models.Filesystem", b =>
{
b.Property<ulong>("Id").ValueGeneratedOnAdd().HasColumnType("bigint unsigned");
@@ -839,7 +881,7 @@ namespace Marechai.Database.Migrations
b.Property<DateTime?>("ExpirationDate").HasColumnType("datetime(6)");
b.Property<ulong?>("Files").HasColumnType("bigint unsigned");
b.Property<ulong?>("FilesCount").HasColumnType("bigint unsigned");
b.Property<ulong?>("FreeClusters").HasColumnType("bigint unsigned");
@@ -1973,6 +2015,73 @@ namespace Marechai.Database.Migrations
b.ToTable("MediaDumpTrackImages");
});
modelBuilder.Entity("Marechai.Database.Models.MediaFile", b =>
{
b.Property<ulong>("Id").ValueGeneratedOnAdd().HasColumnType("bigint unsigned");
b.Property<DateTime?>("AccessDate").HasColumnType("datetime(6)");
b.Property<ulong>("Attributes").HasColumnType("bigint unsigned");
b.Property<DateTime?>("BackupDate").HasColumnType("datetime(6)");
b.Property<DateTime>("CreatedOn").ValueGeneratedOnAdd().HasColumnType("datetime(6)");
b.Property<DateTime?>("CreationDate").HasColumnType("datetime(6)");
b.Property<uint?>("DeviceNumber").HasColumnType("int unsigned");
b.Property<ulong?>("GroupId").HasColumnType("bigint unsigned");
b.Property<ulong?>("Inode").HasColumnType("bigint unsigned");
b.Property<bool>("IsDirectory").HasColumnType("bit(1)");
b.Property<DateTime?>("LastWriteDate").HasColumnType("datetime(6)");
b.Property<ulong?>("Links").HasColumnType("bigint unsigned");
b.Property<string>("Name").IsRequired().HasColumnType("varchar(255) CHARACTER SET utf8mb4").
HasMaxLength(255);
b.Property<string>("Path").IsRequired().HasColumnType("longtext CHARACTER SET utf8mb4").
HasMaxLength(8192);
b.Property<string>("PathSeparator").IsRequired().HasColumnType("varchar(1) CHARACTER SET utf8mb4");
b.Property<ushort?>("PosixMode").HasColumnType("smallint unsigned");
b.Property<DateTime?>("StatusChangeDate").HasColumnType("datetime(6)");
b.Property<DateTime>("UpdatedOn").ValueGeneratedOnAddOrUpdate().HasColumnType("datetime(6)");
b.Property<ulong?>("UserId").HasColumnType("bigint unsigned");
b.HasKey("Id");
b.HasIndex("AccessDate");
b.HasIndex("BackupDate");
b.HasIndex("CreationDate");
b.HasIndex("GroupId");
b.HasIndex("IsDirectory");
b.HasIndex("LastWriteDate");
b.HasIndex("Name");
b.HasIndex("Path");
b.HasIndex("StatusChangeDate");
b.HasIndex("UserId");
b.ToTable("MediaFiles");
});
modelBuilder.Entity("Marechai.Database.Models.MemoryByMachine", b =>
{
b.Property<long>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("bigint(20)");
@@ -3172,6 +3281,24 @@ namespace Marechai.Database.Migrations
OnDelete(DeleteBehavior.Cascade).IsRequired();
});
modelBuilder.Entity("Marechai.Database.Models.FileDataStreamsByMediaFile", b =>
{
b.HasOne("Marechai.Database.Models.FileDataStream", "FileDataStream").WithMany().
HasForeignKey("FileDataStreamId").OnDelete(DeleteBehavior.Cascade).IsRequired();
b.HasOne("Marechai.Database.Models.MediaFile", "MediaFile").WithMany("DataStreams").
HasForeignKey("MediaFileId").OnDelete(DeleteBehavior.Cascade).IsRequired();
});
modelBuilder.Entity("Marechai.Database.Models.FilesByFilesystem", b =>
{
b.HasOne("Marechai.Database.Models.MediaFile", "File").WithMany().HasForeignKey("FileId").
OnDelete(DeleteBehavior.Cascade).IsRequired();
b.HasOne("Marechai.Database.Models.Filesystem", "Filesystem").WithMany("Files").
HasForeignKey("FilesystemId").OnDelete(DeleteBehavior.Cascade).IsRequired();
});
modelBuilder.Entity("Marechai.Database.Models.FilesystemsByLogicalPartition", b =>
{
b.HasOne("Marechai.Database.Models.Filesystem", "Filesystem").WithMany("Partitions").

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 FileDataStreamsByMediaFile : BaseModel<ulong>
{
[Required]
public virtual FileDataStream FileDataStream { get; set; }
[Required]
public virtual MediaFile MediaFile { 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 FilesByFilesystem : BaseModel<ulong>
{
[Required]
public virtual Filesystem Filesystem { get; set; }
[Required]
public virtual MediaFile File { get; set; }
}
}

View File

@@ -38,7 +38,7 @@ namespace Marechai.Database.Models
public DateTime? BackupDate { get; set; }
public int ClusterSize { get; set; }
public ulong Clusters { get; set; }
public ulong? Files { get; set; }
public ulong? FilesCount { get; set; }
public bool Bootable { get; set; }
public string Serial { get; set; }
public string Label { get; set; }
@@ -53,5 +53,6 @@ namespace Marechai.Database.Models
public virtual ICollection<FilesystemsByLogicalPartition> Partitions { get; set; }
public virtual ICollection<FilesystemsByMediaDumpFile> MediaDumpFileImages { get; set; }
public virtual ICollection<FilesByFilesystem> Files { get; set; }
}
}

View File

@@ -117,6 +117,7 @@ namespace Marechai.Database.Models
public virtual DbSet<MediaDumpImage> MediaDumpImages { get; set; }
public virtual DbSet<MediaDumpSubchannelImage> MediaDumpSubchannelImages { get; set; }
public virtual DbSet<MediaDumpTrackImage> MediaDumpTrackImages { get; set; }
public virtual DbSet<MediaFile> MediaFiles { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -1770,6 +1771,30 @@ namespace Marechai.Database.Models
entity.HasIndex(e => e.Sha3);
entity.HasIndex(e => e.Spamsum);
});
modelBuilder.Entity<MediaFile>(entity =>
{
entity.HasIndex(e => e.Path);
entity.HasIndex(e => e.Name);
entity.HasIndex(e => e.IsDirectory);
entity.HasIndex(e => e.CreationDate);
entity.HasIndex(e => e.AccessDate);
entity.HasIndex(e => e.StatusChangeDate);
entity.HasIndex(e => e.BackupDate);
entity.HasIndex(e => e.LastWriteDate);
entity.HasIndex(e => e.GroupId);
entity.HasIndex(e => e.UserId);
});
modelBuilder.Entity<FileDataStreamsByMediaFile>(entity =>
{
entity.HasOne(d => d.MediaFile).WithMany(p => p.DataStreams).OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<FilesByFilesystem>(entity =>
{
entity.HasOne(d => d.Filesystem).WithMany(p => p.Files).OnDelete(DeleteBehavior.Cascade);
});
}
}
}

View File

@@ -0,0 +1,58 @@
/******************************************************************************
// 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 System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Aaru.CommonTypes.Structs;
namespace Marechai.Database.Models
{
public class MediaFile : BaseModel<ulong>
{
[StringLength(8192), Required]
public string Path { get; set; }
[StringLength(255), Required]
public string Name { get; set; }
[Required, DefaultValue('/')]
public char PathSeparator { get; set; }
public bool IsDirectory { get; set; }
public DateTime? CreationDate { get; set; }
public DateTime? AccessDate { get; set; }
public DateTime? StatusChangeDate { get; set; }
public DateTime? BackupDate { get; set; }
public DateTime? LastWriteDate { get; set; }
public FileAttributes Attributes { get; set; }
public ushort? PosixMode { get; set; }
public uint? DeviceNumber { get; set; }
public ulong? GroupId { get; set; }
public ulong? UserId { get; set; }
public ulong? Inode { get; set; }
public ulong? Links { get; set; }
public virtual ICollection<FileDataStreamsByMediaFile> DataStreams { get; set; }
}
}

View File

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