Remove client tables from server db (#58)

This commit is contained in:
Leendert de Borst
2024-07-01 12:46:50 +02:00
parent aae0846639
commit 53ea7c2477
8 changed files with 529 additions and 587 deletions

View File

@@ -32,26 +32,6 @@ public class AliasServerDbContext : IdentityDbContext<AliasVaultUser>
{
}
/// <summary>
/// Gets or sets the Identities DbSet.
/// </summary>
public DbSet<Identity> Identities { get; set; }
/// <summary>
/// Gets or sets the Logins DbSet.
/// </summary>
public DbSet<Login> Logins { get; set; }
/// <summary>
/// Gets or sets the Passwords DbSet.
/// </summary>
public DbSet<Password> Passwords { get; set; }
/// <summary>
/// Gets or sets the Services DbSet.
/// </summary>
public DbSet<Service> Services { get; set; }
/// <summary>
/// Gets or sets the AspNetUserRefreshTokens DbSet.
/// </summary>
@@ -89,41 +69,6 @@ public class AliasServerDbContext : IdentityDbContext<AliasVaultUser>
}
}
// Configure Identity - Login relationship
builder.Entity<Login>()
.HasOne(l => l.Identity)
.WithMany()
.HasForeignKey(l => l.IdentityId)
.OnDelete(DeleteBehavior.Cascade);
// Configure the Login - UserId entity
builder.Entity<Login>()
.HasOne(p => p.User)
.WithMany()
.HasForeignKey(p => p.UserId)
.IsRequired();
// Configure Login - Service relationship
builder.Entity<Login>()
.HasOne(l => l.Service)
.WithMany()
.HasForeignKey(l => l.ServiceId)
.OnDelete(DeleteBehavior.Cascade);
// Configure Login - Password relationship
builder.Entity<Login>()
.HasMany(l => l.Passwords)
.WithOne(p => p.Login)
.HasForeignKey(p => p.LoginId)
.OnDelete(DeleteBehavior.Cascade);
// Configure Identity - DefaultPassword relationship
builder.Entity<Identity>()
.HasOne(i => i.DefaultPassword)
.WithMany()
.HasForeignKey(i => i.DefaultPasswordId)
.OnDelete(DeleteBehavior.SetNull);
// Configure the User - AspNetUserRefreshToken entity
builder.Entity<AspNetUserRefreshToken>()
.HasOne(p => p.User)

View File

@@ -1,135 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="Identity.cs" company="lanedirt">
// Copyright (c) lanedirt. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>
//-----------------------------------------------------------------------
namespace AliasServerDb;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// The identity entity.
/// </summary>
public class Identity
{
/// <summary>
/// Gets or sets the identity primary key.
/// </summary>
[Key]
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the gender.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? Gender { get; set; }
/// <summary>
/// Gets or sets the first name.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? FirstName { get; set; } = null!;
/// <summary>
/// Gets or sets the last name.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? LastName { get; set; } = null!;
/// <summary>
/// Gets or sets the nickname.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? NickName { get; set; }
/// <summary>
/// Gets or sets the birth date.
/// </summary>
public DateTime BirthDate { get; set; }
/// <summary>
/// Gets or sets the address street.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? AddressStreet { get; set; }
/// <summary>
/// Gets or sets the address city.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? AddressCity { get; set; }
/// <summary>
/// Gets or sets the address state.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? AddressState { get; set; }
/// <summary>
/// Gets or sets the address zip code.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? AddressZipCode { get; set; }
/// <summary>
/// Gets or sets the address country.
/// </summary>
[StringLength(255)]
[Column(TypeName = "VARCHAR")]
public string? AddressCountry { get; set; }
/// <summary>
/// Gets or sets the hobbies in CSV format, can contain multiple values separated by ";".
/// </summary>
[StringLength(255)]
public string? Hobbies { get; set; }
/// <summary>
/// Gets or sets the generated email prefix.
/// </summary>
[StringLength(255)]
public string? EmailPrefix { get; set; }
/// <summary>
/// Gets or sets the random generated mobile phone number.
/// </summary>
[StringLength(255)]
public string? PhoneMobile { get; set; }
/// <summary>
/// Gets or sets the generated IBAN bank account number.
/// </summary>
[StringLength(255)]
public string? BankAccountIBAN { get; set; }
/// <summary>
/// Gets or sets the created timestamp.
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// Gets or sets the updated timestamp.
/// </summary>
public DateTime UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the login foreign key.
/// </summary>
public Guid? DefaultPasswordId { get; set; }
/// <summary>
/// Gets or sets the login navigation property.
/// </summary>
[ForeignKey("DefaultPasswordId")]
public virtual Password? DefaultPassword { get; set; }
}

View File

@@ -1,78 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="Login.cs" company="lanedirt">
// Copyright (c) lanedirt. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>
//-----------------------------------------------------------------------
namespace AliasServerDb;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.AspNetCore.Identity;
/// <summary>
/// Login object.
/// </summary>
public class Login
{
/// <summary>
/// Gets or sets Login ID.
/// </summary>
[Key]
public Guid Id { get; set; }
/// <summary>
/// Gets or sets user ID foreign key.
/// </summary>
[StringLength(255)]
public string UserId { get; set; } = null!;
/// <summary>
/// Gets or sets foreign key to the AliasVaultUser object.
/// </summary>
[ForeignKey("UserId")]
public virtual AliasVaultUser User { get; set; } = null!;
/// <summary>
/// Gets or sets optional login description.
/// </summary>
[StringLength(255)]
public string? Description { get; set; }
/// <summary>
/// Gets or sets created timestamp.
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// Gets or sets updated timestamp.
/// </summary>
public DateTime UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the identity ID foreign key.
/// </summary>
public Guid IdentityId { get; set; }
/// <summary>
/// Gets or sets the identity object.
/// </summary>
[ForeignKey("IdentityId")]
public virtual Identity Identity { get; set; } = null!;
/// <summary>
/// Gets or sets the service ID foreign key.
/// </summary>
public Guid ServiceId { get; set; }
/// <summary>
/// Gets or sets the service object.
/// </summary>
[ForeignKey("ServiceId")]
public virtual Service Service { get; set; } = null!;
/// <summary>
/// Gets or sets the password objects.
/// </summary>
public virtual ICollection<Password> Passwords { get; set; } = new List<Password>();
}

View File

@@ -0,0 +1,365 @@
// <auto-generated />
using System;
using AliasServerDb;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AliasServerDb.Migrations
{
[DbContext(typeof(AliasServerDbContext))]
[Migration("20240701104445_RemoveClientTables")]
partial class RemoveClientTables
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true);
modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<bool>("EmailConfirmed")
.HasColumnType("INTEGER");
b.Property<bool>("LockoutEnabled")
.HasColumnType("INTEGER");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("TEXT");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("PasswordHash")
.HasColumnType("TEXT");
b.Property<string>("PhoneNumber")
.HasColumnType("TEXT");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("INTEGER");
b.Property<string>("Salt")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("SecurityStamp")
.HasColumnType("TEXT");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("INTEGER");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Verifier")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("AliasServerDb.AspNetUserRefreshToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("DeviceIdentifier")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("ExpireDate")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("Value")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserRefreshTokens");
});
modelBuilder.Entity("AliasServerDb.Vault", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("VaultBlob")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Vaults");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("ClaimType")
.HasColumnType("TEXT");
b.Property<string>("ClaimValue")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("TEXT");
b.Property<string>("ProviderKey")
.HasColumnType("TEXT");
b.Property<string>("ProviderDisplayName")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("RoleId")
.HasColumnType("TEXT");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("TEXT");
b.Property<string>("LoginProvider")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasColumnType("TEXT");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("AliasServerDb.AspNetUserRefreshToken", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("AliasServerDb.Vault", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AliasServerDb.AliasVaultUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,164 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AliasServerDb.Migrations
{
/// <inheritdoc />
public partial class RemoveClientTables : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Passwords");
migrationBuilder.DropTable(
name: "Logins");
migrationBuilder.DropTable(
name: "Identities");
migrationBuilder.DropTable(
name: "Services");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Services",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
Logo = table.Column<byte[]>(type: "BLOB", nullable: true),
Name = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
Url = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Services", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Identities",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
DefaultPasswordId = table.Column<Guid>(type: "TEXT", nullable: true),
AddressCity = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
AddressCountry = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
AddressState = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
AddressStreet = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
AddressZipCode = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
BankAccountIBAN = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
BirthDate = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
EmailPrefix = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
FirstName = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
Gender = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
Hobbies = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
LastName = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
NickName = table.Column<string>(type: "VARCHAR", maxLength: 255, nullable: true),
PhoneMobile = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Identities", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Logins",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
IdentityId = table.Column<Guid>(type: "TEXT", nullable: false),
ServiceId = table.Column<Guid>(type: "TEXT", nullable: false),
UserId = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Logins", x => x.Id);
table.ForeignKey(
name: "FK_Logins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Logins_Identities_IdentityId",
column: x => x.IdentityId,
principalTable: "Identities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Logins_Services_ServiceId",
column: x => x.ServiceId,
principalTable: "Services",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Passwords",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
LoginId = table.Column<Guid>(type: "TEXT", nullable: false),
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
Value = table.Column<string>(type: "TEXT", maxLength: 255, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Passwords", x => x.Id);
table.ForeignKey(
name: "FK_Passwords_Logins_LoginId",
column: x => x.LoginId,
principalTable: "Logins",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Identities_DefaultPasswordId",
table: "Identities",
column: "DefaultPasswordId");
migrationBuilder.CreateIndex(
name: "IX_Logins_IdentityId",
table: "Logins",
column: "IdentityId");
migrationBuilder.CreateIndex(
name: "IX_Logins_ServiceId",
table: "Logins",
column: "ServiceId");
migrationBuilder.CreateIndex(
name: "IX_Logins_UserId",
table: "Logins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Passwords_LoginId",
table: "Passwords",
column: "LoginId");
migrationBuilder.AddForeignKey(
name: "FK_Identities_Passwords_DefaultPasswordId",
table: "Identities",
column: "DefaultPasswordId",
principalTable: "Passwords",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
}
}

View File

@@ -128,175 +128,6 @@ namespace AliasServerDb.Migrations
b.ToTable("AspNetUserRefreshTokens");
});
modelBuilder.Entity("AliasServerDb.Identity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("AddressCity")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("AddressCountry")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("AddressState")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("AddressStreet")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("AddressZipCode")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("BankAccountIBAN")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("BirthDate")
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<Guid?>("DefaultPasswordId")
.HasColumnType("TEXT");
b.Property<string>("EmailPrefix")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("Gender")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("Hobbies")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("LastName")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("NickName")
.HasMaxLength(255)
.HasColumnType("VARCHAR");
b.Property<string>("PhoneMobile")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("DefaultPasswordId");
b.ToTable("Identities");
});
modelBuilder.Entity("AliasServerDb.Login", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<Guid>("IdentityId")
.HasColumnType("TEXT");
b.Property<Guid>("ServiceId")
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("UserId")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("IdentityId");
b.HasIndex("ServiceId");
b.HasIndex("UserId");
b.ToTable("Logins");
});
modelBuilder.Entity("AliasServerDb.Password", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<Guid>("LoginId")
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("LoginId");
b.ToTable("Passwords");
});
modelBuilder.Entity("AliasServerDb.Service", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreatedAt")
.HasColumnType("TEXT");
b.Property<byte[]>("Logo")
.HasColumnType("BLOB");
b.Property<string>("Name")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("TEXT");
b.Property<string>("Url")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Services");
});
modelBuilder.Entity("AliasServerDb.Vault", b =>
{
b.Property<Guid>("Id")
@@ -464,54 +295,6 @@ namespace AliasServerDb.Migrations
b.Navigation("User");
});
modelBuilder.Entity("AliasServerDb.Identity", b =>
{
b.HasOne("AliasServerDb.Password", "DefaultPassword")
.WithMany()
.HasForeignKey("DefaultPasswordId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("DefaultPassword");
});
modelBuilder.Entity("AliasServerDb.Login", b =>
{
b.HasOne("AliasServerDb.Identity", "Identity")
.WithMany()
.HasForeignKey("IdentityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AliasServerDb.Service", "Service")
.WithMany()
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AliasServerDb.AliasVaultUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Identity");
b.Navigation("Service");
b.Navigation("User");
});
modelBuilder.Entity("AliasServerDb.Password", b =>
{
b.HasOne("AliasServerDb.Login", "Login")
.WithMany("Passwords")
.HasForeignKey("LoginId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Login");
});
modelBuilder.Entity("AliasServerDb.Vault", b =>
{
b.HasOne("AliasServerDb.AliasVaultUser", "User")
@@ -573,11 +356,6 @@ namespace AliasServerDb.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("AliasServerDb.Login", b =>
{
b.Navigation("Passwords");
});
#pragma warning restore 612, 618
}
}

View File

@@ -1,49 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="Password.cs" company="lanedirt">
// Copyright (c) lanedirt. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>
//-----------------------------------------------------------------------
namespace AliasServerDb;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
/// <summary>
/// Password entity.
/// </summary>
public class Password
{
/// <summary>
/// Gets or sets the password primary key.
/// </summary>
[Key]
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the password value.
/// </summary>
[StringLength(255)]
public string? Value { get; set; }
/// <summary>
/// Gets or sets the created timestamp.
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// Gets or sets the updated timestamp.
/// </summary>
public DateTime UpdatedAt { get; set; }
/// <summary>
/// Gets or sets the login foreign key.
/// </summary>
public Guid LoginId { get; set; }
/// <summary>
/// Gets or sets the login navigation property.
/// </summary>
[ForeignKey("LoginId")]
public virtual Login Login { get; set; } = null!;
}

View File

@@ -1,48 +0,0 @@
//-----------------------------------------------------------------------
// <copyright file="Service.cs" company="lanedirt">
// Copyright (c) lanedirt. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
// </copyright>
//-----------------------------------------------------------------------
namespace AliasServerDb;
using System.ComponentModel.DataAnnotations;
/// <summary>
/// The service entity.
/// </summary>
public class Service
{
/// <summary>
/// Gets or sets the service primary key.
/// </summary>
[Key]
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the service name.
/// </summary>
[StringLength(255)]
public string? Name { get; set; }
/// <summary>
/// Gets or sets the service URL.
/// </summary>
[StringLength(255)]
public string? Url { get; set; }
/// <summary>
/// Gets or sets image logo of the service.
/// </summary>
public byte[]? Logo { get; set; } = null;
/// <summary>
/// Gets or sets the created timestamp.
/// </summary>
public DateTime CreatedAt { get; set; }
/// <summary>
/// Gets or sets the updated timestamp.
/// </summary>
public DateTime UpdatedAt { get; set; }
}