refactor: unify db dialect definition in dbdialects package
This commit is contained in:
7
internal/app/db-wrapper/db-dialects/main.go
Normal file
7
internal/app/db-wrapper/db-dialects/main.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package dbdialects
|
||||||
|
|
||||||
|
const (
|
||||||
|
SqlServer string = "sqlserver"
|
||||||
|
Postgres string = "postgres"
|
||||||
|
Null string = "null"
|
||||||
|
)
|
||||||
@@ -5,12 +5,13 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
dbdialects "git.ksdemosapps.com/kylesoda/go-migrate/internal/app/db-wrapper/db-dialects"
|
||||||
mssql "github.com/microsoft/go-mssqldb"
|
mssql "github.com/microsoft/go-mssqldb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Register("sqlserver", func() DbWrapper {
|
Register(dbdialects.SqlServer, func() DbWrapper {
|
||||||
return &mssqlDbWrapper{dialect: "sqlserver"}
|
return &mssqlDbWrapper{dialect: dbdialects.SqlServer}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
dbdialects "git.ksdemosapps.com/kylesoda/go-migrate/internal/app/db-wrapper/db-dialects"
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Register("postgres", func() DbWrapper {
|
Register(dbdialects.Postgres, func() DbWrapper {
|
||||||
return &postgresDbWrapper{dialect: "postgres"}
|
return &postgresDbWrapper{dialect: dbdialects.Postgres}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user