57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { pgTable, serial, text, jsonb, varchar, timestamp, unique, uuid, doublePrecision, json, integer, boolean, index, uniqueIndex, pgEnum } from "drizzle-orm/pg-core"
|
||
import { desc, sql, sum } from "drizzle-orm"
|
||
|
||
export const shortLink = pgTable("n_code_short_link", {
|
||
id: uuid().primaryKey().defaultRandom(),
|
||
// 对外暴露的唯一业务 ID,nanoid 生成
|
||
slug: text("slug").notNull(),
|
||
// 协作码,管理员才能编辑, 6-12 位随机字符串,唯一
|
||
code: text("code").notNull().default(''),
|
||
// 码的类型,link, agent,默认值为 link
|
||
type: text("type").notNull().default("link"),
|
||
version: text("version").notNull().default('1.0.0'),
|
||
|
||
title: text("title").notNull().default(''),
|
||
description: text("description").notNull().default(''),
|
||
tags: jsonb().default([]),
|
||
data: jsonb().default({}),
|
||
|
||
userId: uuid(),
|
||
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
||
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
|
||
|
||
}, (table) => [
|
||
uniqueIndex("n_code_short_idx_slug").on(table.slug),
|
||
uniqueIndex("n_code_short_idx_code").on(table.code)
|
||
]);
|
||
|
||
export const n5Make = pgTable("n_code_make", {
|
||
id: uuid().primaryKey().defaultRandom(),
|
||
slug: text("slug").notNull(),
|
||
resources: jsonb().default([]),
|
||
|
||
userId: uuid(),
|
||
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
||
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
|
||
}, (table) => [
|
||
uniqueIndex("n_code_make_idx_slug").on(table.slug),
|
||
]);
|
||
|
||
export const n5Shop = pgTable("n_code_shop", {
|
||
id: uuid().primaryKey().defaultRandom(),
|
||
slug: text("slug").notNull(),
|
||
title: text("title").notNull(), // 商品标题
|
||
tags: jsonb(), // 商品标签
|
||
link: text("link"), // 商品链接
|
||
description: text("description").notNull().default(''), // 商品描述
|
||
data: jsonb(), // 其他商品发货信息等
|
||
platform: text("platform").notNull(), // 商品平台,如 "淘宝", "抖音", "小红书" 等
|
||
userinfo: text("userinfo"), // 卖家信息,如 "店铺名称", "联系方式" 等
|
||
orderLink: text("orderLink").notNull(), // 订单链接
|
||
|
||
userId: uuid(),
|
||
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
||
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
|
||
}, (table) => [
|
||
uniqueIndex("n_code_shop_idx_slug").on(table.slug),
|
||
]); |