Initial commit: runnable Ask a Plumber First server.

This commit is contained in:
2026-08-21 23:30:15 -07:00
parent 7bc79af954
commit d167b9216a
38 changed files with 4174 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package store
import (
"database/sql"
"fmt"
"strings"
)
func migrateUserProfileColumns(db *sql.DB, dialect string) error {
cols := []string{"avatar_url", "state"}
for _, col := range cols {
var stmt string
switch dialect {
case dialectPostgres:
stmt = fmt.Sprintf(`ALTER TABLE users ADD COLUMN IF NOT EXISTS %s TEXT NOT NULL DEFAULT ''`, col)
default:
stmt = fmt.Sprintf(`ALTER TABLE users ADD COLUMN %s TEXT NOT NULL DEFAULT ''`, col)
}
if _, err := db.Exec(stmt); err != nil {
// SQLite errors when the column already exists.
if dialect == dialectSQLite && strings.Contains(strings.ToLower(err.Error()), "duplicate column") {
continue
}
return fmt.Errorf("add column %s: %w", col, err)
}
}
return nil
}