feat(key-pool): add LRU sorting via last_used_at column

- Add migration to add last_used_at TIMESTAMPTZ column to provider_keys
- Update select_best_key() SQL to sort by last_used_at ASC NULLS FIRST
- Update record_key_usage() to set last_used_at = NOW() on each use
- Bump SCHEMA_VERSION to 10
This commit is contained in:
iven
2026-03-31 10:14:49 +08:00
parent 1d9283f335
commit 8e6abc91e1
3 changed files with 11 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ use sqlx::postgres::PgPoolOptions;
use sqlx::PgPool;
use crate::error::SaasResult;
const SCHEMA_VERSION: i32 = 9;
const SCHEMA_VERSION: i32 = 10;
/// 初始化数据库
pub async fn init_db(database_url: &str) -> SaasResult<PgPool> {