From 4b166c2e4ab8c3cfcaf2e77c190b0507081d775f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 22 Aug 2020 14:52:23 +0100 Subject: [PATCH] Add more hashes to database. --- RomRepoMgr.Database/Context.cs | 4 + ...822134435_AddMoreHashesToFiles.Designer.cs | 181 ++++++++++++++++++ .../20200822134435_AddMoreHashesToFiles.cs | 54 ++++++ .../Migrations/ContextModelSnapshot.cs | 8 + RomRepoMgr.Database/Models/DbFile.cs | 4 + 5 files changed, 251 insertions(+) create mode 100644 RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.Designer.cs create mode 100644 RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.cs diff --git a/RomRepoMgr.Database/Context.cs b/RomRepoMgr.Database/Context.cs index 1ce632d..5ad784c 100644 --- a/RomRepoMgr.Database/Context.cs +++ b/RomRepoMgr.Database/Context.cs @@ -76,6 +76,10 @@ namespace RomRepoMgr.Database entity.HasIndex(e => e.Sha256); + entity.HasIndex(e => e.Sha384); + + entity.HasIndex(e => e.Sha512); + entity.HasIndex(e => e.Size); }); diff --git a/RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.Designer.cs b/RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.Designer.cs new file mode 100644 index 0000000..fd0cdc0 --- /dev/null +++ b/RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.Designer.cs @@ -0,0 +1,181 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RomRepoMgr.Database; + +namespace RomRepoMgr.Database.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20200822134435_AddMoreHashesToFiles")] + partial class AddMoreHashesToFiles + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.7"); + + modelBuilder.Entity("RomRepoMgr.Database.Models.DbFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Crc32") + .HasColumnType("TEXT") + .HasMaxLength(8); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Md5") + .HasColumnType("TEXT") + .HasMaxLength(32); + + b.Property("Sha1") + .HasColumnType("TEXT") + .HasMaxLength(40); + + b.Property("Sha256") + .HasColumnType("TEXT") + .HasMaxLength(64); + + b.Property("Sha384") + .HasColumnType("TEXT") + .HasMaxLength(96); + + b.Property("Sha512") + .HasColumnType("TEXT") + .HasMaxLength(128); + + b.Property("Size") + .HasColumnType("INTEGER"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Crc32"); + + b.HasIndex("Sha1"); + + b.HasIndex("Sha256"); + + b.HasIndex("Sha384"); + + b.HasIndex("Sha512"); + + b.HasIndex("Size"); + + b.ToTable("Files"); + }); + + modelBuilder.Entity("RomRepoMgr.Database.Models.Machine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RomSetId") + .HasColumnType("INTEGER"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.HasIndex("RomSetId"); + + b.ToTable("Machines"); + }); + + modelBuilder.Entity("RomRepoMgr.Database.Models.RomSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Author") + .HasColumnType("TEXT"); + + b.Property("Comment") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasColumnType("TEXT"); + + b.Property("Filename") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Homepage") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Sha384") + .IsRequired() + .HasColumnType("TEXT") + .HasMaxLength(96); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Author"); + + b.HasIndex("Comment"); + + b.HasIndex("Date"); + + b.HasIndex("Description"); + + b.HasIndex("Filename"); + + b.HasIndex("Homepage"); + + b.HasIndex("Name"); + + b.HasIndex("Sha384"); + + b.HasIndex("Version"); + + b.ToTable("RomSets"); + }); + + modelBuilder.Entity("RomRepoMgr.Database.Models.Machine", b => + { + b.HasOne("RomRepoMgr.Database.Models.RomSet", "RomSet") + .WithMany("Machines") + .HasForeignKey("RomSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.cs b/RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.cs new file mode 100644 index 0000000..30b4c02 --- /dev/null +++ b/RomRepoMgr.Database/Migrations/20200822134435_AddMoreHashesToFiles.cs @@ -0,0 +1,54 @@ +/****************************************************************************** +// RomRepoMgr - ROM repository manager +// ---------------------------------------------------------------------------- +// +// Author(s) : Natalia Portillo +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2020 Natalia Portillo +*******************************************************************************/ + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace RomRepoMgr.Database.Migrations +{ + public partial class AddMoreHashesToFiles : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn("Sha384", "Files", maxLength: 96, nullable: true); + + migrationBuilder.AddColumn("Sha512", "Files", maxLength: 128, nullable: true); + + migrationBuilder.CreateIndex("IX_Files_Sha384", "Files", "Sha384"); + + migrationBuilder.CreateIndex("IX_Files_Sha512", "Files", "Sha512"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex("IX_Files_Sha384", "Files"); + + migrationBuilder.DropIndex("IX_Files_Sha512", "Files"); + + migrationBuilder.DropColumn("Sha384", "Files"); + + migrationBuilder.DropColumn("Sha512", "Files"); + } + } +} \ No newline at end of file diff --git a/RomRepoMgr.Database/Migrations/ContextModelSnapshot.cs b/RomRepoMgr.Database/Migrations/ContextModelSnapshot.cs index fac3534..0a93a0d 100644 --- a/RomRepoMgr.Database/Migrations/ContextModelSnapshot.cs +++ b/RomRepoMgr.Database/Migrations/ContextModelSnapshot.cs @@ -28,6 +28,10 @@ namespace RomRepoMgr.Database.Migrations b.Property("Sha256").HasColumnType("TEXT").HasMaxLength(64); + b.Property("Sha384").HasColumnType("TEXT").HasMaxLength(96); + + b.Property("Sha512").HasColumnType("TEXT").HasMaxLength(128); + b.Property("Size").HasColumnType("INTEGER"); b.Property("UpdatedOn").HasColumnType("TEXT"); @@ -40,6 +44,10 @@ namespace RomRepoMgr.Database.Migrations b.HasIndex("Sha256"); + b.HasIndex("Sha384"); + + b.HasIndex("Sha512"); + b.HasIndex("Size"); b.ToTable("Files"); diff --git a/RomRepoMgr.Database/Models/DbFile.cs b/RomRepoMgr.Database/Models/DbFile.cs index e5cb0f7..468bb84 100644 --- a/RomRepoMgr.Database/Models/DbFile.cs +++ b/RomRepoMgr.Database/Models/DbFile.cs @@ -39,5 +39,9 @@ namespace RomRepoMgr.Database.Models public string Sha1 { get; set; } [StringLength(64, MinimumLength = 64)] public string Sha256 { get; set; } + [StringLength(96, MinimumLength = 96)] + public string Sha384 { get; set; } + [StringLength(128, MinimumLength = 128)] + public string Sha512 { get; set; } } } \ No newline at end of file