refactor(metadata): rename field_id to field_key in AssetMetadataValue

Rename the database column from field_id to field_key and the Prisma
property from fieldId to fieldKey to better reflect that the column
stores human-readable metadata field keys, not internal database IDs.

This fixes a bug where AI autofill wrote internal DB IDs instead of
field keys, causing metadata values to not display in the UI.

- Add SQL migration to rename the column
- Update metadata, search, and asset services
- Fix agent-autofill workflow to map fields by key
- Update all related test suites
This commit is contained in:
yiling
2026-05-28 12:38:07 +08:00
parent 5d5d631922
commit 89916a2950
15 changed files with 597 additions and 881 deletions
+2 -2
View File
@@ -330,7 +330,7 @@ describe('ProjectService', () => {
await prisma.assetMetadataValue.create({
data: {
assetId: fileC.id,
fieldId: 'test-field',
fieldKey: 'test-field',
stringValue: 'test-value',
},
})
@@ -370,7 +370,7 @@ describe('ProjectService', () => {
expect(
await prisma.assetMetadataValue.findUnique({
// eslint-disable-next-line @typescript-eslint/naming-convention
where: { assetId_fieldId: { assetId: fileC.id, fieldId: 'test-field' } },
where: { assetId_fieldKey: { assetId: fileC.id, fieldKey: 'test-field' } },
}),
).toBeNull()
expect(await prisma.assetComment.findUnique({ where: { id: comment.id } })).toBeNull()