finish setup insert method, refactor sql migration file

This commit is contained in:
lbenedar
2026-04-17 17:33:21 +03:00
parent 1b7c7e9ae3
commit 21abe68858
47 changed files with 2054 additions and 1056 deletions

View File

@@ -22,27 +22,32 @@ type Pack struct {
// SystemPacksFlags SystemPacksFlags `json:"flags"`
}
func (p *Pack) ToDB(dest *db.Pack) bool {
func (p *Pack) ToDB(dest **db.Pack) bool {
if dest == nil {
return false
}
dest.Name = p.Name
dest.Label = p.Label
dest.Banner = p.Banner
dest.Path = p.Path
dest.Type = p.Type
dest.System = p.System
p.Ownership.ToDB(&dest.Ownership)
dest.PackageType = p.PackageType
dest.PackageName = p.PackageName
dest.ID = p.Id
pack := &db.Pack{
Name: p.Name,
Label: p.Label,
Banner: p.Banner,
Path: p.Path,
Type: p.Type,
System: p.System,
PackageType: p.PackageType,
PackageName: p.PackageName,
ID: p.Id,
}
p.Ownership.ToDB(&pack.Ownership)
wg := sync.WaitGroup{}
go CopySliceToDBParallel(&wg, &dest.Index, p.Index)
go CopySliceToDBParallel(&wg, &dest.Folders, p.Folders)
go CopySliceToDBParallel(&wg, &pack.Index, p.Index)
go CopySliceToDBParallel(&wg, &pack.Folders, p.Folders)
wg.Wait()
*dest = pack
return true
}
@@ -58,17 +63,21 @@ type PackFolder struct {
// Packs0FoldersFlags any `json:"flags"`
}
func (p *PackFolder) ToDB(dest *db.PackFolder) bool {
func (p *PackFolder) ToDB(dest **db.PackFolder) bool {
if dest == nil {
return false
}
dest.ID = p.ID
dest.Description = p.Description
dest.Name = p.Name
dest.Sort = p.Sort
dest.Sorting = p.Sorting
dest.Type = p.Type
packFolder := &db.PackFolder{
ID: p.ID,
Description: p.Description,
Name: p.Name,
Sort: p.Sort,
Sorting: p.Sorting,
Type: p.Type,
}
*dest = packFolder
return true
}