mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-04-08 20:58:01 +02:00
Include created timestamp in user migration
This commit is contained in:
parent
c29756ac6e
commit
863f14e25f
@ -105,8 +105,21 @@ public class MigrateToPostgres : IMigration
|
||||
{
|
||||
try
|
||||
{
|
||||
var privateUser = await cacheUsers.GetPrivate(user.Id);
|
||||
await _userStore.Set(privateUser!.Id, privateUser);
|
||||
var privateUser = await cacheUsers.Get<PrivateUser>(user.Id);
|
||||
privateUser!.Password ??= privateUser.PasswordHash;
|
||||
|
||||
await _userStore.Set(privateUser!.Id, new InternalVoidUser()
|
||||
{
|
||||
Id = privateUser.Id,
|
||||
Avatar = privateUser.Avatar,
|
||||
Created = privateUser.Created,
|
||||
DisplayName = privateUser.DisplayName,
|
||||
Email = privateUser.Email,
|
||||
Flags = privateUser.Flags,
|
||||
LastLogin = privateUser.LastLogin,
|
||||
Password = privateUser.Password!,
|
||||
Roles = privateUser.Roles
|
||||
});
|
||||
_logger.LogInformation("Migrated user {USer}", user.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -115,4 +128,10 @@ public class MigrateToPostgres : IMigration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PrivateUser : PrivateVoidUser
|
||||
{
|
||||
public string? PasswordHash { get; set; }
|
||||
public string? Password { get; set; }
|
||||
}
|
||||
}
|
@ -32,13 +32,14 @@ public class PostgresUserStore : IUserStore
|
||||
await using var conn = await _connection.Get();
|
||||
await conn.ExecuteAsync(
|
||||
@"insert into
|
||||
""Users""(""Id"", ""Email"", ""Password"", ""LastLogin"", ""DisplayName"", ""Avatar"", ""Flags"")
|
||||
values(:id, :email, :password, :lastLogin, :displayName, :avatar, :flags)",
|
||||
""Users""(""Id"", ""Email"", ""Password"", ""Created"", ""LastLogin"", ""DisplayName"", ""Avatar"", ""Flags"")
|
||||
values(:id, :email, :password, :created, :lastLogin, :displayName, :avatar, :flags)",
|
||||
new
|
||||
{
|
||||
Id = id,
|
||||
email = obj.Email,
|
||||
password = obj.Password,
|
||||
created = obj.Created,
|
||||
displayName = obj.DisplayName,
|
||||
lastLogin = obj.LastLogin.ToUniversalTime(),
|
||||
avatar = obj.Avatar,
|
||||
|
Loading…
x
Reference in New Issue
Block a user