A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix 'Failed to create user' error by correcting last_repo column name and SQL queries

- Add last_repo column to users table schema in migration
- Fix CreateUser query to include last_repo value in INSERT
- Fix GetUserByGithubID and GetUserByID to scan last_repo field
- Fix UpdateUserRepo to use last_repo instead of lastRepo
- Standardize all SQL queries to use snake_case (last_repo) consistently

+10 -7
+1
backend/internal/database/migrations/001_initial.sql
··· 5 5 username TEXT NOT NULL, 6 6 email TEXT, 7 7 avatar_url TEXT, 8 + last_repo TEXT, 8 9 created_at DATETIME DEFAULT CURRENT_TIMESTAMP, 9 10 updated_at DATETIME DEFAULT CURRENT_TIMESTAMP 10 11 );
+9 -7
backend/internal/database/queries.go
··· 9 9 // CreateUser creates a new user or updates if exists 10 10 func (db *DB) CreateUser(user *User) error { 11 11 query := ` 12 - INSERT INTO users (github_id, username, email, avatar_url, lastRepo, updated_at) 13 - VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP) 12 + INSERT INTO users (github_id, username, email, avatar_url, last_repo, updated_at) 13 + VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP) 14 14 ON CONFLICT(github_id) DO UPDATE SET 15 15 username = excluded.username, 16 16 email = excluded.email, 17 17 avatar_url = excluded.avatar_url, 18 - lastRepo = excluded.lastRepo, 18 + last_repo = excluded.last_repo, 19 19 updated_at = CURRENT_TIMESTAMP 20 20 RETURNING id, created_at, updated_at 21 21 ` 22 22 23 - return db.QueryRow(query, user.GithubID, user.Username, user.Email, user.AvatarURL). 23 + return db.QueryRow(query, user.GithubID, user.Username, user.Email, user.AvatarURL, user.LastRepo). 24 24 Scan(&user.ID, &user.CreatedAt, &user.UpdatedAt) 25 25 } 26 26 ··· 28 28 func (db *DB) GetUserByGithubID(githubID int) (*User, error) { 29 29 user := &User{} 30 30 query := ` 31 - SELECT id, github_id, username, email, avatar_url, lastRepo, created_at, updated_at 31 + SELECT id, github_id, username, email, avatar_url, last_repo, created_at, updated_at 32 32 FROM users 33 33 WHERE github_id = ? 34 34 ` ··· 39 39 &user.Username, 40 40 &user.Email, 41 41 &user.AvatarURL, 42 + &user.LastRepo, 42 43 &user.CreatedAt, 43 44 &user.UpdatedAt, 44 45 ) ··· 57 58 func (db *DB) GetUserByID(id int) (*User, error) { 58 59 user := &User{} 59 60 query := ` 60 - SELECT id, github_id, username, email, avatar_url, lastRepo, created_at, updated_at 61 + SELECT id, github_id, username, email, avatar_url, last_repo, created_at, updated_at 61 62 FROM users 62 63 WHERE id = ? 63 64 ` ··· 68 69 &user.Username, 69 70 &user.Email, 70 71 &user.AvatarURL, 72 + &user.LastRepo, 71 73 &user.CreatedAt, 72 74 &user.UpdatedAt, 73 75 ) ··· 260 262 func (db *DB) UpdateUserRepo(userID int, lastRepo string) error { 261 263 query := ` 262 264 UPDATE users 263 - SET lastRepo = ?, updated_at = CURRENT_TIMESTAMP 265 + SET last_repo = ?, updated_at = CURRENT_TIMESTAMP 264 266 WHERE id = ? 265 267 ` 266 268