Fix migrate lock scope and stop RealIP from bypassing proxy trust.

Hold a session advisory lock for the full migration apply path, and remove Chi RealIP so clientIP can validate the TCP peer before walking X-Forwarded-For.
This commit is contained in:
2026-08-22 12:25:16 -07:00
parent 29b0536215
commit 35c8c9f391
4 changed files with 89 additions and 24 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
package store
import (
"context"
"database/sql"
"fmt"
"net/url"
@@ -11,13 +12,13 @@ import (
)
// applySchema runs semicolon-separated DDL statements.
func applySchema(db *sql.DB, schema string) error {
func applySchema(ctx context.Context, exec execContext, schema string) error {
for _, stmt := range strings.Split(schema, ";") {
stmt = strings.TrimSpace(stmt)
if stmt == "" {
continue
}
if _, err := db.Exec(stmt); err != nil {
if _, err := exec.ExecContext(ctx, stmt); err != nil {
return fmt.Errorf("%w: %s", err, stmt)
}
}