use crate::{DateTimeUtc, UserId};
use sea_orm::JsonValue;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "user_token")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub user: UserId,
    pub name: String,
    pub token_hash: String,
    pub scopes: JsonValue,
    pub expires_at: Option<DateTimeUtc>,
    pub is_revoked: bool,
    pub created_at: DateTimeUtc,
    pub updated_at: DateTimeUtc,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
