75 lines
3.0 KiB
TypeScript
75 lines
3.0 KiB
TypeScript
import { pgTable, serial, text, jsonb, varchar, timestamp, unique, uuid, doublePrecision, json, integer, boolean, index, uniqueIndex, pgEnum } from "drizzle-orm/pg-core"
|
|
import { sql, sum } from "drizzle-orm"
|
|
|
|
export const life = pgTable("flowme_life", {
|
|
id: uuid().primaryKey().notNull().defaultRandom(),
|
|
uid: uuid(),
|
|
|
|
title: text('title').default(''),
|
|
tags: jsonb().default([]),
|
|
summary: text('summary').default(''),
|
|
description: text('description').default(''),
|
|
link: text('link').default(''),
|
|
data: jsonb().default({}),
|
|
|
|
effectiveAt: text('effectiveAt').default(''),
|
|
type: text('type').default(''),
|
|
prompt: text('prompt').default(''),
|
|
taskType: text('taskType').default(''),
|
|
taskResult: jsonb('taskResult').default({}),
|
|
|
|
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
|
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
|
|
}, (table) => [
|
|
index('life_uid_idx').using('btree', table.uid.asc().nullsLast()),
|
|
index('life_title_idx').using('btree', table.title.asc().nullsLast()),
|
|
index('life_effective_at_idx').using('btree', table.effectiveAt.asc().nullsLast()),
|
|
index('life_summary_idx').using('btree', table.summary.asc().nullsLast()),
|
|
]);
|
|
|
|
export const flowme = pgTable("flowme", {
|
|
id: uuid().primaryKey().notNull().defaultRandom(),
|
|
uid: uuid(),
|
|
|
|
title: text('title').default(''),
|
|
tags: jsonb().default([]),
|
|
summary: text('summary').default(''),
|
|
description: text('description').default(''),
|
|
link: text('link').default(''),
|
|
data: jsonb().default({}),
|
|
|
|
channelId: uuid().references(() => flowmeChannels.id, { onDelete: 'set null' }),
|
|
type: text('type').default(''),
|
|
source: text('source').default(''),
|
|
importance: integer('importance').default(0), // 重要性等级
|
|
isArchived: boolean('isArchived').default(false), // 是否归档
|
|
|
|
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
|
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
|
|
|
|
}, (table) => [
|
|
index('flowme_uid_idx').using('btree', table.uid.asc().nullsLast()),
|
|
index('flowme_title_idx').using('btree', table.title.asc().nullsLast()),
|
|
index('flowme_channel_id_idx').using('btree', table.channelId.asc().nullsLast()),
|
|
]);
|
|
|
|
|
|
export const flowmeChannels = pgTable("flowme_channels", {
|
|
id: uuid().primaryKey().notNull().defaultRandom(),
|
|
uid: uuid(),
|
|
title: text('title').default(''),
|
|
tags: jsonb().default([]),
|
|
summary: text('summary').default(''),
|
|
description: text('description').default(''),
|
|
link: text('link').default(''),
|
|
data: jsonb().default({}),
|
|
|
|
key: text('key').default(''),
|
|
color: text('color').default('#007bff'),
|
|
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
|
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
|
|
}, (table) => [
|
|
index('flowme_channels_uid_idx').using('btree', table.uid.asc().nullsLast()),
|
|
index('flowme_channels_key_idx').using('btree', table.key.asc().nullsLast()),
|
|
index('flowme_channels_title_idx').using('btree', table.title.asc().nullsLast()),
|
|
]); |