mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-02-15 15:23:24 +08:00
- Revised the README files for shared data and main data layers to improve clarity and structure. - Consolidated documentation on shared data types and API types, removing the now-deleted `api-design-guidelines.md`. - Streamlined directory structure descriptions and updated links to relevant documentation. - Enhanced quick reference sections for better usability and understanding of the data architecture. |
||
|---|---|---|
| .. | ||
| schemas | ||
| seeding | ||
| DbService.ts | ||
| README.md | ||
| types.d.ts | ||
Database Layer
This directory contains database schemas and configuration.
Documentation
- Database Patterns: docs/en/references/data/database-patterns.md
Directory Structure
src/main/data/db/
├── schemas/ # Drizzle table definitions
│ ├── columnHelpers.ts # Reusable column definitions
│ ├── topic.ts # Topic table
│ ├── message.ts # Message table
│ └── ... # Other tables
├── seeding/ # Database initialization
└── DbService.ts # Database connection management
Quick Reference
Naming Conventions
- Table names: Singular snake_case (
topic,message,app_state) - Export names:
xxxTablepattern (topicTable,messageTable)
Common Commands
# Generate migrations after schema changes
yarn db:migrations:generate
Column Helpers
import { uuidPrimaryKey, createUpdateTimestamps } from './columnHelpers'
export const myTable = sqliteTable('my_table', {
id: uuidPrimaryKey(),
name: text(),
...createUpdateTimestamps
})