update
This commit is contained in:
@ -118,9 +118,14 @@ source varchar(32) not null default ''
|
||||
source_url varchar(512) not null default ''
|
||||
```
|
||||
|
||||
对应模型:`internal/model/runway_draft.go` 的 `BrandRunwayDraft`、`internal/model/street_snap_draft.go` 的 `StreetSnapDraft`。列由 `AutoMigrate` 托管,**模型上不加 `uniqueIndex` tag**(GORM tag 无法表达部分索引条件)。
|
||||
对应模型:`internal/model/runway_draft.go` 的 `BrandRunwayDraft`、`internal/model/street_snap_draft.go` 的 `StreetSnapDraft`。**模型上不加 `uniqueIndex` tag**(GORM tag 无法表达部分索引条件)。
|
||||
|
||||
索引写在 `internal/database/postgres.go` 的 `EnsureDedupSchema` 中——该函数本就是「`AutoMigrate` 之外的索引补充」的既定位置,且全部 `IF NOT EXISTS` 幂等:
|
||||
> **落点已变更(2026-09-21)**:服务启动时的自动迁移(`AutoMigrate` / `EnsureDedupSchema`)已移除,
|
||||
> 全库结构改由 `cmd/dbtool` 的 dump 维护。加列 / 加索引现在走 `db/migrations/` 下的一次性脚本:
|
||||
> 对开发库执行 → 再 `dbtool dump -clean` 重新导出。本规格的列与索引已落在
|
||||
> `db/migrations/2026-09-21-03-ingest-source-idempotency.sql`(已应用)。
|
||||
|
||||
索引定义(部分唯一索引——全量唯一索引会因存量大量 `('','')` 冲突而建索引失败):
|
||||
|
||||
```sql
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_br_draft_source
|
||||
|
||||
Reference in New Issue
Block a user