mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 23:23:52 +08:00
Fix foreign key constraint failure
This commit is contained in:
parent
5d27c66efa
commit
81b9e08fb6
@ -19,19 +19,20 @@ namespace osu.Game.Beatmaps
|
|||||||
//TODO: should be in database
|
//TODO: should be in database
|
||||||
public int BeatmapVersion;
|
public int BeatmapVersion;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
public int? BeatmapOnlineInfoId { get; set; }
|
public int? BeatmapOnlineInfoId { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
public int? BeatmapSetOnlineInfoId { get; set; }
|
public int? BeatmapSetOnlineInfoId { get; set; }
|
||||||
|
|
||||||
public int BeatmapSetInfoId { get; set; }
|
public int BeatmapSetInfoId { get; set; }
|
||||||
|
|
||||||
public BeatmapSetInfo BeatmapSet { get; set; }
|
public BeatmapSetInfo BeatmapSet { get; set; }
|
||||||
|
|
||||||
public int BeatmapMetadataId { get; set; }
|
public int? BeatmapMetadataId { get; set; }
|
||||||
|
|
||||||
public BeatmapMetadata Metadata { get; set; }
|
public BeatmapMetadata Metadata { get; set; }
|
||||||
|
|
||||||
//[Required]
|
|
||||||
public int BeatmapDifficultyId { get; set; }
|
public int BeatmapDifficultyId { get; set; }
|
||||||
|
|
||||||
public BeatmapDifficulty Difficulty { get; set; }
|
public BeatmapDifficulty Difficulty { get; set; }
|
||||||
|
@ -12,6 +12,7 @@ namespace osu.Game.Beatmaps
|
|||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
public int? BeatmapSetOnlineInfoId { get; set; }
|
public int? BeatmapSetOnlineInfoId { get; set; }
|
||||||
|
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
@ -12,6 +12,7 @@ namespace osu.Game.Beatmaps
|
|||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
public int? BeatmapSetOnlineInfoId { get; set; }
|
public int? BeatmapSetOnlineInfoId { get; set; }
|
||||||
|
|
||||||
public BeatmapMetadata Metadata { get; set; }
|
public BeatmapMetadata Metadata { get; set; }
|
||||||
|
@ -137,22 +137,22 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public BeatmapSetInfo QueryBeatmapSet(Func<BeatmapSetInfo, bool> query)
|
public BeatmapSetInfo QueryBeatmapSet(Func<BeatmapSetInfo, bool> query)
|
||||||
{
|
{
|
||||||
return Connection.BeatmapSetInfo.FirstOrDefault(query);
|
return Connection.BeatmapSetInfo.Include(b=>b.Beatmaps).Include(b=>b.Metadata).FirstOrDefault(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BeatmapSetInfo> QueryBeatmapSets(Expression<Func<BeatmapSetInfo, bool>> query)
|
public List<BeatmapSetInfo> QueryBeatmapSets(Expression<Func<BeatmapSetInfo, bool>> query)
|
||||||
{
|
{
|
||||||
return Connection.BeatmapSetInfo.Where(query).ToList();
|
return Connection.BeatmapSetInfo.Include(b => b.Beatmaps).Include(b => b.Metadata).Include(b=>b.Files).Where(query).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapInfo QueryBeatmap(Func<BeatmapInfo, bool> query)
|
public BeatmapInfo QueryBeatmap(Func<BeatmapInfo, bool> query)
|
||||||
{
|
{
|
||||||
return Connection.BeatmapInfo.FirstOrDefault(query);
|
return Connection.BeatmapInfo.Include(b => b.BeatmapSet).Include(b => b.Metadata).Include(b=>b.Ruleset).FirstOrDefault(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BeatmapInfo> QueryBeatmaps(Expression<Func<BeatmapInfo, bool>> query)
|
public List<BeatmapInfo> QueryBeatmaps(Expression<Func<BeatmapInfo, bool>> query)
|
||||||
{
|
{
|
||||||
return Connection.BeatmapInfo.Where(query).ToList();
|
return Connection.BeatmapInfo.Include(b => b.BeatmapSet).Include(b => b.Metadata).Where(query).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,6 @@ namespace osu.Game.Database
|
|||||||
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.Name).IsUnique();
|
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.Name).IsUnique();
|
||||||
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.InstantiationInfo).IsUnique();
|
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.InstantiationInfo).IsUnique();
|
||||||
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.Available);
|
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.Available);
|
||||||
//modelBuilder.Entity<BeatmapMetadata>().HasOne(b => b.BeatmapSetOnlineInfo).WithOne(bs => bs.BeatmapMetadata).OnDelete(DeleteBehavior.SetNull);
|
|
||||||
//modelBuilder.Entity<BeatmapSetInfo>().HasOne(b => b.BeatmapSetOnlineInfo).WithOne(bs => bs.BeatmapSetInfo).OnDelete(DeleteBehavior.SetNull);
|
|
||||||
//modelBuilder.Entity<BeatmapInfo>().HasOne(b => b.BeatmapSetOnlineInfo).WithMany(bs => bs.Beatmaps).OnDelete(DeleteBehavior.SetNull);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,6 @@ namespace osu.Game
|
|||||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) =>
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) =>
|
||||||
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||||
|
|
||||||
private OsuDbContext dbContext;
|
|
||||||
|
|
||||||
private OsuDbContext createDbContext()
|
private OsuDbContext createDbContext()
|
||||||
{
|
{
|
||||||
var connectionString = Host.Storage.GetDatabaseConnectionString(@"client");
|
var connectionString = Host.Storage.GetDatabaseConnectionString(@"client");
|
||||||
@ -106,7 +104,7 @@ namespace osu.Game
|
|||||||
dependencies.Cache(this);
|
dependencies.Cache(this);
|
||||||
dependencies.Cache(LocalConfig);
|
dependencies.Cache(LocalConfig);
|
||||||
|
|
||||||
dbContext = createDbContext();
|
using (var dbContext = createDbContext())
|
||||||
if (dbContext.Database.GetPendingMigrations().Any())
|
if (dbContext.Database.GetPendingMigrations().Any())
|
||||||
dbContext.Database.Migrate();
|
dbContext.Database.Migrate();
|
||||||
|
|
||||||
@ -116,11 +114,11 @@ namespace osu.Game
|
|||||||
Token = LocalConfig.Get<string>(OsuSetting.Token)
|
Token = LocalConfig.Get<string>(OsuSetting.Token)
|
||||||
});
|
});
|
||||||
|
|
||||||
dependencies.Cache(RulesetStore = new RulesetStore(dbContext));
|
dependencies.Cache(RulesetStore = new RulesetStore(createDbContext()));
|
||||||
dependencies.Cache(FileStore = new FileStore(dbContext, Host.Storage));
|
dependencies.Cache(FileStore = new FileStore(createDbContext(), Host.Storage));
|
||||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, dbContext, RulesetStore, API, Host));
|
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, createDbContext(), RulesetStore, API, Host));
|
||||||
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, dbContext, Host, BeatmapManager, RulesetStore));
|
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, createDbContext(), Host, BeatmapManager, RulesetStore));
|
||||||
dependencies.Cache(KeyBindingStore = new KeyBindingStore(dbContext, RulesetStore));
|
dependencies.Cache(KeyBindingStore = new KeyBindingStore(createDbContext(), RulesetStore));
|
||||||
dependencies.Cache(new OsuColour());
|
dependencies.Cache(new OsuColour());
|
||||||
|
|
||||||
//this completely overrides the framework default. will need to change once we make a proper FontStore.
|
//this completely overrides the framework default. will need to change once we make a proper FontStore.
|
||||||
@ -247,8 +245,6 @@ namespace osu.Game
|
|||||||
LocalConfig.Save();
|
LocalConfig.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
dbContext?.Dispose();
|
|
||||||
|
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
private readonly OsuLogo logo;
|
private readonly OsuLogo logo;
|
||||||
|
|
||||||
private const string menu_music_beatmap_hash = "715a09144f885d746644c1983e285044";
|
private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether we have loaded the menu previously.
|
/// Whether we have loaded the menu previously.
|
||||||
@ -91,7 +91,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz")));
|
setInfo = beatmaps.Import(new OszArchiveReader(game.Resources.GetStream(@"Tracks/circles.osz")));
|
||||||
|
|
||||||
setInfo.Protected = true;
|
setInfo.Protected = true;
|
||||||
beatmaps.Delete(setInfo);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +100,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
welcome = audio.Sample.Get(@"welcome");
|
welcome = audio.Sample.Get(@"welcome");
|
||||||
seeya = audio.Sample.Get(@"seeya");
|
seeya = audio.Sample.Get(@"seeya");
|
||||||
|
beatmaps.Delete(setInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEntering(Screen last)
|
protected override void OnEntering(Screen last)
|
||||||
|
Loading…
Reference in New Issue
Block a user