fix(asset-library): 素材库 - 支持自定义分类、分页、完整预览和批量上传
This commit is contained in:
@@ -10,13 +10,14 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const CurrentSchemaVersion int64 = 5
|
||||
const CurrentSchemaVersion int64 = 6
|
||||
|
||||
const baselineSchemaChecksum = "sha256:open-ai-canvas-schema-v1-20260830"
|
||||
const schemaMigrationAppliedAtIndexChecksum = "sha256:schema-migrations-applied-at-index-v2-20260830"
|
||||
const assetTaxonomyCandidateIdentityChecksum = "sha256:asset-taxonomy-candidate-identity-v3-20260831-r1"
|
||||
const resourceUploadKeyChecksum = "sha256:resource-upload-key-v4-20260901"
|
||||
const paymentTopupChecksum = "sha256:payment-topup-v5-20260902"
|
||||
const assetLibraryFoldersChecksum = "sha256:asset-library-folders-v6-20260902"
|
||||
|
||||
const postgresSchemaMigrationLockID int64 = 73123910420260830
|
||||
|
||||
@@ -48,6 +49,7 @@ var schemaMigrations = []migration{
|
||||
{version: 3, name: "asset_taxonomy_candidate_identity", checksum: assetTaxonomyCandidateIdentityChecksum, apply: migrateSchemaV3},
|
||||
{version: 4, name: "resource_upload_key", checksum: resourceUploadKeyChecksum, apply: migrateSchemaV4},
|
||||
{version: 5, name: "payment_topup", checksum: paymentTopupChecksum, apply: migrateSchemaV5},
|
||||
{version: 6, name: "asset_library_folders", checksum: assetLibraryFoldersChecksum, apply: migrateSchemaV6},
|
||||
}
|
||||
|
||||
func migrateSchemaV2(tx *gorm.DB) error {
|
||||
@@ -123,6 +125,13 @@ func migrateSchemaV5(tx *gorm.DB) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func migrateSchemaV6(tx *gorm.DB) error {
|
||||
if err := tx.AutoMigrate(&model.Asset{}, &model.AssetFolder{}); err != nil {
|
||||
return fmt.Errorf("创建个人素材分类并扩展素材目录字段:%w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func MigrateSchema(db *gorm.DB) error {
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Dialector.Name() == "postgres" {
|
||||
|
||||
@@ -59,6 +59,7 @@ func Models() []any {
|
||||
&model.ResourceDeletionJob{},
|
||||
&model.AnnouncementImageDraft{},
|
||||
&model.Asset{},
|
||||
&model.AssetFolder{},
|
||||
&model.ProjectAssetLink{},
|
||||
&model.ProjectAssetFolder{},
|
||||
&model.ProjectAssetCandidate{},
|
||||
|
||||
Reference in New Issue
Block a user