Add database entities for USB vendor and product IDs.

This commit is contained in:
2018-12-24 06:29:52 +00:00
parent 93baf690cd
commit 383794bace
14 changed files with 1809 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace DiscImageChef.Database.Migrations
{
public partial class StoreUsbIdsInDatabase : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("UsbVendors",
table => new
{
Id = table.Column<ushort>(nullable: false),
Vendor = table.Column<string>(nullable: true),
AddedWhen = table.Column<DateTime>(nullable: false),
ModifiedWhen = table.Column<DateTime>(nullable: false)
}, constraints: table => { table.PrimaryKey("PK_UsbVendors", x => x.Id); });
migrationBuilder.CreateTable("UsbProducts",
table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ProductId = table.Column<ushort>(nullable: false),
Product = table.Column<string>(nullable: true),
AddedWhen = table.Column<DateTime>(nullable: false),
ModifiedWhen = table.Column<DateTime>(nullable: false),
VendorId = table.Column<ushort>(nullable: false)
}, constraints: table =>
{
table.PrimaryKey("PK_UsbProducts", x => x.Id);
table.ForeignKey("FK_UsbProducts_UsbVendors_VendorId", x => x.VendorId,
"UsbVendors", "Id", onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_UsbProducts_VendorId", "UsbProducts", "VendorId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("UsbProducts");
migrationBuilder.DropTable("UsbVendors");
}
}
}

View File

@@ -1122,6 +1122,42 @@ namespace DiscImageChef.Database.Migrations
b.ToTable("Reports");
});
modelBuilder.Entity("DiscImageChef.Database.Models.UsbProduct", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<DateTime>("AddedWhen");
b.Property<DateTime>("ModifiedWhen");
b.Property<string>("Product");
b.Property<ushort>("ProductId");
b.Property<ushort>("VendorId");
b.HasKey("Id");
b.HasIndex("VendorId");
b.ToTable("UsbProducts");
});
modelBuilder.Entity("DiscImageChef.Database.Models.UsbVendor", b =>
{
b.Property<ushort>("Id").ValueGeneratedOnAdd();
b.Property<DateTime>("AddedWhen");
b.Property<DateTime>("ModifiedWhen");
b.Property<string>("Vendor");
b.HasKey("Id");
b.ToTable("UsbVendors");
});
modelBuilder.Entity("DiscImageChef.Database.Models.Version", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
@@ -1270,6 +1306,13 @@ namespace DiscImageChef.Database.Migrations
b.HasOne("DiscImageChef.CommonTypes.Metadata.Usb", "USB").WithMany().HasForeignKey("USBId");
});
modelBuilder.Entity("DiscImageChef.Database.Models.UsbProduct",
b =>
{
b.HasOne("DiscImageChef.Database.Models.UsbVendor", "Vendor").WithMany("Products")
.HasForeignKey("VendorId").OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}