-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package database | ||
|
||
import "context" | ||
|
||
// StoreExtender is an extension of the Store interface that provides optional optimizations and | ||
// database-specific features. While not required by the core goose package, implementing these | ||
// methods can improve performance and functionality for specific databases. | ||
// | ||
// IMPORTANT: This interface may be expanded in future versions. Implementors MUST be prepared to | ||
// update their implementations when new methods are added, either by implementing the new | ||
// functionality or returning [errors.ErrUnsupported]. This is similar to how Go's standard library | ||
// handles interface extensions (e.g., sql.Scanner, sql.Driver). | ||
// | ||
// The goose package handles these extended capabilities through a [controller.StoreController], | ||
// which automatically uses optimized methods when available while falling back to default behavior | ||
// when they're not implemented. | ||
// | ||
// Example usage to verify implementation: | ||
// | ||
// var _ StoreExtender = (*CustomStoreExtended)(nil) | ||
// | ||
// In short, a compile-time to allow implementors to verify that they have implemented all methods. | ||
type StoreExtender interface { | ||
Store | ||
|
||
// TableExists checks if the migrations table exists in the database. Implementing this method | ||
// allows goose to optimize table existence checks by using database-specific system catalogs | ||
// (e.g., pg_tables for PostgreSQL, sqlite_master for SQLite) instead of generic SQL queries. | ||
// | ||
// Return [errors.ErrUnsupported] if the database does not provide an efficient way to check | ||
// table existence. | ||
TableExists(ctx context.Context, db DBTxConn) (bool, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters