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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user