2025-03-03 00:56:32 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-04-27 22:36:16 +02:00
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
2025-03-03 00:56:32 +01:00
|
|
|
using WatchIt.Database.Model.Accounts;
|
2024-04-27 22:36:16 +02:00
|
|
|
|
2025-03-03 00:56:32 +01:00
|
|
|
namespace WatchIt.Database.Configuration.Accounts;
|
2024-04-27 22:36:16 +02:00
|
|
|
|
|
|
|
|
public class AccountRefreshTokenConfiguration : IEntityTypeConfiguration<AccountRefreshToken>
|
|
|
|
|
{
|
2025-03-03 00:56:32 +01:00
|
|
|
#region PUBLIC METHODS
|
|
|
|
|
|
2024-04-27 22:36:16 +02:00
|
|
|
public void Configure(EntityTypeBuilder<AccountRefreshToken> builder)
|
|
|
|
|
{
|
2025-03-03 00:56:32 +01:00
|
|
|
builder.ToTable("AccountRefreshTokens", "accounts");
|
|
|
|
|
|
|
|
|
|
// Id
|
|
|
|
|
builder.HasKey(x => x.Token);
|
|
|
|
|
builder.HasIndex(x => x.Token)
|
2024-04-27 22:36:16 +02:00
|
|
|
.IsUnique();
|
2025-03-03 00:56:32 +01:00
|
|
|
builder.Property(x => x.Token)
|
2024-04-27 22:36:16 +02:00
|
|
|
.IsRequired();
|
2025-03-03 00:56:32 +01:00
|
|
|
|
|
|
|
|
// Account
|
2024-04-27 22:36:16 +02:00
|
|
|
builder.HasOne(x => x.Account)
|
2025-03-03 00:56:32 +01:00
|
|
|
.WithMany(x => x.RefreshTokens)
|
2024-04-27 22:36:16 +02:00
|
|
|
.HasForeignKey(x => x.AccountId)
|
|
|
|
|
.IsRequired();
|
|
|
|
|
builder.Property(x => x.AccountId)
|
|
|
|
|
.IsRequired();
|
2025-03-03 00:56:32 +01:00
|
|
|
|
|
|
|
|
// Expiration date
|
2024-04-27 22:36:16 +02:00
|
|
|
builder.Property(x => x.ExpirationDate)
|
|
|
|
|
.IsRequired();
|
2025-03-03 00:56:32 +01:00
|
|
|
|
|
|
|
|
// Is extendable
|
2024-04-27 22:36:16 +02:00
|
|
|
builder.Property(x => x.IsExtendable)
|
|
|
|
|
.IsRequired();
|
2025-03-03 00:56:32 +01:00
|
|
|
|
|
|
|
|
// Version
|
|
|
|
|
builder.Property(b => b.Version)
|
|
|
|
|
.IsRowVersion();
|
2024-04-27 22:36:16 +02:00
|
|
|
}
|
2025-03-03 00:56:32 +01:00
|
|
|
|
|
|
|
|
#endregion
|
2024-04-27 22:36:16 +02:00
|
|
|
}
|