using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
namespace Iceshrimp.Backend.Core.Database.Tables;
[Table("session")]
[Index(nameof(Token))]
public class Session
{
[Key]
[Column("id")]
[StringLength(32)]
public string Id { get; set; } = null!;
///
/// The created date of the OAuth token
///
[Column("createdAt")]
public DateTime CreatedAt { get; set; }
[Column("userId")] [StringLength(32)] public string UserId { get; set; } = null!;
///
/// The authorization token
///
[Column("token")]
[StringLength(64)]
public string Token { get; set; } = null!;
///
/// Whether or not the token has been activated (i.e. 2fa has been confirmed)
///
[Column("active")]
public bool Active { get; set; }
[ForeignKey(nameof(UserId))]
[InverseProperty(nameof(Tables.User.Sessions))]
public virtual User User { get; set; } = null!;
[Column("lastActiveDate")] public DateTime? LastActiveDate { get; set; }
}