From d9521fc59b46748dea21df10f719ea1370c8ce4c Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Sat, 17 May 2025 16:08:05 +0200 Subject: [PATCH] Change db format a little --- backend/db.go | 2 +- backend/migrations/1_initial.sql | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/db.go b/backend/db.go index e171cdf..78f41f8 100644 --- a/backend/db.go +++ b/backend/db.go @@ -114,7 +114,7 @@ func (db *Db) CreateAllowance(userId int, allowance *CreateAllowanceRequest) (in defer tx.MustRollback() // Insert the new allowance - err = tx.Query("insert into allowances (user_id, name, target, progress, weight) values (?, ?, ?, 0, ?)"). + err = tx.Query("insert into allowances (user_id, name, target, weight) values (?, ?, ?, ?)"). Bind(userId, allowance.Name, allowance.Target, allowance.Weight). Exec() diff --git a/backend/migrations/1_initial.sql b/backend/migrations/1_initial.sql index cb7a4ce..abf29fe 100644 --- a/backend/migrations/1_initial.sql +++ b/backend/migrations/1_initial.sql @@ -1,7 +1,9 @@ create table users ( id integer primary key, - name text not null + name text not null, + weight real not null default 1.0, + balance integer not null default 0 ) strict; create table history @@ -18,7 +20,7 @@ create table allowances user_id integer not null, name text not null, target integer not null, - progress integer not null, + progress integer not null default 0, weight real not null );