feat(db): 0000 站点域——sites/site_config_revisions + 唯一约束
drizzle-kit 首个迁移从 0000 起编号(计划文案写 0001,以实际产出为准)。 迁移文件 + meta/_journal.json + snapshot 一并入库。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -1,2 +1,21 @@
|
||||
// 聚合导出:后续任务(6-12)按域追加 pgTable 定义
|
||||
export {}
|
||||
// 聚合导出:Task 6 起按域追加 pgTable 定义(迁移 0001——站点域)
|
||||
import { pgTable, uuid, text, integer, jsonb, timestamp, uniqueIndex } from 'drizzle-orm/pg-core'
|
||||
|
||||
export const sites = pgTable('sites', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
key: text('key').notNull().unique(),
|
||||
name: text('name').notNull(),
|
||||
defaultLocale: text('default_locale').notNull(),
|
||||
productionOrigin: text('production_origin').notNull(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const siteConfigRevisions = pgTable('site_config_revisions', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
siteId: uuid('site_id').notNull().references(() => sites.id),
|
||||
version: integer('version').notNull(),
|
||||
data: jsonb('data').notNull(),
|
||||
checksum: text('checksum').notNull(),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
}, (t) => [uniqueIndex('site_config_rev_uq').on(t.siteId, t.version)])
|
||||
|
||||
Reference in New Issue
Block a user