Add magazines.

This commit is contained in:
2019-06-17 03:40:21 +01:00
parent a4792df520
commit 2ff8cc37f6
7 changed files with 8131 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddMagazines : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("Magazines",
table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(),
NativeTitle = table.Column<string>(nullable: true),
Published = table.Column<DateTime>(nullable: true),
CountryId = table.Column<short>(nullable: true),
Synopsis = table.Column<string>(maxLength: 262144, nullable: true),
Issn = table.Column<string>(maxLength: 8, nullable: true),
FirstPublication = table.Column<DateTime>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_Magazines", x => x.Id);
table.ForeignKey("FK_Magazines_iso3166_1_numeric_CountryId",
x => x.CountryId, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex("IX_Magazines_CountryId", "Magazines", "CountryId");
migrationBuilder.CreateIndex("IX_Magazines_FirstPublication", "Magazines", "FirstPublication");
migrationBuilder.CreateIndex("IX_Magazines_Issn", "Magazines", "Issn");
migrationBuilder.CreateIndex("IX_Magazines_NativeTitle", "Magazines", "NativeTitle");
migrationBuilder.CreateIndex("IX_Magazines_Published", "Magazines", "Published");
migrationBuilder.CreateIndex("IX_Magazines_Synopsis", "Magazines", "Synopsis")
.Annotation("MySql:FullTextIndex", true);
migrationBuilder.CreateIndex("IX_Magazines_Title", "Magazines", "Title");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("Magazines");
}
}
}

View File

@@ -4433,6 +4433,43 @@ namespace Cicm.Database.Migrations
b.ToTable("MachinePhotos");
});
modelBuilder.Entity("Cicm.Database.Models.Magazine", b =>
{
b.Property<long>("Id").ValueGeneratedOnAdd();
b.Property<short?>("CountryId");
b.Property<DateTime?>("FirstPublication");
b.Property<string>("Issn").HasMaxLength(8);
b.Property<string>("NativeTitle");
b.Property<DateTime?>("Published");
b.Property<string>("Synopsis").HasMaxLength(262144);
b.Property<string>("Title").IsRequired();
b.HasKey("Id");
b.HasIndex("CountryId");
b.HasIndex("FirstPublication");
b.HasIndex("Issn");
b.HasIndex("NativeTitle");
b.HasIndex("Published");
b.HasIndex("Synopsis").HasAnnotation("MySql:FullTextIndex", true);
b.HasIndex("Title");
b.ToTable("Magazines");
});
modelBuilder.Entity("Cicm.Database.Models.MemoryByMachine", b =>
{
b.Property<long>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("bigint(20)");
@@ -5594,6 +5631,13 @@ namespace Cicm.Database.Migrations
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Cicm.Database.Models.Magazine",
b =>
{
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "Country").WithMany("Magazines")
.HasForeignKey("CountryId");
});
modelBuilder.Entity("Cicm.Database.Models.MemoryByMachine",
b =>
{

View File

@@ -50,5 +50,6 @@ namespace Cicm.Database.Models
public virtual ICollection<Person> People { get; set; }
public virtual ICollection<Document> Documents { get; set; }
public virtual ICollection<Book> Books { get; set; }
public virtual ICollection<Magazine> Magazines { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace Cicm.Database.Models
{
public class Magazine : DocumentBase
{
[StringLength(8, MinimumLength = 8)]
public string Issn { get; set; }
[DisplayFormat(DataFormatString = "{0:d}")]
[DataType(DataType.Date)]
public DateTime? FirstPublication { get; set; }
public virtual Iso31661Numeric Country { get; set; }
}
}

View File

@@ -90,6 +90,7 @@ namespace Cicm.Database.Models
public virtual DbSet<PeopleByBook> PeopleByBooks { get; set; }
public virtual DbSet<BooksByMachine> BooksByMachines { get; set; }
public virtual DbSet<BooksByMachineFamily> BooksByMachineFamilies { get; set; }
public virtual DbSet<Magazine> Magazines { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -852,6 +853,25 @@ namespace Cicm.Database.Models
entity.HasOne(d => d.License).WithMany(p => p.OwnedMachinePhotos).OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity<Magazine>(entity =>
{
entity.HasIndex(e => e.Title);
entity.HasIndex(e => e.NativeTitle);
entity.HasIndex(e => e.Published);
entity.HasIndex(e => e.CountryId);
entity.HasIndex(e => e.Synopsis).ForMySqlIsFullText();
entity.HasIndex(e => e.Issn);
entity.HasIndex(e => e.FirstPublication);
entity.HasOne(d => d.Country).WithMany(p => p.Magazines).HasForeignKey(d => d.CountryId);
});
modelBuilder.Entity<MemoryByMachine>(entity =>
{
entity.ToTable("memory_by_machine");

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.829</Version>
<Version>3.0.99.830</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>