1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/store/datastore/ddl/migrate.go

30 lines
625 B
Go
Raw Normal View History

2017-05-13 09:56:23 +02:00
package ddl
import (
"database/sql"
"github.com/drone/drone/store/datastore/ddl/mysql"
"github.com/drone/drone/store/datastore/ddl/postgres"
"github.com/drone/drone/store/datastore/ddl/sqlite"
)
// Supported database drivers
const (
DriverSqlite = "sqlite3"
DriverMysql = "mysql"
DriverPostgres = "postgres"
)
// Migrate performs the database migration. If the migration fails
// and error is returned.
func Migrate(driver string, db *sql.DB) error {
switch driver {
case DriverMysql:
return mysql.Migrate(db)
case DriverPostgres:
return postgres.Migrate(db)
default:
return sqlite.Migrate(db)
}
}