drizzle-database
仓库创建 2024年12月9日最近提交 6 小时前SkillHot 收录 5 小时前
▸ 精选理由
说明表定义与迁移惯例,便于安全改库与新增关系。
▸ 风险提示
运行迁移或修改 schema 有数据丢失风险
这个 Skill 做什么
在 ChatbotX 中使用 Drizzle ORM 定义表结构、编写迁移与查询。
在 ChatbotX 用 Drizzle ORM 定义 PostgreSQL 表、写迁移、建关联和查询,统一用 pgTable 和 sharedColumns 管理 id、createdAt 等字段。创建表、改 schema、写 migration 或写复杂查询时用,代码风格和迁移流程都有约定。优势是和项目约定的模板一致,减少手写 SQL 的重复工作并利于类型安全。
▸ 展开 SKILL.md 英文原文
Work with Drizzle ORM database schema, migrations, relations, and queries in PostgreSQL. Use when creating tables, modifying schema, writing migrations, defining relations, or querying the database.
524
Stars
116
Forks
21
仓库内 Skill
积累中
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/ChatbotXIO/ChatbotX/main/.agents/skills/drizzle-database/SKILL.md或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/ChatbotXIO/ChatbotX/main/.agents/skills/drizzle-database/SKILL.md"SKILL.MD 节选查看完整文件 ↗
# Drizzle Database
Package: `packages/database` (`@chatbotx.io/database`)
## Table Definition
Tables use `pgTable` with `sharedColumns` spread for consistent `id`, `createdAt`, `updatedAt`:
```typescript
import { pgTable, text, index, uniqueIndex } from "drizzle-orm/pg-core"
import { sharedColumns, bigintAsString, timestampConfig } from "../partials/shared"
import { otherModel } from "./other"
export const myModel = pgTable(
"MyModel",
{
...sharedColumns,
name: text().notNull(),
description: text(),
workspaceId: bigintAsString()
.notNull()
.references(() => workspaceModel.id, {
onDelete: "cascade",
onUpdate: "cascade",
}),
},
(tavia SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有