mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add books.
This commit is contained in:
7801
Cicm.Database/Migrations/20190617012113_AddBooks.Designer.cs
generated
Normal file
7801
Cicm.Database/Migrations/20190617012113_AddBooks.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
67
Cicm.Database/Migrations/20190617012113_AddBooks.cs
Normal file
67
Cicm.Database/Migrations/20190617012113_AddBooks.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddBooks : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable("Books",
|
||||||
|
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),
|
||||||
|
Isbn = table.Column<string>(maxLength: 13, nullable: true),
|
||||||
|
Pages = table.Column<short>(nullable: true),
|
||||||
|
Edition = table.Column<int>(nullable: true),
|
||||||
|
PreviousId = table.Column<long>(nullable: true),
|
||||||
|
SourceId = table.Column<long>(nullable: true)
|
||||||
|
}, constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Books", x => x.Id);
|
||||||
|
table.ForeignKey("FK_Books_iso3166_1_numeric_CountryId", x => x.CountryId,
|
||||||
|
"iso3166_1_numeric", "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey("FK_Books_Books_PreviousId", x => x.PreviousId, "Books",
|
||||||
|
"Id", onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey("FK_Books_Books_SourceId", x => x.SourceId, "Books", "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_CountryId", "Books", "CountryId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_Edition", "Books", "Edition");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_Isbn", "Books", "Isbn");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_NativeTitle", "Books", "NativeTitle");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_Pages", "Books", "Pages");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_PreviousId", "Books", "PreviousId", unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_Published", "Books", "Published");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_SourceId", "Books", "SourceId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_Synopsis", "Books", "Synopsis")
|
||||||
|
.Annotation("MySql:FullTextIndex", true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_Books_Title", "Books", "Title");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable("Books");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,55 @@ namespace Cicm.Database.Migrations
|
|||||||
modelBuilder.HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
|
modelBuilder.HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Cicm.Database.Models.Book", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id").ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<short?>("CountryId");
|
||||||
|
|
||||||
|
b.Property<int?>("Edition");
|
||||||
|
|
||||||
|
b.Property<string>("Isbn").HasMaxLength(13);
|
||||||
|
|
||||||
|
b.Property<string>("NativeTitle");
|
||||||
|
|
||||||
|
b.Property<short?>("Pages");
|
||||||
|
|
||||||
|
b.Property<long?>("PreviousId");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("Published");
|
||||||
|
|
||||||
|
b.Property<long?>("SourceId");
|
||||||
|
|
||||||
|
b.Property<string>("Synopsis").HasMaxLength(262144);
|
||||||
|
|
||||||
|
b.Property<string>("Title").IsRequired();
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CountryId");
|
||||||
|
|
||||||
|
b.HasIndex("Edition");
|
||||||
|
|
||||||
|
b.HasIndex("Isbn");
|
||||||
|
|
||||||
|
b.HasIndex("NativeTitle");
|
||||||
|
|
||||||
|
b.HasIndex("Pages");
|
||||||
|
|
||||||
|
b.HasIndex("PreviousId").IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Published");
|
||||||
|
|
||||||
|
b.HasIndex("SourceId");
|
||||||
|
|
||||||
|
b.HasIndex("Synopsis").HasAnnotation("MySql:FullTextIndex", true);
|
||||||
|
|
||||||
|
b.HasIndex("Title");
|
||||||
|
|
||||||
|
b.ToTable("Books");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Cicm.Database.Models.BrowserTest", b =>
|
modelBuilder.Entity("Cicm.Database.Models.BrowserTest", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)");
|
b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)");
|
||||||
@@ -5293,6 +5342,17 @@ namespace Cicm.Database.Migrations
|
|||||||
b.HasDiscriminator().HasValue("ApplicationUser");
|
b.HasDiscriminator().HasValue("ApplicationUser");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Cicm.Database.Models.Book", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "Country").WithMany("Books")
|
||||||
|
.HasForeignKey("CountryId");
|
||||||
|
|
||||||
|
b.HasOne("Cicm.Database.Models.Book", "Previous").WithOne("Next")
|
||||||
|
.HasForeignKey("Cicm.Database.Models.Book", "PreviousId");
|
||||||
|
|
||||||
|
b.HasOne("Cicm.Database.Models.Book", "Source").WithMany("Derivates").HasForeignKey("SourceId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Cicm.Database.Models.CompaniesByDocument", b =>
|
modelBuilder.Entity("Cicm.Database.Models.CompaniesByDocument", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Cicm.Database.Models.DocumentCompany", "Company").WithMany("Documents")
|
b.HasOne("Cicm.Database.Models.DocumentCompany", "Company").WithMany("Documents")
|
||||||
|
|||||||
21
Cicm.Database/Models/Book.cs
Normal file
21
Cicm.Database/Models/Book.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Models
|
||||||
|
{
|
||||||
|
public class Book : DocumentBase
|
||||||
|
{
|
||||||
|
[StringLength(13, MinimumLength = 10)]
|
||||||
|
public string Isbn { get; set; }
|
||||||
|
public short? Pages { get; set; }
|
||||||
|
public int? Edition { get; set; }
|
||||||
|
public long? PreviousId { get; set; }
|
||||||
|
public long? SourceId { get; set; }
|
||||||
|
|
||||||
|
public virtual Book Previous { get; set; }
|
||||||
|
public virtual Book Source { get; set; }
|
||||||
|
public virtual Book Next { get; set; }
|
||||||
|
public virtual Iso31661Numeric Country { get; set; }
|
||||||
|
public virtual ICollection<Book> Derivates { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,5 +49,6 @@ namespace Cicm.Database.Models
|
|||||||
public virtual ICollection<Company> Companies { get; set; }
|
public virtual ICollection<Company> Companies { get; set; }
|
||||||
public virtual ICollection<Person> People { get; set; }
|
public virtual ICollection<Person> People { get; set; }
|
||||||
public virtual ICollection<Document> Documents { get; set; }
|
public virtual ICollection<Document> Documents { get; set; }
|
||||||
|
public virtual ICollection<Book> Books { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,7 @@ namespace Cicm.Database.Models
|
|||||||
public virtual DbSet<DocumentCompany> DocumentCompanies { get; set; }
|
public virtual DbSet<DocumentCompany> DocumentCompanies { get; set; }
|
||||||
public virtual DbSet<CompaniesByDocument> CompaniesByDocuments { get; set; }
|
public virtual DbSet<CompaniesByDocument> CompaniesByDocuments { get; set; }
|
||||||
public virtual DbSet<DocumentsByMachine> DocumentsByMachines { get; set; }
|
public virtual DbSet<DocumentsByMachine> DocumentsByMachines { get; set; }
|
||||||
|
public virtual DbSet<Book> Books { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@@ -99,6 +100,33 @@ namespace Cicm.Database.Models
|
|||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity<Book>(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.Isbn);
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.Pages);
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.Edition);
|
||||||
|
|
||||||
|
entity.HasOne(d => d.Previous).WithOne(d => d.Next).HasForeignKey<Book>(d => d.PreviousId)
|
||||||
|
.OnDelete(DeleteBehavior.ClientSetNull);
|
||||||
|
|
||||||
|
entity.HasOne(d => d.Source).WithMany(d => d.Derivates).HasForeignKey(d => d.SourceId)
|
||||||
|
.OnDelete(DeleteBehavior.ClientSetNull);
|
||||||
|
|
||||||
|
entity.HasOne(d => d.Country).WithMany(p => p.Books).HasForeignKey(d => d.CountryId);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<BrowserTest>(entity =>
|
modelBuilder.Entity<BrowserTest>(entity =>
|
||||||
{
|
{
|
||||||
entity.ToTable("browser_tests");
|
entity.ToTable("browser_tests");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.824</Version>
|
<Version>3.0.99.825</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user