Extract generic migration logic into datastores/sql/migrate package
Move database-agnostic migration logic (file discovery, version tracking, bootstrap detection) into a shared migrate package behind a Dialect interface, leaving postgres as a thin wrapper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
15
datastores/sql/postgres/dialect.go
Normal file
15
datastores/sql/postgres/dialect.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package postgres
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Dialect implements migrate.Dialect for PostgreSQL.
|
||||
type Dialect struct{}
|
||||
|
||||
// Placeholder returns PostgreSQL's positional bind parameter ($1, $2, …).
|
||||
func (Dialect) Placeholder(n int) string { return fmt.Sprintf("$%d", n) }
|
||||
|
||||
// TableExistsQuery returns a query that checks whether a table exists in
|
||||
// PostgreSQL using information_schema.
|
||||
func (Dialect) TableExistsQuery() string {
|
||||
return "SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_name = $1)"
|
||||
}
|
||||
Reference in New Issue
Block a user