//! License key and activation models. use chrono::{DateTime, Utc}; use serde::Serialize; use sqlx::FromRow; use super::super::id_types::*; use super::super::validated_types::*; /// A license key issued to a buyer for software activation. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbLicenseKey { /// Database primary key. pub id: LicenseKeyId, /// Item this key grants access to. pub item_id: ItemId, /// User who owns this key. pub owner_id: UserId, /// Transaction that generated this key (if any). pub transaction_id: Option, /// The key code (word-word-word-word-word format). pub key_code: KeyCode, /// Maximum allowed activations (NULL = unlimited). pub max_activations: Option, /// Current number of active activations. pub activation_count: i32, /// When the key was revoked (None = active). pub revoked_at: Option>, /// When the key was created. pub created_at: DateTime, } /// A machine activation for a license key. #[derive(Debug, Clone, FromRow, Serialize)] pub struct DbLicenseActivation { /// Database primary key. pub id: LicenseActivationId, /// License key this activation belongs to. pub license_key_id: LicenseKeyId, /// Opaque machine identifier from calling software. pub machine_id: String, /// Optional friendly name for this machine. pub label: Option, /// When this activation was created. pub activated_at: DateTime, /// When this activation was last validated. pub last_validated_at: DateTime, /// Whether this activation is currently active. pub is_active: bool, }