mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 16:10:03 +01:00
Initial commit
This commit is contained in:
commit
9cfc758ca1
14 changed files with 697 additions and 0 deletions
30
driver/driver.go
Normal file
30
driver/driver.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package driver
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/adrianmacneil/dbmate/driver/postgres"
|
||||
"github.com/adrianmacneil/dbmate/driver/shared"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// Driver provides top level database functions
|
||||
type Driver interface {
|
||||
Open(*url.URL) (*sql.DB, error)
|
||||
CreateDatabase(*url.URL) error
|
||||
DropDatabase(*url.URL) error
|
||||
CreateMigrationsTable(*sql.DB) error
|
||||
SelectMigrations(*sql.DB) (map[string]struct{}, error)
|
||||
InsertMigration(shared.Transaction, string) error
|
||||
DeleteMigration(shared.Transaction, string) error
|
||||
}
|
||||
|
||||
// Get loads a database driver by name
|
||||
func Get(name string) (Driver, error) {
|
||||
switch name {
|
||||
case "postgres":
|
||||
return postgres.Driver{}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("Unknown driver: %s", name)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue