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>
16 lines
506 B
Go
16 lines
506 B
Go
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)"
|
|
}
|