From 53ea7c24775fd3acb8b06dbb8c74e2d04f1838ea Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Mon, 1 Jul 2024 12:46:50 +0200 Subject: [PATCH] Remove client tables from server db (#58) --- .../AliasServerDb/AliasServerDbContext.cs | 55 --- src/Databases/AliasServerDb/Identity.cs | 135 ------- src/Databases/AliasServerDb/Login.cs | 78 ---- ...40701104445_RemoveClientTables.Designer.cs | 365 ++++++++++++++++++ .../20240701104445_RemoveClientTables.cs | 164 ++++++++ .../AliasServerDbContextModelSnapshot.cs | 222 ----------- src/Databases/AliasServerDb/Password.cs | 49 --- src/Databases/AliasServerDb/Service.cs | 48 --- 8 files changed, 529 insertions(+), 587 deletions(-) delete mode 100644 src/Databases/AliasServerDb/Identity.cs delete mode 100644 src/Databases/AliasServerDb/Login.cs create mode 100644 src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.Designer.cs create mode 100644 src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.cs delete mode 100644 src/Databases/AliasServerDb/Password.cs delete mode 100644 src/Databases/AliasServerDb/Service.cs diff --git a/src/Databases/AliasServerDb/AliasServerDbContext.cs b/src/Databases/AliasServerDb/AliasServerDbContext.cs index d923246ae..00681527c 100644 --- a/src/Databases/AliasServerDb/AliasServerDbContext.cs +++ b/src/Databases/AliasServerDb/AliasServerDbContext.cs @@ -32,26 +32,6 @@ public class AliasServerDbContext : IdentityDbContext { } - /// - /// Gets or sets the Identities DbSet. - /// - public DbSet Identities { get; set; } - - /// - /// Gets or sets the Logins DbSet. - /// - public DbSet Logins { get; set; } - - /// - /// Gets or sets the Passwords DbSet. - /// - public DbSet Passwords { get; set; } - - /// - /// Gets or sets the Services DbSet. - /// - public DbSet Services { get; set; } - /// /// Gets or sets the AspNetUserRefreshTokens DbSet. /// @@ -89,41 +69,6 @@ public class AliasServerDbContext : IdentityDbContext } } - // Configure Identity - Login relationship - builder.Entity() - .HasOne(l => l.Identity) - .WithMany() - .HasForeignKey(l => l.IdentityId) - .OnDelete(DeleteBehavior.Cascade); - - // Configure the Login - UserId entity - builder.Entity() - .HasOne(p => p.User) - .WithMany() - .HasForeignKey(p => p.UserId) - .IsRequired(); - - // Configure Login - Service relationship - builder.Entity() - .HasOne(l => l.Service) - .WithMany() - .HasForeignKey(l => l.ServiceId) - .OnDelete(DeleteBehavior.Cascade); - - // Configure Login - Password relationship - builder.Entity() - .HasMany(l => l.Passwords) - .WithOne(p => p.Login) - .HasForeignKey(p => p.LoginId) - .OnDelete(DeleteBehavior.Cascade); - - // Configure Identity - DefaultPassword relationship - builder.Entity() - .HasOne(i => i.DefaultPassword) - .WithMany() - .HasForeignKey(i => i.DefaultPasswordId) - .OnDelete(DeleteBehavior.SetNull); - // Configure the User - AspNetUserRefreshToken entity builder.Entity() .HasOne(p => p.User) diff --git a/src/Databases/AliasServerDb/Identity.cs b/src/Databases/AliasServerDb/Identity.cs deleted file mode 100644 index e3d9a1ee1..000000000 --- a/src/Databases/AliasServerDb/Identity.cs +++ /dev/null @@ -1,135 +0,0 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) lanedirt. All rights reserved. -// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. -// -//----------------------------------------------------------------------- -namespace AliasServerDb; - -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -/// -/// The identity entity. -/// -public class Identity -{ - /// - /// Gets or sets the identity primary key. - /// - [Key] - public Guid Id { get; set; } - - /// - /// Gets or sets the gender. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? Gender { get; set; } - - /// - /// Gets or sets the first name. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? FirstName { get; set; } = null!; - - /// - /// Gets or sets the last name. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? LastName { get; set; } = null!; - - /// - /// Gets or sets the nickname. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? NickName { get; set; } - - /// - /// Gets or sets the birth date. - /// - public DateTime BirthDate { get; set; } - - /// - /// Gets or sets the address street. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? AddressStreet { get; set; } - - /// - /// Gets or sets the address city. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? AddressCity { get; set; } - - /// - /// Gets or sets the address state. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? AddressState { get; set; } - - /// - /// Gets or sets the address zip code. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? AddressZipCode { get; set; } - - /// - /// Gets or sets the address country. - /// - [StringLength(255)] - [Column(TypeName = "VARCHAR")] - public string? AddressCountry { get; set; } - - /// - /// Gets or sets the hobbies in CSV format, can contain multiple values separated by ";". - /// - [StringLength(255)] - public string? Hobbies { get; set; } - - /// - /// Gets or sets the generated email prefix. - /// - [StringLength(255)] - public string? EmailPrefix { get; set; } - - /// - /// Gets or sets the random generated mobile phone number. - /// - [StringLength(255)] - public string? PhoneMobile { get; set; } - - /// - /// Gets or sets the generated IBAN bank account number. - /// - [StringLength(255)] - public string? BankAccountIBAN { get; set; } - - /// - /// Gets or sets the created timestamp. - /// - public DateTime CreatedAt { get; set; } - - /// - /// Gets or sets the updated timestamp. - /// - public DateTime UpdatedAt { get; set; } - - /// - /// Gets or sets the login foreign key. - /// - public Guid? DefaultPasswordId { get; set; } - - /// - /// Gets or sets the login navigation property. - /// - [ForeignKey("DefaultPasswordId")] - public virtual Password? DefaultPassword { get; set; } -} diff --git a/src/Databases/AliasServerDb/Login.cs b/src/Databases/AliasServerDb/Login.cs deleted file mode 100644 index b31542272..000000000 --- a/src/Databases/AliasServerDb/Login.cs +++ /dev/null @@ -1,78 +0,0 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) lanedirt. All rights reserved. -// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. -// -//----------------------------------------------------------------------- -namespace AliasServerDb; - -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.AspNetCore.Identity; - -/// -/// Login object. -/// -public class Login -{ - /// - /// Gets or sets Login ID. - /// - [Key] - public Guid Id { get; set; } - - /// - /// Gets or sets user ID foreign key. - /// - [StringLength(255)] - public string UserId { get; set; } = null!; - - /// - /// Gets or sets foreign key to the AliasVaultUser object. - /// - [ForeignKey("UserId")] - public virtual AliasVaultUser User { get; set; } = null!; - - /// - /// Gets or sets optional login description. - /// - [StringLength(255)] - public string? Description { get; set; } - - /// - /// Gets or sets created timestamp. - /// - public DateTime CreatedAt { get; set; } - - /// - /// Gets or sets updated timestamp. - /// - public DateTime UpdatedAt { get; set; } - - /// - /// Gets or sets the identity ID foreign key. - /// - public Guid IdentityId { get; set; } - - /// - /// Gets or sets the identity object. - /// - [ForeignKey("IdentityId")] - public virtual Identity Identity { get; set; } = null!; - - /// - /// Gets or sets the service ID foreign key. - /// - public Guid ServiceId { get; set; } - - /// - /// Gets or sets the service object. - /// - [ForeignKey("ServiceId")] - public virtual Service Service { get; set; } = null!; - - /// - /// Gets or sets the password objects. - /// - public virtual ICollection Passwords { get; set; } = new List(); -} diff --git a/src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.Designer.cs b/src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.Designer.cs new file mode 100644 index 000000000..ceda900be --- /dev/null +++ b/src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.Designer.cs @@ -0,0 +1,365 @@ +// +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 + { + /// + 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("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("Salt") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("DeviceIdentifier") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("ExpireDate") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserRefreshTokens"); + }); + + modelBuilder.Entity("AliasServerDb.Vault", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property("VaultBlob") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Vaults"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("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", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("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", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("AliasServerDb.AliasVaultUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("AliasServerDb.AliasVaultUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", 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", b => + { + b.HasOne("AliasServerDb.AliasVaultUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.cs b/src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.cs new file mode 100644 index 000000000..40129949b --- /dev/null +++ b/src/Databases/AliasServerDb/Migrations/20240701104445_RemoveClientTables.cs @@ -0,0 +1,164 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AliasServerDb.Migrations +{ + /// + public partial class RemoveClientTables : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Passwords"); + + migrationBuilder.DropTable( + name: "Logins"); + + migrationBuilder.DropTable( + name: "Identities"); + + migrationBuilder.DropTable( + name: "Services"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Services", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + Logo = table.Column(type: "BLOB", nullable: true), + Name = table.Column(type: "TEXT", maxLength: 255, nullable: true), + UpdatedAt = table.Column(type: "TEXT", nullable: false), + Url = table.Column(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(type: "TEXT", nullable: false), + DefaultPasswordId = table.Column(type: "TEXT", nullable: true), + AddressCity = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + AddressCountry = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + AddressState = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + AddressStreet = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + AddressZipCode = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + BankAccountIBAN = table.Column(type: "TEXT", maxLength: 255, nullable: true), + BirthDate = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + EmailPrefix = table.Column(type: "TEXT", maxLength: 255, nullable: true), + FirstName = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + Gender = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + Hobbies = table.Column(type: "TEXT", maxLength: 255, nullable: true), + LastName = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + NickName = table.Column(type: "VARCHAR", maxLength: 255, nullable: true), + PhoneMobile = table.Column(type: "TEXT", maxLength: 255, nullable: true), + UpdatedAt = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Identities", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Logins", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + IdentityId = table.Column(type: "TEXT", nullable: false), + ServiceId = table.Column(type: "TEXT", nullable: false), + UserId = table.Column(type: "TEXT", maxLength: 255, nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", maxLength: 255, nullable: true), + UpdatedAt = table.Column(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(type: "TEXT", nullable: false), + LoginId = table.Column(type: "TEXT", nullable: false), + CreatedAt = table.Column(type: "TEXT", nullable: false), + UpdatedAt = table.Column(type: "TEXT", nullable: false), + Value = table.Column(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); + } + } +} diff --git a/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs index 5d4ae45d4..816c96039 100644 --- a/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs +++ b/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs @@ -128,175 +128,6 @@ namespace AliasServerDb.Migrations b.ToTable("AspNetUserRefreshTokens"); }); - modelBuilder.Entity("AliasServerDb.Identity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("AddressCity") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("AddressCountry") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("AddressState") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("AddressStreet") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("AddressZipCode") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("BankAccountIBAN") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("BirthDate") - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("DefaultPasswordId") - .HasColumnType("TEXT"); - - b.Property("EmailPrefix") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("FirstName") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("Gender") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("Hobbies") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("LastName") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("NickName") - .HasMaxLength(255) - .HasColumnType("VARCHAR"); - - b.Property("PhoneMobile") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("UpdatedAt") - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("DefaultPasswordId"); - - b.ToTable("Identities"); - }); - - modelBuilder.Entity("AliasServerDb.Login", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("IdentityId") - .HasColumnType("TEXT"); - - b.Property("ServiceId") - .HasColumnType("TEXT"); - - b.Property("UpdatedAt") - .HasColumnType("TEXT"); - - b.Property("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("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("LoginId") - .HasColumnType("TEXT"); - - b.Property("UpdatedAt") - .HasColumnType("TEXT"); - - b.Property("Value") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.HasIndex("LoginId"); - - b.ToTable("Passwords"); - }); - - modelBuilder.Entity("AliasServerDb.Service", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT"); - - b.Property("CreatedAt") - .HasColumnType("TEXT"); - - b.Property("Logo") - .HasColumnType("BLOB"); - - b.Property("Name") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.Property("UpdatedAt") - .HasColumnType("TEXT"); - - b.Property("Url") - .HasMaxLength(255) - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Services"); - }); - modelBuilder.Entity("AliasServerDb.Vault", b => { b.Property("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 } } diff --git a/src/Databases/AliasServerDb/Password.cs b/src/Databases/AliasServerDb/Password.cs deleted file mode 100644 index eaa4843ca..000000000 --- a/src/Databases/AliasServerDb/Password.cs +++ /dev/null @@ -1,49 +0,0 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) lanedirt. All rights reserved. -// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. -// -//----------------------------------------------------------------------- -namespace AliasServerDb; - -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -/// -/// Password entity. -/// -public class Password -{ - /// - /// Gets or sets the password primary key. - /// - [Key] - public Guid Id { get; set; } - - /// - /// Gets or sets the password value. - /// - [StringLength(255)] - public string? Value { get; set; } - - /// - /// Gets or sets the created timestamp. - /// - public DateTime CreatedAt { get; set; } - - /// - /// Gets or sets the updated timestamp. - /// - public DateTime UpdatedAt { get; set; } - - /// - /// Gets or sets the login foreign key. - /// - public Guid LoginId { get; set; } - - /// - /// Gets or sets the login navigation property. - /// - [ForeignKey("LoginId")] - public virtual Login Login { get; set; } = null!; -} diff --git a/src/Databases/AliasServerDb/Service.cs b/src/Databases/AliasServerDb/Service.cs deleted file mode 100644 index 9ad852453..000000000 --- a/src/Databases/AliasServerDb/Service.cs +++ /dev/null @@ -1,48 +0,0 @@ -//----------------------------------------------------------------------- -// -// Copyright (c) lanedirt. All rights reserved. -// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. -// -//----------------------------------------------------------------------- -namespace AliasServerDb; - -using System.ComponentModel.DataAnnotations; - -/// -/// The service entity. -/// -public class Service -{ - /// - /// Gets or sets the service primary key. - /// - [Key] - public Guid Id { get; set; } - - /// - /// Gets or sets the service name. - /// - [StringLength(255)] - public string? Name { get; set; } - - /// - /// Gets or sets the service URL. - /// - [StringLength(255)] - public string? Url { get; set; } - - /// - /// Gets or sets image logo of the service. - /// - public byte[]? Logo { get; set; } = null; - - /// - /// Gets or sets the created timestamp. - /// - public DateTime CreatedAt { get; set; } - - /// - /// Gets or sets the updated timestamp. - /// - public DateTime UpdatedAt { get; set; } -}