-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Problem
The PostgresConnection.Connect() method has MultiStatementEnabled: true hardcoded when creating the
golang-migrate driver:
primaryDriver, err := postgres.WithInstance(dbPrimary, &postgres.Config{
MultiStatementEnabled: true, // hardcoded
DatabaseName: pc.PrimaryDBName,
SchemaName: "public",
})This prevents consumers from controlling whether migrations run with multi-statement mode enabled or disabled.
Proposal
Add a MultiStatementEnabled *bool field to PostgresConnection struct:
type PostgresConnection struct {
// ... existing fields ...
MultiStatementEnabled *bool // nil = default true (backward compatible)
}Update Connect() to use the field with default true:
multiStmtEnabled := true
if pc.MultiStatementEnabled != nil {
multiStmtEnabled = *pc.MultiStatementEnabled
}Usage example
type Config struct {
// ... other fields ...
// PostgreSQL migration settings
MultiStatementEnabled *bool `env:"DB_MULTI_STATEMENT_ENABLED"`
}
postgresConnection := &libPostgres.PostgresConnection{
ConnectionStringPrimary: connStr,
// ... other fields ...
MultiStatementEnabled: cfg.MultiStatementEnabled, // nil = defaults to true
}Why pointer?
Using *bool instead of bool allows distinguishing between:
nil→ not configured, use defaulttrue&true→ explicitly enabled&false→ explicitly disabled
Backward Compatibility
- Default behavior unchanged (
true) - No breaking changes to existing consumers
- Field is optional
Reactions are currently unavailable