tmain.go: add foreign key to cpt table - ags-upload - Insert AGS files to a database
HTML git clone git://src.adamsgaard.dk/ags-upload
DIR Log
DIR Files
DIR Refs
---
DIR commit 52ae372551aa77ef8cff17830e9ad996f6876516
DIR parent 2ac532c6bc6353cf8fb2512a15c2e3d3a5d56022
HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 8 Oct 2025 11:45:02 +0200
main.go: add foreign key to cpt table
Diffstat:
M cmd/main.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
DIR diff --git a/cmd/main.go b/cmd/main.go
t@@ -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])
t@@ -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