Add Archive model and migration for storing archive statistics

This commit is contained in:
2025-09-28 01:41:19 +01:00
parent 9850100508
commit e3b051b82f
6 changed files with 3376 additions and 2 deletions

View File

@@ -48,6 +48,7 @@ public sealed class DbContext : IdentityDbContext<IdentityUser>
public DbContext(DbContextOptions<DbContext> options) : base(options) {}
public DbSet<Archive> Archives { get; set; }
public DbSet<Device> Devices { get; set; }
public DbSet<UploadedReport> Reports { get; set; }
public DbSet<Command> Commands { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Aaru.Server.Database.Migrations
{
/// <inheritdoc />
public partial class AddArchiveToStats : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Archives",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Count = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Archives", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Archives");
}
}
}

View File

@@ -17,7 +17,7 @@ namespace Aaru.Server.Database.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true)
@@ -2052,6 +2052,26 @@ namespace Aaru.Server.Database.Migrations
b.ToTable("Usb");
});
modelBuilder.Entity("Aaru.Server.Database.Models.Archive", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<long>("Count")
.HasColumnType("bigint");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Archives");
});
modelBuilder.Entity("Aaru.Server.Database.Models.Command", b =>
{
b.Property<int>("Id")

View File

@@ -0,0 +1,35 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Archive.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Aaru Server.
//
// --[ Description ] ----------------------------------------------------------
//
// Model for storing archive statistics in database.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2024 Natalia Portillo
// ****************************************************************************/
namespace Aaru.Server.Database.Models;
public class Archive : NameCountModel<int> {}