mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-12 00:49:14 +08:00
- Added new section on schema file organization, detailing principles and decision criteria for merging or separating table files. - Updated file naming conventions for single and multi-table files, as well as helper utilities. - Refactored import paths in various schema files to use the new `_columnHelpers` module instead of the deprecated `columnHelpers`. - Removed obsolete `customSql.ts`, `columnHelpers.ts`, `messageFts.ts`, `tag.ts`, `entityTag.ts`, and other related files to streamline the codebase. This refactor improves clarity in database schema management and aligns file organization with best practices.
25 lines
744 B
TypeScript
25 lines
744 B
TypeScript
import { index, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
|
|
import { createUpdateTimestamps, uuidPrimaryKey } from './_columnHelpers'
|
|
|
|
/**
|
|
* Group table - general-purpose grouping for entities
|
|
*
|
|
* Supports grouping of topics, sessions, and assistants.
|
|
* Each group belongs to a specific entity type.
|
|
*/
|
|
export const groupTable = sqliteTable(
|
|
'group',
|
|
{
|
|
id: uuidPrimaryKey(),
|
|
// Entity type this group belongs to: topic, session, assistant
|
|
entityType: text().notNull(),
|
|
// Display name of the group
|
|
name: text().notNull(),
|
|
// Sort order for display
|
|
sortOrder: integer().default(0),
|
|
...createUpdateTimestamps
|
|
},
|
|
(t) => [index('group_entity_sort_idx').on(t.entityType, t.sortOrder)]
|
|
)
|