Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update EF models to not use driver specific fields (#190)

Leendert de Borste45866fa67a0
diff --git a/src/AliasVault.Admin/appsettings.json b/src/AliasVault.Admin/appsettings.json
index bc79ae18f..189a56ce1 100644
--- a/src/AliasVault.Admin/appsettings.json
+++ b/src/AliasVault.Admin/appsettings.json
@@ -1,7 +1,7 @@
{
- "DatabaseProvider": "sqlite",
+ "DatabaseProvider": "postgresql",
"ConnectionStrings": {
- "AliasServerDbContext": "Data Source=../../database/AliasServerDb.sqlite"
+ "AliasServerDbContext": "Host=localhost;Port=5432;Database=aliasvault;Username=aliasvault;Password=password"
},
"Logging": {
"LogLevel": {
diff --git a/src/Databases/AliasServerDb/AliasServerDb.csproj b/src/Databases/AliasServerDb/AliasServerDb.csproj
index 64798af33..3cd3165ab 100644
--- a/src/Databases/AliasServerDb/AliasServerDb.csproj
+++ b/src/Databases/AliasServerDb/AliasServerDb.csproj
@@ -50,4 +50,8 @@
<ProjectReference Include="..\..\Utilities\AliasVault.WorkerStatus\AliasVault.WorkerStatus.csproj" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Migrations\PostgresqlMigrations\" />
+ </ItemGroup>
+
</Project>
diff --git a/src/Databases/AliasServerDb/AuthLog.cs b/src/Databases/AliasServerDb/AuthLog.cs
index 152956d64..07510007a 100644
--- a/src/Databases/AliasServerDb/AuthLog.cs
+++ b/src/Databases/AliasServerDb/AuthLog.cs
@@ -91,7 +91,6 @@ public class AuthLog
/// Gets or sets the type of authentication event (e.g., Login, Logout, FailedLogin).
/// </summary>
[Required]
- [Column(TypeName = "nvarchar(50)")]
public AuthEventType EventType { get; set; }
/// <summary>
diff --git a/src/Databases/AliasServerDb/Log.cs b/src/Databases/AliasServerDb/Log.cs
index 90a22146b..998279ee7 100644
--- a/src/Databases/AliasServerDb/Log.cs
+++ b/src/Databases/AliasServerDb/Log.cs
@@ -26,13 +26,13 @@ public class Log
/// Gets or sets the application name associated with the log entry.
/// </summary>
[Required]
- [Column(TypeName = "nvarchar(50)")]
+ [MaxLength(50)]
public string Application { get; set; } = null!;
/// <summary>
/// Gets or sets the source context that triggered this log message.
/// </summary>
- [Column(TypeName = "nvarchar(255)")]
+ [MaxLength(255)]
public string SourceContext { get; set; } = null!;
/// <summary>
@@ -48,7 +48,7 @@ public class Log
/// <summary>
/// Gets or sets the log level.
/// </summary>
- [Column(TypeName = "nvarchar(128)")]
+ [MaxLength(128)]
public string Level { get; set; } = null!;
/// <summary>
diff --git a/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241221225053_InitialMigration.Designer.cs b/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241222101415_InitialMigration.Designer.cs
similarity index 98%
rename from src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241221225053_InitialMigration.Designer.cs
rename to src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241222101415_InitialMigration.Designer.cs
index e3333e021..9ebe53de7 100644
--- a/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241221225053_InitialMigration.Designer.cs
+++ b/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241222101415_InitialMigration.Designer.cs
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace AliasServerDb.Migrations.PostgresqlMigrations
{
[DbContext(typeof(AliasServerDbContextPostgresql))]
- [Migration("20241221225053_InitialMigration")]
+ [Migration("20241222101415_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
@@ -253,7 +253,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
.HasColumnType("character varying(100)");
b.Property<int>("EventType")
- .HasColumnType("nvarchar(50)");
+ .HasColumnType("integer");
b.Property<int?>("FailureReason")
.HasColumnType("integer");
@@ -438,7 +438,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("Application")
.IsRequired()
.HasMaxLength(50)
- .HasColumnType("nvarchar(50)");
+ .HasColumnType("character varying(50)");
b.Property<string>("Exception")
.IsRequired()
@@ -447,7 +447,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("Level")
.IsRequired()
.HasMaxLength(128)
- .HasColumnType("nvarchar(128)");
+ .HasColumnType("character varying(128)");
b.Property<string>("LogEvent")
.IsRequired()
@@ -468,7 +468,8 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("SourceContext")
.IsRequired()
- .HasColumnType("nvarchar(255)");
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
b.Property<DateTime>("TimeStamp")
.HasColumnType("timestamp with time zone");
@@ -521,7 +522,8 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("Name")
.IsRequired()
- .HasColumnType("nvarchar(50)");
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
b.Property<DateTime>("RunDate")
.HasColumnType("timestamp with time zone");
diff --git a/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241221225053_InitialMigration.cs b/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241222101415_InitialMigration.cs
similarity index 98%
rename from src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241221225053_InitialMigration.cs
rename to src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241222101415_InitialMigration.cs
index 4ca18b5e6..cf7dabf89 100644
--- a/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241221225053_InitialMigration.cs
+++ b/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/20241222101415_InitialMigration.cs
@@ -1,5 +1,4 @@
-// <auto-generated/>
-using System;
+using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
@@ -104,7 +103,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Username = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
- EventType = table.Column<int>(type: "nvarchar(50)", nullable: false),
+ EventType = table.Column<int>(type: "integer", nullable: false),
IsSuccess = table.Column<bool>(type: "boolean", nullable: false),
FailureReason = table.Column<int>(type: "integer", nullable: true),
IpAddress = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
@@ -142,11 +141,11 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- Application = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
- SourceContext = table.Column<string>(type: "nvarchar(255)", nullable: false),
+ Application = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
+ SourceContext = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
Message = table.Column<string>(type: "text", nullable: false),
MessageTemplate = table.Column<string>(type: "text", nullable: false),
- Level = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
+ Level = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
TimeStamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Exception = table.Column<string>(type: "text", nullable: false),
Properties = table.Column<string>(type: "text", nullable: false),
@@ -192,7 +191,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- Name = table.Column<string>(type: "nvarchar(50)", nullable: false),
+ Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
RunDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
StartTime = table.Column<TimeOnly>(type: "time without time zone", nullable: false),
EndTime = table.Column<TimeOnly>(type: "time without time zone", nullable: true),
diff --git a/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/AliasServerDbContextPostgresqlModelSnapshot.cs b/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/AliasServerDbContextPostgresqlModelSnapshot.cs
index 037cc84af..efe471f3b 100644
--- a/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/AliasServerDbContextPostgresqlModelSnapshot.cs
+++ b/src/Databases/AliasServerDb/Migrations/PostgresqlMigrations/AliasServerDbContextPostgresqlModelSnapshot.cs
@@ -250,7 +250,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
.HasColumnType("character varying(100)");
b.Property<int>("EventType")
- .HasColumnType("nvarchar(50)");
+ .HasColumnType("integer");
b.Property<int?>("FailureReason")
.HasColumnType("integer");
@@ -435,7 +435,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("Application")
.IsRequired()
.HasMaxLength(50)
- .HasColumnType("nvarchar(50)");
+ .HasColumnType("character varying(50)");
b.Property<string>("Exception")
.IsRequired()
@@ -444,7 +444,7 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("Level")
.IsRequired()
.HasMaxLength(128)
- .HasColumnType("nvarchar(128)");
+ .HasColumnType("character varying(128)");
b.Property<string>("LogEvent")
.IsRequired()
@@ -465,7 +465,8 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("SourceContext")
.IsRequired()
- .HasColumnType("nvarchar(255)");
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
b.Property<DateTime>("TimeStamp")
.HasColumnType("timestamp with time zone");
@@ -518,7 +519,8 @@ namespace AliasServerDb.Migrations.PostgresqlMigrations
b.Property<string>("Name")
.IsRequired()
- .HasColumnType("nvarchar(50)");
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
b.Property<DateTime>("RunDate")
.HasColumnType("timestamp with time zone");
diff --git a/src/Databases/AliasServerDb/TaskRunnerJob.cs b/src/Databases/AliasServerDb/TaskRunnerJob.cs
index 6c2033de7..76b0b48bf 100644
--- a/src/Databases/AliasServerDb/TaskRunnerJob.cs
+++ b/src/Databases/AliasServerDb/TaskRunnerJob.cs
@@ -27,7 +27,7 @@ public class TaskRunnerJob
/// Gets or sets the name of the task runner job.
/// </summary>
[Required]
- [Column(TypeName = "nvarchar(50)")]
+ [MaxLength(50)]
public string Name { get; set; } = null!;
/// <summary>