* some groups stuff * further groups rework * fixes for pause changes * adjsut timeout interval * fixes and namespace change to file scoped * more fixes * further implement groups * fix change group ownership * add some more stuff for groups * more fixes and additions * some fixes based on analyzers, add shard info to ui * add discord command, cleanup * fix regex * add group migration and deletion on user deletion * add api method for client to check health of connection * adjust regex for vanity * fixes for server and bot * fixes some string comparison in linq queries * fixes group leave and sets alias to null * fix syntax in changeownership * add better logging, fixes for group leaving * fixes for group leave Co-authored-by: Stanley Dimant <root.darkarchon@outlook.com>
67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
using MareSynchronosShared.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace MareSynchronosShared.Data;
|
|
|
|
public class MareDbContext : DbContext
|
|
{
|
|
#if DEBUG
|
|
public MareDbContext() { }
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
if (optionsBuilder.IsConfigured)
|
|
{
|
|
base.OnConfiguring(optionsBuilder);
|
|
return;
|
|
}
|
|
|
|
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=mare;Username=postgres", builder =>
|
|
{
|
|
builder.MigrationsHistoryTable("_efmigrationshistory", "public");
|
|
builder.MigrationsAssembly("MareSynchronosShared");
|
|
}).UseSnakeCaseNamingConvention();
|
|
optionsBuilder.EnableThreadSafetyChecks(false);
|
|
|
|
base.OnConfiguring(optionsBuilder);
|
|
}
|
|
#endif
|
|
|
|
public MareDbContext(DbContextOptions<MareDbContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
public DbSet<User> Users { get; set; }
|
|
public DbSet<FileCache> Files { get; set; }
|
|
public DbSet<ClientPair> ClientPairs { get; set; }
|
|
public DbSet<ForbiddenUploadEntry> ForbiddenUploadEntries { get; set; }
|
|
public DbSet<Banned> BannedUsers { get; set; }
|
|
public DbSet<Auth> Auth { get; set; }
|
|
public DbSet<LodeStoneAuth> LodeStoneAuth { get; set; }
|
|
public DbSet<BannedRegistrations> BannedRegistrations { get; set; }
|
|
public DbSet<Group> Groups { get; set; }
|
|
public DbSet<GroupPair> GroupPairs { get; set; }
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Auth>().ToTable("auth");
|
|
modelBuilder.Entity<User>().ToTable("users");
|
|
modelBuilder.Entity<FileCache>().ToTable("file_caches");
|
|
modelBuilder.Entity<FileCache>().HasIndex(c => c.UploaderUID);
|
|
modelBuilder.Entity<ClientPair>().ToTable("client_pairs");
|
|
modelBuilder.Entity<ClientPair>().HasKey(u => new { u.UserUID, u.OtherUserUID });
|
|
modelBuilder.Entity<ClientPair>().HasIndex(c => c.UserUID);
|
|
modelBuilder.Entity<ClientPair>().HasIndex(c => c.OtherUserUID);
|
|
modelBuilder.Entity<ForbiddenUploadEntry>().ToTable("forbidden_upload_entries");
|
|
modelBuilder.Entity<Banned>().ToTable("banned_users");
|
|
modelBuilder.Entity<LodeStoneAuth>().ToTable("lodestone_auth");
|
|
modelBuilder.Entity<BannedRegistrations>().ToTable("banned_registrations");
|
|
modelBuilder.Entity<Group>().ToTable("groups");
|
|
modelBuilder.Entity<Group>().HasIndex(c => c.OwnerUID);
|
|
modelBuilder.Entity<GroupPair>().ToTable("group_pairs");
|
|
modelBuilder.Entity<GroupPair>().HasKey(u => new { u.GroupGID, u.GroupUserUID });
|
|
modelBuilder.Entity<GroupPair>().HasIndex(c => c.GroupUserUID);
|
|
modelBuilder.Entity<GroupPair>().HasIndex(c => c.GroupGID);
|
|
}
|
|
} |