一键导入
persistence
SQLite persistence layer reference for PhotoManager. Use this skill when working on database code, repositories, backup service, or schema changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
SQLite persistence layer reference for PhotoManager. Use this skill when working on database code, repositories, backup service, or schema changes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add or modify tests following project conventions. Use when asked to write tests, add test coverage, or fix failing tests.
Add or modify tests for PhotoManager following project conventions. Use this skill when asked to write tests, add test coverage, or fix failing tests.
Avalonia UI reference guide for PhotoManager: UI conventions, MVVM patterns, and cross-platform UI patterns. Use this skill when working on UI code, adding image-processing methods, or needing to understand the Avalonia UI layer of the application.
Refactor code following Clean Architecture patterns. Use when asked to restructure, extract, move, or reorganize code while preserving behavior.
Avalonia UI reference guide for PhotoManager: UI conventions, MVVM patterns, and cross-platform UI patterns. Use this skill when working on UI code, adding image-processing methods, or needing to understand the Avalonia UI layer of the application.
Refactor PhotoManager code following Clean Architecture patterns. Use this skill when asked to restructure, extract, move, or reorganize code while preserving behavior.
| name | persistence |
| description | SQLite persistence layer reference for PhotoManager. Use this skill when working on database code, repositories, backup service, or schema changes. |
You are working on the PhotoManager persistence layer.
Use the facts below as your authoritative reference.
PhotoManager.Persistence/
├── IPersistenceContext.cs # High-level facade (Initialize, WriteBackup, DeleteOldBackups, Dispose)
├── PersistenceDiagnostics.cs # Last-operation diagnostics
├── PersistenceServiceCollectionExtensions.cs # AddPersistence()
├── Sqlite/
│ ├── ISqliteConnectionFactory.cs / SqliteConnectionFactory.cs # PRAGMAs on every open
│ ├── SqliteSchema.cs # DDL + PRAGMA user_version
│ ├── ISqliteBackupService.cs / SqliteBackupService.cs # Online backup + zip
│ └── SqlitePersistenceContext.cs # IPersistenceContext implementation
├── Repositories/
│ ├── IFolderPersistence.cs / FolderPersistence.cs
│ ├── IAssetPersistence.cs / AssetPersistence.cs
│ ├── IThumbnailPersistence.cs / ThumbnailPersistence.cs
│ ├── IRecentPathsPersistence.cs / RecentPathsPersistence.cs
│ └── ISyncDefinitionsPersistence.cs / SyncDefinitionsPersistence.cs
├── Cache/
│ ├── ILruCache.cs
│ └── LruCache.cs # Thread-safe LRU cache
└── GlobalUsings.cs
All concrete classes in Sqlite/ and Repositories/ are internal sealed.
Defined in SqliteSchema.cs:
| Table | Primary key | Notes |
|---|---|---|
Folders | Id (TEXT, GUID) | Index on Path |
Assets | (FolderId, FileName) | Index on Hash. FK → Folders(Id) |
Thumbnails | (FolderId, FileName) | Data BLOB. FK → Folders(Id) |
RecentPaths | Position (INTEGER) | Single ordered list |
SyncDefinitions | Position (INTEGER) | Single ordered list |
SqliteConnectionFactory.Open() applies PRAGMAs on every connection:
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA busy_timeout = 5000;
PRAGMA temp_store = MEMORY;
PRAGMA foreign_keys = ON;
SqliteTransaction with pre-bound parameters for efficiencyWriteBackup(backupFilePath): uses SQLite online-backup API → snapshot .tmp.db → zip → cleanupyyyyMMdd.zip containing photomanager.dbGetBackupFilesPaths(backupDirectory): returns sorted .zip file pathsDeleteBackupFile(backupFilePath): deletes a single backup archive// PersistenceServiceCollectionExtensions.cs
services.AddSingleton<ISqliteConnectionFactory, SqliteConnectionFactory>();
services.AddSingleton<ISqliteBackupService, SqliteBackupService>();
services.AddSingleton<IPersistenceContext, SqlitePersistenceContext>();
Called from InfrastructureServiceCollectionExtensions.AddInfrastructure().
SqliteConnection.ClearAllPools() + TearDownHelper.DeleteTempDbDirectories() in TearDownISqliteConnectionFactory / ISqliteBackupServicePhotoManager.Tests.Integration.Constantsdotnet test --filter "FullyQualifiedName~Persistence" PhotoManager/PhotoManager.slnxSqliteSchema.CREATE_SCRIPT in SqliteSchema.csSCHEMA_VERSION and add migration logic in EnsureCreated()I{Table}Persistence.cs interface and {Table}Persistence.cs implementation in Repositories/PersistenceServiceCollectionExtensions.csPhotoManager.Tests/Integration/Persistence/Repositories/