partial revert + change
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
using MareSynchronosShared.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace MareSynchronosShared.Data;
|
||||
|
||||
public class MareDbContext : DbContext
|
||||
{
|
||||
#if DEBUG
|
||||
public MareDbContext() { }
|
||||
public MareDbContext(DbContextOptions<MareDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -29,6 +25,11 @@ public class MareDbContext : DbContext
|
||||
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
#endif
|
||||
|
||||
public MareDbContext(DbContextOptions<MareDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<User> Users { get; set; }
|
||||
public DbSet<FileCache> Files { get; set; }
|
||||
@@ -38,7 +39,6 @@ public class MareDbContext : DbContext
|
||||
public DbSet<Auth> Auth { get; set; }
|
||||
public DbSet<LodeStoneAuth> LodeStoneAuth { get; set; }
|
||||
public DbSet<BannedRegistrations> BannedRegistrations { get; set; }
|
||||
public DbSet<Alias> Aliases { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
@@ -46,8 +46,6 @@ public class MareDbContext : DbContext
|
||||
modelBuilder.Entity<Auth>().ToTable("auth");
|
||||
modelBuilder.Entity<User>().ToTable("users");
|
||||
modelBuilder.Entity<User>().HasIndex(c => c.CharacterIdentification);
|
||||
modelBuilder.Entity<Alias>().ToTable("aliases");
|
||||
modelBuilder.Entity<Alias>().HasIndex(c => c.AliasUID);
|
||||
modelBuilder.Entity<FileCache>().ToTable("file_caches");
|
||||
modelBuilder.Entity<FileCache>().HasIndex(c => c.UploaderUID);
|
||||
modelBuilder.Entity<ClientPair>().ToTable("client_pairs");
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
public partial class AddAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_auth_users_user_temp_id",
|
||||
table: "auth");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_client_pairs_users_other_user_temp_id1",
|
||||
table: "client_pairs");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_client_pairs_users_user_temp_id2",
|
||||
table: "client_pairs");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "aliases",
|
||||
columns: table => new
|
||||
{
|
||||
alias_uid = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
||||
user_uid = table.Column<string>(type: "character varying(10)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_aliases", x => x.alias_uid);
|
||||
table.ForeignKey(
|
||||
name: "fk_aliases_users_user_temp_id",
|
||||
column: x => x.user_uid,
|
||||
principalTable: "users",
|
||||
principalColumn: "uid");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_aliases_alias_uid",
|
||||
table: "aliases",
|
||||
column: "alias_uid");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_aliases_user_uid",
|
||||
table: "aliases",
|
||||
column: "user_uid");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_auth_users_user_temp_id1",
|
||||
table: "auth",
|
||||
column: "user_uid",
|
||||
principalTable: "users",
|
||||
principalColumn: "uid");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_client_pairs_users_other_user_temp_id2",
|
||||
table: "client_pairs",
|
||||
column: "other_user_uid",
|
||||
principalTable: "users",
|
||||
principalColumn: "uid",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_client_pairs_users_user_temp_id3",
|
||||
table: "client_pairs",
|
||||
column: "user_uid",
|
||||
principalTable: "users",
|
||||
principalColumn: "uid",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_auth_users_user_temp_id1",
|
||||
table: "auth");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_client_pairs_users_other_user_temp_id2",
|
||||
table: "client_pairs");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_client_pairs_users_user_temp_id3",
|
||||
table: "client_pairs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "aliases");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_auth_users_user_temp_id",
|
||||
table: "auth",
|
||||
column: "user_uid",
|
||||
principalTable: "users",
|
||||
principalColumn: "uid");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_client_pairs_users_other_user_temp_id1",
|
||||
table: "client_pairs",
|
||||
column: "other_user_uid",
|
||||
principalTable: "users",
|
||||
principalColumn: "uid",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_client_pairs_users_user_temp_id2",
|
||||
table: "client_pairs",
|
||||
column: "user_uid",
|
||||
principalTable: "users",
|
||||
principalColumn: "uid",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
[DbContext(typeof(MareDbContext))]
|
||||
[Migration("20220824222011_AddAlias")]
|
||||
[Migration("20220824225157_AddAlias")]
|
||||
partial class AddAlias
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -24,29 +24,6 @@ namespace MareSynchronosServer.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Alias", b =>
|
||||
{
|
||||
b.Property<string>("AliasUID")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("alias_uid");
|
||||
|
||||
b.Property<string>("UserUID")
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("user_uid");
|
||||
|
||||
b.HasKey("AliasUID")
|
||||
.HasName("pk_aliases");
|
||||
|
||||
b.HasIndex("AliasUID")
|
||||
.HasDatabaseName("ix_aliases_alias_uid");
|
||||
|
||||
b.HasIndex("UserUID")
|
||||
.HasDatabaseName("ix_aliases_user_uid");
|
||||
|
||||
b.ToTable("aliases", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Auth", b =>
|
||||
{
|
||||
b.Property<string>("HashedKey")
|
||||
@@ -237,6 +214,11 @@ namespace MareSynchronosServer.Migrations
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("uid");
|
||||
|
||||
b.Property<string>("Alias")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("alias");
|
||||
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
@@ -269,22 +251,12 @@ namespace MareSynchronosServer.Migrations
|
||||
b.ToTable("users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Alias", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosShared.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID")
|
||||
.HasConstraintName("fk_aliases_users_user_temp_id");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Auth", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosShared.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID")
|
||||
.HasConstraintName("fk_auth_users_user_temp_id1");
|
||||
.HasConstraintName("fk_auth_users_user_temp_id");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
@@ -296,14 +268,14 @@ namespace MareSynchronosServer.Migrations
|
||||
.HasForeignKey("OtherUserUID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_client_pairs_users_other_user_temp_id2");
|
||||
.HasConstraintName("fk_client_pairs_users_other_user_temp_id1");
|
||||
|
||||
b.HasOne("MareSynchronosShared.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_client_pairs_users_user_temp_id3");
|
||||
.HasConstraintName("fk_client_pairs_users_user_temp_id2");
|
||||
|
||||
b.Navigation("OtherUser");
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MareSynchronosServer.Migrations
|
||||
{
|
||||
public partial class AddAlias : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "alias",
|
||||
table: "users",
|
||||
type: "character varying(10)",
|
||||
maxLength: 10,
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "alias",
|
||||
table: "users");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,29 +22,6 @@ namespace MareSynchronosServer.Migrations
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Alias", b =>
|
||||
{
|
||||
b.Property<string>("AliasUID")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("alias_uid");
|
||||
|
||||
b.Property<string>("UserUID")
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("user_uid");
|
||||
|
||||
b.HasKey("AliasUID")
|
||||
.HasName("pk_aliases");
|
||||
|
||||
b.HasIndex("AliasUID")
|
||||
.HasDatabaseName("ix_aliases_alias_uid");
|
||||
|
||||
b.HasIndex("UserUID")
|
||||
.HasDatabaseName("ix_aliases_user_uid");
|
||||
|
||||
b.ToTable("aliases", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Auth", b =>
|
||||
{
|
||||
b.Property<string>("HashedKey")
|
||||
@@ -235,6 +212,11 @@ namespace MareSynchronosServer.Migrations
|
||||
.HasColumnType("character varying(10)")
|
||||
.HasColumnName("uid");
|
||||
|
||||
b.Property<string>("Alias")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("alias");
|
||||
|
||||
b.Property<string>("CharacterIdentification")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
@@ -267,22 +249,12 @@ namespace MareSynchronosServer.Migrations
|
||||
b.ToTable("users", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Alias", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosShared.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID")
|
||||
.HasConstraintName("fk_aliases_users_user_temp_id");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MareSynchronosShared.Models.Auth", b =>
|
||||
{
|
||||
b.HasOne("MareSynchronosShared.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID")
|
||||
.HasConstraintName("fk_auth_users_user_temp_id1");
|
||||
.HasConstraintName("fk_auth_users_user_temp_id");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
@@ -294,14 +266,14 @@ namespace MareSynchronosServer.Migrations
|
||||
.HasForeignKey("OtherUserUID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_client_pairs_users_other_user_temp_id2");
|
||||
.HasConstraintName("fk_client_pairs_users_other_user_temp_id1");
|
||||
|
||||
b.HasOne("MareSynchronosShared.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserUID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_client_pairs_users_user_temp_id3");
|
||||
.HasConstraintName("fk_client_pairs_users_user_temp_id2");
|
||||
|
||||
b.Navigation("OtherUser");
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MareSynchronosShared.Models;
|
||||
|
||||
public class Alias
|
||||
{
|
||||
[Key]
|
||||
[MaxLength(10)]
|
||||
[Required]
|
||||
public string AliasUID { get; set; }
|
||||
public User User { get; set; }
|
||||
public string UserUID { get; set; }
|
||||
}
|
||||
@@ -17,5 +17,7 @@ namespace MareSynchronosShared.Models
|
||||
public bool IsAdmin { get; set; } = false;
|
||||
|
||||
public DateTime LastLoggedIn { get; set; }
|
||||
[MaxLength(10)]
|
||||
public string Alias { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user