cherry-studio/src/main/data/db
fullex 819c209821 docs(data): update README and remove outdated API design guidelines
- 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.
2025-12-29 17:15:06 +08:00
..
schemas feat(api): enhance message deletion functionality with activeNodeId management 2025-12-29 13:42:05 +08:00
seeding feat: CacheService & useCache Hooks 2025-09-15 14:12:41 +08:00
DbService.ts feat: initialize database in app startup and enhance DbService 2025-11-21 23:46:51 +08:00
README.md docs(data): update README and remove outdated API design guidelines 2025-12-29 17:15:06 +08:00
types.d.ts mv dir to data 2025-08-09 14:30:24 +08:00

Database Layer

This directory contains database schemas and configuration.

Documentation

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: xxxTable pattern (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
})