Add data migration export/import endpoints
All checks were successful
Backend Build and Test / build (push) Successful in 40s
All checks were successful
Backend Build and Test / build (push) Successful in 40s
Add GET /api/export to the Go backend that dumps all users, allowances, history, and tasks (including completed) as a single JSON snapshot. Add POST /api/import to the Spring backend that accepts the same JSON, wipes existing data, inserts all records with original IDs preserved via native SQL, and resets PostgreSQL sequences to avoid future collisions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -86,3 +86,45 @@ type TransferRequest struct {
|
||||
To int `json:"to"`
|
||||
Amount float64 `json:"amount"`
|
||||
}
|
||||
|
||||
type ExportUser struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Balance int64 `json:"balance"`
|
||||
Weight float64 `json:"weight"`
|
||||
}
|
||||
|
||||
type ExportAllowance struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"userId"`
|
||||
Name string `json:"name"`
|
||||
Target int64 `json:"target"`
|
||||
Balance int64 `json:"balance"`
|
||||
Weight float64 `json:"weight"`
|
||||
Colour *int `json:"colour"`
|
||||
}
|
||||
|
||||
type ExportHistory struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"userId"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Amount int64 `json:"amount"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type ExportTask struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Reward int64 `json:"reward"`
|
||||
Assigned *int `json:"assigned"`
|
||||
Schedule *string `json:"schedule"`
|
||||
Completed *int64 `json:"completed"`
|
||||
NextRun *int64 `json:"nextRun"`
|
||||
}
|
||||
|
||||
type ExportData struct {
|
||||
Users []ExportUser `json:"users"`
|
||||
Allowances []ExportAllowance `json:"allowances"`
|
||||
History []ExportHistory `json:"history"`
|
||||
Tasks []ExportTask `json:"tasks"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user