feat(db): add file storage metadata columns #128
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add storage metadata columns to the
item_filestable to support dual-running MinIO and filesystem backends during migration.Context
The existing
item_filestable (migration011_item_files.sql) stores:The
object_keycolumn stores the MinIO key (e.g.items/{itemID}/files/{uuid}/{filename}). For the filesystem backend, we need to track which backend each file uses and the filesystem path.Additionally, the
revisionstable stores file metadata in columnsfile_key,file_version,file_checksum,file_size— these also need astorage_backendindicator.Requirements
Migration
017_file_storage_metadata.sqlWhy these columns
storage_backendonitem_files: During migration, existing rows stay'minio'while new uploads write'filesystem'. The application reads this to know which backend to use for downloads/deletes.file_storage_backendonrevisions: Same dual-running support for revision files (uploaded viaPOST /api/items/{partNumber}/file).What we do NOT need
storage_pathcolumn: The existingobject_key/file_keycolumns already serve this purpose — the filesystem backend uses the same key as a relative path under its root directory.content_typeonitem_files: Already exists.file_sizeonitem_files: Already exists assize.DB repository changes
Update
internal/db/item_files.go:ItemFilestruct: addStorageBackend stringfieldCreate(): accept and insertstorage_backendListByItem()andGet(): includestorage_backendin SELECTUpdate
internal/db/revisions.go(or whereverRevisionis defined):Revisionstruct: addFileStorageBackend stringfieldAcceptance criteria
'minio'— no data lossItemFileandRevisionstructs updated with backend fieldgo build ./...passesPriority
P0 — blocks data migration and dual-running
Part of
Storage Migration: MinIO → PostgreSQL + Filesystem