Updated Db models

This commit is contained in:
Toastie (DCS Team) 2024-06-29 17:50:16 +12:00
parent 5e7c75a498
commit c5cd772126
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
7 changed files with 39 additions and 36 deletions

View file

@ -1,4 +1,4 @@
#nullable disable
#nullable disable
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using EllieBot.Db.Models;
@ -282,10 +282,10 @@ public abstract class EllieContext : DbContext
var selfassignableRolesEntity = modelBuilder.Entity<SelfAssignedRole>();
selfassignableRolesEntity.HasIndex(s => new
{
s.GuildId,
s.RoleId
})
{
s.GuildId,
s.RoleId
})
.IsUnique();
selfassignableRolesEntity.Property(x => x.Group).HasDefaultValue(0);
@ -358,10 +358,10 @@ public abstract class EllieContext : DbContext
var xps = modelBuilder.Entity<UserXpStats>();
xps.HasIndex(x => new
{
x.UserId,
x.GuildId
})
{
x.UserId,
x.GuildId
})
.IsUnique();
xps.HasIndex(x => x.UserId);
@ -407,9 +407,9 @@ public abstract class EllieContext : DbContext
.OnDelete(DeleteBehavior.SetNull);
ci.HasIndex(x => new
{
x.Name
})
{
x.Name
})
.IsUnique();
#endregion
@ -528,10 +528,10 @@ public abstract class EllieContext : DbContext
.IsUnique(false);
rr2.HasIndex(x => new
{
x.MessageId,
x.Emote
})
{
x.MessageId,
x.Emote
})
.IsUnique();
});
@ -606,11 +606,11 @@ public abstract class EllieContext : DbContext
{
// user can own only one of each item
x.HasIndex(model => new
{
model.UserId,
model.ItemType,
model.ItemKey
})
{
model.UserId,
model.ItemType,
model.ItemKey
})
.IsUnique();
});
@ -635,10 +635,10 @@ public abstract class EllieContext : DbContext
#region Sticky Roles
modelBuilder.Entity<StickyRole>(sr => sr.HasIndex(x => new
{
x.GuildId,
x.UserId
})
{
x.GuildId,
x.UserId
})
.IsUnique());
#endregion

View file

@ -1,4 +1,5 @@
#nullable disable
namespace EllieBot.Db;
public readonly struct LevelStats

View file

@ -1,6 +1,7 @@
#nullable disable
namespace EllieBot.Db.Models;
// FUTURE remove LastLevelUp from here and UserXpStats
public class DiscordUser : DbEntity
{

View file

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace EllieBot.Db.Models;
public class AntiRaidSetting : DbEntity
{
public int GuildConfigId { get; set; }