Move NameValue statistics to database.

This commit is contained in:
2018-12-21 03:17:35 +00:00
parent ccc249261f
commit a7721f943a
15 changed files with 1588 additions and 211 deletions

View File

@@ -37,13 +37,19 @@ namespace DiscImageChef.Database
{
public sealed class DicContext : DbContext
{
// Note: If table does not appear check that last migration has been REALLY added to the project
public DicContext()
{
Database.Migrate();
}
public DbSet<Device> Devices { get; set; }
public DbSet<Report> Reports { get; set; }
public DbSet<Device> Devices { get; set; }
public DbSet<Report> Reports { get; set; }
public DbSet<Command> Commands { get; set; }
public DbSet<Filesystem> Filesystems { get; set; }
public DbSet<Filter> Filters { get; set; }
public DbSet<MediaFormat> MediaFormats { get; set; }
public DbSet<Partition> Partitions { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{

View File

@@ -64,8 +64,15 @@
<Compile Include="Migrations\20181127001622_AddDeviceBasicFields.Designer.cs" />
<Compile Include="Migrations\20181127013131_CorrectReportsDbSet.cs" />
<Compile Include="Migrations\20181127013131_CorrectReportsDbSet.Designer.cs" />
<Compile Include="Migrations\20181221015906_NameValueStatistics.cs" />
<Compile Include="Migrations\20181221015906_NameValueStatistics.Designer.cs" />
<Compile Include="Migrations\DicContextModelSnapshot.cs" />
<Compile Include="Models\Command.cs" />
<Compile Include="Models\Device.cs" />
<Compile Include="Models\Filesystem.cs" />
<Compile Include="Models\Filter.cs" />
<Compile Include="Models\MediaFormat.cs" />
<Compile Include="Models\Partition.cs" />
<Compile Include="Models\Report.cs" />
</ItemGroup>
<ItemGroup>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DiscImageChef.Database.Migrations
{
public partial class NameValueStatistics : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("Commands",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Synchronized = table.Column<bool>(nullable: false)
}, constraints: table => { table.PrimaryKey("PK_Commands", x => x.Id); });
migrationBuilder.CreateTable("Filesystems",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Synchronized = table.Column<bool>(nullable: false)
},
constraints: table => { table.PrimaryKey("PK_Filesystems", x => x.Id); });
migrationBuilder.CreateTable("Filters",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Synchronized = table.Column<bool>(nullable: false)
}, constraints: table => { table.PrimaryKey("PK_Filters", x => x.Id); });
migrationBuilder.CreateTable("MediaFormats",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Synchronized = table.Column<bool>(nullable: false)
},
constraints: table => { table.PrimaryKey("PK_MediaFormats", x => x.Id); });
migrationBuilder.CreateTable("Partitions",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: true),
Synchronized = table.Column<bool>(nullable: false)
}, constraints: table => { table.PrimaryKey("PK_Partitions", x => x.Id); });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("Commands");
migrationBuilder.DropTable("Filesystems");
migrationBuilder.DropTable("Filters");
migrationBuilder.DropTable("MediaFormats");
migrationBuilder.DropTable("Partitions");
}
}
}

View File

@@ -824,6 +824,19 @@ namespace DiscImageChef.Database.Migrations
b.ToTable("Usb");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Command", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<bool>("Synchronized");
b.HasKey("Id");
b.ToTable("Commands");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Device", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
@@ -877,6 +890,58 @@ namespace DiscImageChef.Database.Migrations
b.ToTable("Devices");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Filesystem", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<bool>("Synchronized");
b.HasKey("Id");
b.ToTable("Filesystems");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Filter", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<bool>("Synchronized");
b.HasKey("Id");
b.ToTable("Filters");
});
modelBuilder.Entity("DiscImageChef.Database.Models.MediaFormat", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<bool>("Synchronized");
b.HasKey("Id");
b.ToTable("MediaFormats");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Partition", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<bool>("Synchronized");
b.HasKey("Id");
b.ToTable("Partitions");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Report", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class Command
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public bool Synchronized { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class Filesystem
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public bool Synchronized { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class Filter
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public bool Synchronized { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class MediaFormat
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public bool Synchronized { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace DiscImageChef.Database.Models
{
public class Partition
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public bool Synchronized { get; set; }
}
}