Skip to content

Commit 51b4ae3

Browse files
committed
db: add autoincrement to auth_user primary key
The auth_user table was missing the autoincrement tag on its primary key. Without it, inserting a user without an explicit ID would fail or reuse a deleted rowid, which is not the intended behavior. Signed-off-by: Robin Jarry <robin@jarry.cc>
1 parent e644843 commit 51b4ae3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎pkg/db/migrations/0001_initial_schema.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func init() {
2323

2424
type user0001 struct {
2525
bun.BaseModel `bun:"table:auth_user"`
26-
ID int `bun:"id,pk"`
26+
ID int `bun:"id,pk,autoincrement"`
2727
Username string `bun:"username,notnull"`
2828
Password string `bun:"password,notnull"`
2929
FirstName string `bun:"first_name,notnull"`

‎pkg/db/models.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type User struct {
1616
bun.BaseModel `bun:"table:auth_user" json:"-"`
1717

18-
ID int `bun:"id,pk" json:"id"`
18+
ID int `bun:"id,pk,autoincrement" json:"id"`
1919
Username string `bun:"username,notnull" json:"username"`
2020
Password string `bun:"password,notnull" json:"-"`
2121
FirstName string `bun:"first_name,notnull" json:"first_name"`

0 commit comments

Comments
 (0)