forked from pressly/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialect.go
59 lines (52 loc) · 1.41 KB
/
dialect.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package goose
import (
"fmt"
"github.com/pressly/goose/v3/database"
"github.com/pressly/goose/v3/internal/dialect"
)
// Dialect is the type of database dialect. It is an alias for [database.Dialect].
type Dialect = database.Dialect
const (
DialectClickHouse Dialect = database.DialectClickHouse
DialectMSSQL Dialect = database.DialectMSSQL
DialectMySQL Dialect = database.DialectMySQL
DialectPostgres Dialect = database.DialectPostgres
DialectRedshift Dialect = database.DialectRedshift
DialectSQLite3 Dialect = database.DialectSQLite3
DialectTiDB Dialect = database.DialectTiDB
DialectVertica Dialect = database.DialectVertica
DialectYdB Dialect = database.DialectYdB
)
func init() {
store, _ = dialect.NewStore(dialect.Postgres)
}
var store dialect.Store
// SetDialect sets the dialect to use for the goose package.
func SetDialect(s string) error {
var d dialect.Dialect
switch s {
case "postgres", "pgx":
d = dialect.Postgres
case "mysql":
d = dialect.Mysql
case "sqlite3", "sqlite":
d = dialect.Sqlite3
case "mssql", "azuresql", "sqlserver":
d = dialect.Sqlserver
case "redshift":
d = dialect.Redshift
case "tidb":
d = dialect.Tidb
case "clickhouse":
d = dialect.Clickhouse
case "vertica":
d = dialect.Vertica
case "ydb":
d = dialect.Ydb
default:
return fmt.Errorf("%q: unknown dialect", s)
}
var err error
store, err = dialect.NewStore(d)
return err
}