Add UnderlyingConn(ctx) for safer scoped DB access
- Add UnderlyingConn method to Storage interface - Implement in SQLiteStorage for scoped connection access - Useful for migrations and DDL operations - Add comprehensive tests for basic access, DDL, context cancellation, and concurrent connections - Closes bd-66, bd-22, bd-24, bd-38, bd-39, bd-56 Amp-Thread-ID: https://ampcode.com/threads/T-e47963af-4ace-4914-a0ae-4737f77be6ff Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -79,6 +79,12 @@ type Storage interface {
|
||||
// in the same database. Extensions should use foreign keys to reference core tables.
|
||||
// WARNING: Direct database access bypasses the storage layer. Use with caution.
|
||||
UnderlyingDB() *sql.DB
|
||||
|
||||
// UnderlyingConn returns a single connection from the pool for scoped use.
|
||||
// Useful for migrations and DDL operations that benefit from explicit connection lifetime.
|
||||
// The caller MUST close the connection when done to return it to the pool.
|
||||
// For general queries, prefer UnderlyingDB() which manages the pool automatically.
|
||||
UnderlyingConn(ctx context.Context) (*sql.Conn, error)
|
||||
}
|
||||
|
||||
// Config holds database configuration
|
||||
|
||||
Reference in New Issue
Block a user