mirror of
				https://github.com/zoriya/Kyoo.git
				synced 2025-11-04 03:27:14 -05:00 
			
		
		
		
	Adding unique & index field to slugs
This commit is contained in:
		
							parent
							
								
									0c9b3d04c3
								
							
						
					
					
						commit
						e890c05660
					
				@ -124,6 +124,26 @@ namespace Kyoo
 | 
			
		||||
				.Ignore(x => x.Name);
 | 
			
		||||
			modelBuilder.Entity<PeopleLink>()
 | 
			
		||||
				.Ignore(x => x.ExternalIDs);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			modelBuilder.Entity<Collection>()
 | 
			
		||||
				.HasIndex(x => x.Slug)
 | 
			
		||||
				.IsUnique();
 | 
			
		||||
			modelBuilder.Entity<Genre>()
 | 
			
		||||
				.HasIndex(x => x.Slug)
 | 
			
		||||
				.IsUnique();
 | 
			
		||||
			modelBuilder.Entity<Library>()
 | 
			
		||||
				.HasIndex(x => x.Slug)
 | 
			
		||||
				.IsUnique();
 | 
			
		||||
			modelBuilder.Entity<People>()
 | 
			
		||||
				.HasIndex(x => x.Slug)
 | 
			
		||||
				.IsUnique();
 | 
			
		||||
			modelBuilder.Entity<Show>()
 | 
			
		||||
				.HasIndex(x => x.Slug)
 | 
			
		||||
				.IsUnique();
 | 
			
		||||
			modelBuilder.Entity<Studio>()
 | 
			
		||||
				.HasIndex(x => x.Slug)
 | 
			
		||||
				.IsUnique();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 | 
			
		||||
namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
{
 | 
			
		||||
    [DbContext(typeof(DatabaseContext))]
 | 
			
		||||
    [Migration("20200413152648_Initial")]
 | 
			
		||||
    [Migration("20200414223325_Initial")]
 | 
			
		||||
    partial class Initial
 | 
			
		||||
    {
 | 
			
		||||
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
 | 
			
		||||
@ -41,6 +41,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Collections");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -130,6 +133,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Genres");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -168,6 +174,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Libraries");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -213,6 +222,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("Slug");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Peoples");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -333,6 +345,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("StudioID");
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Shows");
 | 
			
		||||
@ -352,6 +367,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Studios");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -325,6 +325,12 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
                table: "CollectionLinks",
 | 
			
		||||
                column: "ShowID");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Collections_Slug",
 | 
			
		||||
                table: "Collections",
 | 
			
		||||
                column: "Slug",
 | 
			
		||||
                unique: true);
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Episodes_SeasonID",
 | 
			
		||||
                table: "Episodes",
 | 
			
		||||
@ -340,6 +346,18 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
                table: "GenreLinks",
 | 
			
		||||
                column: "GenreID");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Genres_Slug",
 | 
			
		||||
                table: "Genres",
 | 
			
		||||
                column: "Slug",
 | 
			
		||||
                unique: true);
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Libraries_Slug",
 | 
			
		||||
                table: "Libraries",
 | 
			
		||||
                column: "Slug",
 | 
			
		||||
                unique: true);
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_LibraryLinks_CollectionID",
 | 
			
		||||
                table: "LibraryLinks",
 | 
			
		||||
@ -365,16 +383,34 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
                table: "PeopleLinks",
 | 
			
		||||
                column: "ShowID");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Peoples_Slug",
 | 
			
		||||
                table: "Peoples",
 | 
			
		||||
                column: "Slug",
 | 
			
		||||
                unique: true);
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Seasons_ShowID",
 | 
			
		||||
                table: "Seasons",
 | 
			
		||||
                column: "ShowID");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Shows_Slug",
 | 
			
		||||
                table: "Shows",
 | 
			
		||||
                column: "Slug",
 | 
			
		||||
                unique: true);
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Shows_StudioID",
 | 
			
		||||
                table: "Shows",
 | 
			
		||||
                column: "StudioID");
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Studios_Slug",
 | 
			
		||||
                table: "Studios",
 | 
			
		||||
                column: "Slug",
 | 
			
		||||
                unique: true);
 | 
			
		||||
 | 
			
		||||
            migrationBuilder.CreateIndex(
 | 
			
		||||
                name: "IX_Tracks_EpisodeID",
 | 
			
		||||
                table: "Tracks",
 | 
			
		||||
@ -39,6 +39,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Collections");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -128,6 +131,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Genres");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -166,6 +172,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Libraries");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -211,6 +220,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("Slug");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Peoples");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
@ -331,6 +343,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("StudioID");
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Shows");
 | 
			
		||||
@ -350,6 +365,9 @@ namespace Kyoo.Models.DatabaseMigrations.Internal
 | 
			
		||||
 | 
			
		||||
                    b.HasKey("ID");
 | 
			
		||||
 | 
			
		||||
                    b.HasIndex("Slug")
 | 
			
		||||
                        .IsUnique();
 | 
			
		||||
 | 
			
		||||
                    b.ToTable("Studios");
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -52,8 +52,8 @@ namespace Kyoo
 | 
			
		||||
			services.AddDbContext<DatabaseContext>(options =>
 | 
			
		||||
			{
 | 
			
		||||
				options.UseLazyLoadingProxies()
 | 
			
		||||
					.UseSqlite(_configuration.GetConnectionString("Database"))
 | 
			
		||||
					.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
 | 
			
		||||
					.UseSqlite(_configuration.GetConnectionString("Database"));
 | 
			
		||||
					//.UseLoggerFactory(LoggerFactory.Create(builder => builder.AddConsole()));
 | 
			
		||||
			});
 | 
			
		||||
			
 | 
			
		||||
			services.AddDbContext<IdentityDatabase>(options =>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user