diff --git a/osu.Game/Beatmaps/BeatmapDifficulty.cs b/osu.Game/Beatmaps/BeatmapDifficulty.cs index 25e212f3c5..e310c4a646 100644 --- a/osu.Game/Beatmaps/BeatmapDifficulty.cs +++ b/osu.Game/Beatmaps/BeatmapDifficulty.cs @@ -14,6 +14,9 @@ namespace osu.Game.Beatmaps [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int ID { get; set; } + + public int BeatmapInfoID { get; set; } + public float DrainRate { get; set; } = DEFAULT_DIFFICULTY; public float CircleSize { get; set; } = DEFAULT_DIFFICULTY; public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY; diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index c1516f17c9..d2ed5d692c 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -31,6 +31,7 @@ namespace osu.Game.Beatmaps [Required] public BeatmapSetInfo BeatmapSet { get; set; } + public BeatmapMetadata Metadata { get; set; } public int BaseDifficultyID { get; set; } diff --git a/osu.Game/Beatmaps/BeatmapMetadata.cs b/osu.Game/Beatmaps/BeatmapMetadata.cs index 5e47d6c13d..ca8702d222 100644 --- a/osu.Game/Beatmaps/BeatmapMetadata.cs +++ b/osu.Game/Beatmaps/BeatmapMetadata.cs @@ -16,6 +16,14 @@ namespace osu.Game.Beatmaps [NotMapped] public int? OnlineBeatmapSetID { get; set; } + public int? BeatmapSetInfoID { get; set; } + + public BeatmapSetInfo BeatmapSetInfo { get; set; } + + public int? BeatmapInfoID { get; set; } + + public BeatmapInfo BeatmapInfo { get; set; } + public string Title { get; set; } public string TitleUnicode { get; set; } public string Artist { get; set; } diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index bd288621e0..e360f11ba3 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -74,6 +74,9 @@ namespace osu.Game.Database modelBuilder.Entity().HasIndex(b => b.Name).IsUnique(); modelBuilder.Entity().HasIndex(b => b.InstantiationInfo).IsUnique(); modelBuilder.Entity().HasIndex(b => b.Available); + + modelBuilder.Entity().HasOne(m => m.BeatmapSetInfo).WithOne(s => s.Metadata).OnDelete(DeleteBehavior.Cascade); + modelBuilder.Entity().HasOne(m => m.BeatmapInfo).WithOne(b => b.Metadata).OnDelete(DeleteBehavior.Cascade); } private class OsuDbLoggerFactory : ILoggerFactory diff --git a/osu.Game/Migrations/20171014052545_Init.designer.cs b/osu.Game/Migrations/20171017092037_InitialCreate.Designer.cs similarity index 80% rename from osu.Game/Migrations/20171014052545_Init.designer.cs rename to osu.Game/Migrations/20171017092037_InitialCreate.Designer.cs index f151131882..422c1612d2 100644 --- a/osu.Game/Migrations/20171014052545_Init.designer.cs +++ b/osu.Game/Migrations/20171017092037_InitialCreate.Designer.cs @@ -1,7 +1,4 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -// +// using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; @@ -13,8 +10,8 @@ using System; namespace osu.Game.Migrations { [DbContext(typeof(OsuDbContext))] - [Migration("20171014052545_Init")] - partial class Init + [Migration("20171017092037_InitialCreate")] + partial class InitialCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -29,6 +26,8 @@ namespace osu.Game.Migrations b.Property("ApproachRate"); + b.Property("BeatmapInfoID"); + b.Property("CircleSize"); b.Property("DrainRate"); @@ -41,6 +40,9 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("BeatmapInfoID") + .IsUnique(); + b.ToTable("BeatmapDifficulty"); }); @@ -59,8 +61,6 @@ namespace osu.Game.Migrations b.Property("Countdown"); - b.Property("DifficultyID"); - b.Property("DistanceSpacing"); b.Property("GridSize"); @@ -73,8 +73,6 @@ namespace osu.Game.Migrations b.Property("MD5Hash"); - b.Property("MetadataID"); - b.Property("Path"); b.Property("RulesetID"); @@ -97,12 +95,8 @@ namespace osu.Game.Migrations b.HasIndex("BeatmapSetInfoID"); - b.HasIndex("DifficultyID"); - b.HasIndex("MD5Hash"); - b.HasIndex("MetadataID"); - b.HasIndex("RulesetID"); b.ToTable("BeatmapInfo"); @@ -119,10 +113,15 @@ namespace osu.Game.Migrations b.Property("AudioFile"); - b.Property("Author"); + b.Property("AuthorString") + .HasColumnName("Author"); b.Property("BackgroundFile"); + b.Property("BeatmapInfoID"); + + b.Property("BeatmapSetInfoID"); + b.Property("PreviewTime"); b.Property("Source"); @@ -135,6 +134,12 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("BeatmapInfoID") + .IsUnique(); + + b.HasIndex("BeatmapSetInfoID") + .IsUnique(); + b.ToTable("BeatmapMetadata"); }); @@ -168,16 +173,12 @@ namespace osu.Game.Migrations b.Property("Hash"); - b.Property("MetadataID"); - b.Property("Protected"); b.HasKey("ID"); b.HasIndex("DeletePending"); - b.HasIndex("MetadataID"); - b.ToTable("BeatmapSetInfo"); }); @@ -248,6 +249,14 @@ namespace osu.Game.Migrations b.ToTable("RulesetInfo"); }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo") + .WithOne("Difficulty") + .HasForeignKey("osu.Game.Beatmaps.BeatmapDifficulty", "BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") @@ -255,21 +264,25 @@ namespace osu.Game.Migrations .HasForeignKey("BeatmapSetInfoID") .OnDelete(DeleteBehavior.Cascade); - b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "Difficulty") - .WithMany() - .HasForeignKey("DifficultyID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") - .WithMany() - .HasForeignKey("MetadataID"); - b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") .WithMany() .HasForeignKey("RulesetID") .OnDelete(DeleteBehavior.Cascade); }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "BeatmapInfo") + .WithOne("Metadata") + .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSetInfo") + .WithOne("Metadata") + .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") @@ -282,13 +295,6 @@ namespace osu.Game.Migrations .HasForeignKey("FileInfoID") .OnDelete(DeleteBehavior.Cascade); }); - - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => - { - b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") - .WithMany() - .HasForeignKey("MetadataID"); - }); #pragma warning restore 612, 618 } } diff --git a/osu.Game/Migrations/20171014052545_Init.cs b/osu.Game/Migrations/20171017092037_InitialCreate.cs similarity index 86% rename from osu.Game/Migrations/20171014052545_Init.cs rename to osu.Game/Migrations/20171017092037_InitialCreate.cs index 6792f79e3d..2626e2ea74 100644 --- a/osu.Game/Migrations/20171014052545_Init.cs +++ b/osu.Game/Migrations/20171017092037_InitialCreate.cs @@ -1,52 +1,26 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; namespace osu.Game.Migrations { - public partial class Init : Migration + public partial class InitialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "BeatmapDifficulty", + name: "BeatmapSetInfo", columns: table => new { ID = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - ApproachRate = table.Column(type: "REAL", nullable: false), - CircleSize = table.Column(type: "REAL", nullable: false), - DrainRate = table.Column(type: "REAL", nullable: false), - OverallDifficulty = table.Column(type: "REAL", nullable: false), - SliderMultiplier = table.Column(type: "REAL", nullable: false), - SliderTickRate = table.Column(type: "REAL", nullable: false) + DeletePending = table.Column(type: "INTEGER", nullable: false), + Hash = table.Column(type: "TEXT", nullable: true), + Protected = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_BeatmapDifficulty", x => x.ID); - }); - - migrationBuilder.CreateTable( - name: "BeatmapMetadata", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Artist = table.Column(type: "TEXT", nullable: true), - ArtistUnicode = table.Column(type: "TEXT", nullable: true), - AudioFile = table.Column(type: "TEXT", nullable: true), - Author = table.Column(type: "TEXT", nullable: true), - BackgroundFile = table.Column(type: "TEXT", nullable: true), - PreviewTime = table.Column(type: "INTEGER", nullable: false), - Source = table.Column(type: "TEXT", nullable: true), - Tags = table.Column(type: "TEXT", nullable: true), - Title = table.Column(type: "TEXT", nullable: true), - TitleUnicode = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_BeatmapMetadata", x => x.ID); + table.PrimaryKey("PK_BeatmapSetInfo", x => x.ID); }); migrationBuilder.CreateTable( @@ -94,86 +68,6 @@ namespace osu.Game.Migrations table.PrimaryKey("PK_RulesetInfo", x => x.ID); }); - migrationBuilder.CreateTable( - name: "BeatmapSetInfo", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - DeletePending = table.Column(type: "INTEGER", nullable: false), - Hash = table.Column(type: "TEXT", nullable: true), - MetadataID = table.Column(type: "INTEGER", nullable: true), - Protected = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BeatmapSetInfo", x => x.ID); - table.ForeignKey( - name: "FK_BeatmapSetInfo_BeatmapMetadata_MetadataID", - column: x => x.MetadataID, - principalTable: "BeatmapMetadata", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "BeatmapInfo", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - AudioLeadIn = table.Column(type: "INTEGER", nullable: false), - BaseDifficultyID = table.Column(type: "INTEGER", nullable: false), - BeatDivisor = table.Column(type: "INTEGER", nullable: false), - BeatmapSetInfoID = table.Column(type: "INTEGER", nullable: false), - Countdown = table.Column(type: "INTEGER", nullable: false), - DifficultyID = table.Column(type: "INTEGER", nullable: false), - DistanceSpacing = table.Column(type: "REAL", nullable: false), - GridSize = table.Column(type: "INTEGER", nullable: false), - Hash = table.Column(type: "TEXT", nullable: true), - Hidden = table.Column(type: "INTEGER", nullable: false), - LetterboxInBreaks = table.Column(type: "INTEGER", nullable: false), - MD5Hash = table.Column(type: "TEXT", nullable: true), - MetadataID = table.Column(type: "INTEGER", nullable: true), - Path = table.Column(type: "TEXT", nullable: true), - RulesetID = table.Column(type: "INTEGER", nullable: false), - SpecialStyle = table.Column(type: "INTEGER", nullable: false), - StackLeniency = table.Column(type: "REAL", nullable: false), - StarDifficulty = table.Column(type: "REAL", nullable: false), - StoredBookmarks = table.Column(type: "TEXT", nullable: true), - TimelineZoom = table.Column(type: "REAL", nullable: false), - Version = table.Column(type: "TEXT", nullable: true), - WidescreenStoryboard = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BeatmapInfo", x => x.ID); - table.ForeignKey( - name: "FK_BeatmapInfo_BeatmapSetInfo_BeatmapSetInfoID", - column: x => x.BeatmapSetInfoID, - principalTable: "BeatmapSetInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_BeatmapInfo_BeatmapDifficulty_DifficultyID", - column: x => x.DifficultyID, - principalTable: "BeatmapDifficulty", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_BeatmapInfo_BeatmapMetadata_MetadataID", - column: x => x.MetadataID, - principalTable: "BeatmapMetadata", - principalColumn: "ID", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_BeatmapInfo_RulesetInfo_RulesetID", - column: x => x.RulesetID, - principalTable: "RulesetInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "BeatmapSetFileInfo", columns: table => new @@ -201,31 +95,144 @@ namespace osu.Game.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "BeatmapInfo", + columns: table => new + { + ID = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + AudioLeadIn = table.Column(type: "INTEGER", nullable: false), + BaseDifficultyID = table.Column(type: "INTEGER", nullable: false), + BeatDivisor = table.Column(type: "INTEGER", nullable: false), + BeatmapSetInfoID = table.Column(type: "INTEGER", nullable: false), + Countdown = table.Column(type: "INTEGER", nullable: false), + DistanceSpacing = table.Column(type: "REAL", nullable: false), + GridSize = table.Column(type: "INTEGER", nullable: false), + Hash = table.Column(type: "TEXT", nullable: true), + Hidden = table.Column(type: "INTEGER", nullable: false), + LetterboxInBreaks = table.Column(type: "INTEGER", nullable: false), + MD5Hash = table.Column(type: "TEXT", nullable: true), + Path = table.Column(type: "TEXT", nullable: true), + RulesetID = table.Column(type: "INTEGER", nullable: false), + SpecialStyle = table.Column(type: "INTEGER", nullable: false), + StackLeniency = table.Column(type: "REAL", nullable: false), + StarDifficulty = table.Column(type: "REAL", nullable: false), + StoredBookmarks = table.Column(type: "TEXT", nullable: true), + TimelineZoom = table.Column(type: "REAL", nullable: false), + Version = table.Column(type: "TEXT", nullable: true), + WidescreenStoryboard = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BeatmapInfo", x => x.ID); + table.ForeignKey( + name: "FK_BeatmapInfo_BeatmapSetInfo_BeatmapSetInfoID", + column: x => x.BeatmapSetInfoID, + principalTable: "BeatmapSetInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BeatmapInfo_RulesetInfo_RulesetID", + column: x => x.RulesetID, + principalTable: "RulesetInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "BeatmapDifficulty", + columns: table => new + { + ID = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ApproachRate = table.Column(type: "REAL", nullable: false), + BeatmapInfoID = table.Column(type: "INTEGER", nullable: false), + CircleSize = table.Column(type: "REAL", nullable: false), + DrainRate = table.Column(type: "REAL", nullable: false), + OverallDifficulty = table.Column(type: "REAL", nullable: false), + SliderMultiplier = table.Column(type: "REAL", nullable: false), + SliderTickRate = table.Column(type: "REAL", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BeatmapDifficulty", x => x.ID); + table.ForeignKey( + name: "FK_BeatmapDifficulty_BeatmapInfo_BeatmapInfoID", + column: x => x.BeatmapInfoID, + principalTable: "BeatmapInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "BeatmapMetadata", + columns: table => new + { + ID = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Artist = table.Column(type: "TEXT", nullable: true), + ArtistUnicode = table.Column(type: "TEXT", nullable: true), + AudioFile = table.Column(type: "TEXT", nullable: true), + Author = table.Column(type: "TEXT", nullable: true), + BackgroundFile = table.Column(type: "TEXT", nullable: true), + BeatmapInfoID = table.Column(type: "INTEGER", nullable: true), + BeatmapSetInfoID = table.Column(type: "INTEGER", nullable: true), + PreviewTime = table.Column(type: "INTEGER", nullable: false), + Source = table.Column(type: "TEXT", nullable: true), + Tags = table.Column(type: "TEXT", nullable: true), + Title = table.Column(type: "TEXT", nullable: true), + TitleUnicode = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BeatmapMetadata", x => x.ID); + table.ForeignKey( + name: "FK_BeatmapMetadata_BeatmapInfo_BeatmapInfoID", + column: x => x.BeatmapInfoID, + principalTable: "BeatmapInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BeatmapMetadata_BeatmapSetInfo_BeatmapSetInfoID", + column: x => x.BeatmapSetInfoID, + principalTable: "BeatmapSetInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_BeatmapDifficulty_BeatmapInfoID", + table: "BeatmapDifficulty", + column: "BeatmapInfoID", + unique: true); + migrationBuilder.CreateIndex( name: "IX_BeatmapInfo_BeatmapSetInfoID", table: "BeatmapInfo", column: "BeatmapSetInfoID"); - migrationBuilder.CreateIndex( - name: "IX_BeatmapInfo_DifficultyID", - table: "BeatmapInfo", - column: "DifficultyID"); - migrationBuilder.CreateIndex( name: "IX_BeatmapInfo_MD5Hash", table: "BeatmapInfo", column: "MD5Hash"); - migrationBuilder.CreateIndex( - name: "IX_BeatmapInfo_MetadataID", - table: "BeatmapInfo", - column: "MetadataID"); - migrationBuilder.CreateIndex( name: "IX_BeatmapInfo_RulesetID", table: "BeatmapInfo", column: "RulesetID"); + migrationBuilder.CreateIndex( + name: "IX_BeatmapMetadata_BeatmapInfoID", + table: "BeatmapMetadata", + column: "BeatmapInfoID", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_BeatmapMetadata_BeatmapSetInfoID", + table: "BeatmapMetadata", + column: "BeatmapSetInfoID", + unique: true); + migrationBuilder.CreateIndex( name: "IX_BeatmapSetFileInfo_BeatmapSetInfoID", table: "BeatmapSetFileInfo", @@ -241,11 +248,6 @@ namespace osu.Game.Migrations table: "BeatmapSetInfo", column: "DeletePending"); - migrationBuilder.CreateIndex( - name: "IX_BeatmapSetInfo_MetadataID", - table: "BeatmapSetInfo", - column: "MetadataID"); - migrationBuilder.CreateIndex( name: "IX_FileInfo_Hash", table: "FileInfo", @@ -288,7 +290,10 @@ namespace osu.Game.Migrations protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "BeatmapInfo"); + name: "BeatmapDifficulty"); + + migrationBuilder.DropTable( + name: "BeatmapMetadata"); migrationBuilder.DropTable( name: "BeatmapSetFileInfo"); @@ -297,19 +302,16 @@ namespace osu.Game.Migrations name: "KeyBinding"); migrationBuilder.DropTable( - name: "BeatmapDifficulty"); - - migrationBuilder.DropTable( - name: "RulesetInfo"); - - migrationBuilder.DropTable( - name: "BeatmapSetInfo"); + name: "BeatmapInfo"); migrationBuilder.DropTable( name: "FileInfo"); migrationBuilder.DropTable( - name: "BeatmapMetadata"); + name: "BeatmapSetInfo"); + + migrationBuilder.DropTable( + name: "RulesetInfo"); } } } diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index f3a6c5a520..69cc206b7e 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -1,10 +1,11 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -// +// using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage; using osu.Game.Database; +using System; namespace osu.Game.Migrations { @@ -24,6 +25,8 @@ namespace osu.Game.Migrations b.Property("ApproachRate"); + b.Property("BeatmapInfoID"); + b.Property("CircleSize"); b.Property("DrainRate"); @@ -36,6 +39,9 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("BeatmapInfoID") + .IsUnique(); + b.ToTable("BeatmapDifficulty"); }); @@ -54,8 +60,6 @@ namespace osu.Game.Migrations b.Property("Countdown"); - b.Property("DifficultyID"); - b.Property("DistanceSpacing"); b.Property("GridSize"); @@ -68,8 +72,6 @@ namespace osu.Game.Migrations b.Property("MD5Hash"); - b.Property("MetadataID"); - b.Property("Path"); b.Property("RulesetID"); @@ -92,12 +94,8 @@ namespace osu.Game.Migrations b.HasIndex("BeatmapSetInfoID"); - b.HasIndex("DifficultyID"); - b.HasIndex("MD5Hash"); - b.HasIndex("MetadataID"); - b.HasIndex("RulesetID"); b.ToTable("BeatmapInfo"); @@ -114,10 +112,15 @@ namespace osu.Game.Migrations b.Property("AudioFile"); - b.Property("Author"); + b.Property("AuthorString") + .HasColumnName("Author"); b.Property("BackgroundFile"); + b.Property("BeatmapInfoID"); + + b.Property("BeatmapSetInfoID"); + b.Property("PreviewTime"); b.Property("Source"); @@ -130,6 +133,12 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("BeatmapInfoID") + .IsUnique(); + + b.HasIndex("BeatmapSetInfoID") + .IsUnique(); + b.ToTable("BeatmapMetadata"); }); @@ -163,16 +172,12 @@ namespace osu.Game.Migrations b.Property("Hash"); - b.Property("MetadataID"); - b.Property("Protected"); b.HasKey("ID"); b.HasIndex("DeletePending"); - b.HasIndex("MetadataID"); - b.ToTable("BeatmapSetInfo"); }); @@ -243,6 +248,14 @@ namespace osu.Game.Migrations b.ToTable("RulesetInfo"); }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo") + .WithOne("Difficulty") + .HasForeignKey("osu.Game.Beatmaps.BeatmapDifficulty", "BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") @@ -250,21 +263,25 @@ namespace osu.Game.Migrations .HasForeignKey("BeatmapSetInfoID") .OnDelete(DeleteBehavior.Cascade); - b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "Difficulty") - .WithMany() - .HasForeignKey("DifficultyID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") - .WithMany() - .HasForeignKey("MetadataID"); - b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") .WithMany() .HasForeignKey("RulesetID") .OnDelete(DeleteBehavior.Cascade); }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "BeatmapInfo") + .WithOne("Metadata") + .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSetInfo") + .WithOne("Metadata") + .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") @@ -277,13 +294,6 @@ namespace osu.Game.Migrations .HasForeignKey("FileInfoID") .OnDelete(DeleteBehavior.Cascade); }); - - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => - { - b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") - .WithMany() - .HasForeignKey("MetadataID"); - }); #pragma warning restore 612, 618 } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d3ac2d6189..9c6e03249e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -286,9 +286,9 @@ - - - 20171014052545_Init.cs + + + 20171017092037_InitialCreate.cs