ags-upload

Insert AGS files to a database
git clone git://src.adamsgaard.dk/ags-upload # fast
git clone https://src.adamsgaard.dk/ags-upload.git # slow
Log | Files | Refs Back to index

commit 52ae372551aa77ef8cff17830e9ad996f6876516
parent 2ac532c6bc6353cf8fb2512a15c2e3d3a5d56022
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed,  8 Oct 2025 11:45:02 +0200

main.go: add foreign key to cpt table

Diffstat:
Mcmd/main.go | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/main.go b/cmd/main.go @@ -92,7 +92,6 @@ func ParseAGSProjectAndSCPT(r io.Reader) (*CptInfo, []Cpt, error) { } for i := range rec { rec[i] = strings.TrimSpace(rec[i]) - // Some exporters put empty quotes => "" — leave as empty string } tag := strings.ToUpper(rec[0]) @@ -230,10 +229,11 @@ func main() { } } - // If you later derive InfoId from a SC* info table, set it here before insert. if len(cpts) > 0 { // Optional: add a foreign key to project if you want (e.g., ProjectID) - // for i := range cpts { cpts[i].ProjectID = proj.ID } + for i := range cpts { + cpts[i].InfoId = proj.ID + } if err := tx.CreateInBatches(cpts, 2000).Error; err != nil { return err