feat:multi cluster application
This commit is contained in:
4
vendor/openpitrix.io/openpitrix/pkg/db/Dockerfile
generated
vendored
4
vendor/openpitrix.io/openpitrix/pkg/db/Dockerfile
generated
vendored
@@ -2,9 +2,9 @@
|
||||
# Use of this source code is governed by a Apache license
|
||||
# that can be found in the LICENSE file.
|
||||
|
||||
FROM dhoer/flyway:5.1.4-mysql-8.0.11-alpine
|
||||
FROM openpitrix/flyway:alpine
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
USER root
|
||||
RUN apk add --no-cache mysql-client
|
||||
|
||||
COPY ./schema /flyway/sql
|
||||
|
||||
6
vendor/openpitrix.io/openpitrix/pkg/db/connection.go
generated
vendored
6
vendor/openpitrix.io/openpitrix/pkg/db/connection.go
generated
vendored
@@ -61,9 +61,11 @@ func FromContext(ctx context.Context) (*Database, bool) {
|
||||
|
||||
func (db *Database) New(ctx context.Context) *Conn {
|
||||
actualDb, ok := FromContext(ctx)
|
||||
conn := db.Conn
|
||||
if ok {
|
||||
var conn *dbr.Connection
|
||||
if ok || db == nil {
|
||||
conn = actualDb.Conn
|
||||
} else {
|
||||
conn = db.Conn
|
||||
}
|
||||
return &Conn{
|
||||
Session: conn.NewSession(&EventReceiver{ctx}),
|
||||
|
||||
14
vendor/openpitrix.io/openpitrix/pkg/db/db.go
generated
vendored
14
vendor/openpitrix.io/openpitrix/pkg/db/db.go
generated
vendored
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/gocraft/dbr"
|
||||
@@ -91,6 +90,14 @@ func (b *SelectQuery) Join(table, on interface{}) *SelectQuery {
|
||||
b.SelectBuilder.Join(table, on)
|
||||
return b
|
||||
}
|
||||
func (b *SelectQuery) RightJoin(table, on interface{}) *SelectQuery {
|
||||
b.SelectBuilder.RightJoin(table, on)
|
||||
return b
|
||||
}
|
||||
func (b *SelectQuery) LeftJoin(table, on interface{}) *SelectQuery {
|
||||
b.SelectBuilder.LeftJoin(table, on)
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *SelectQuery) JoinAs(table string, alias string, on interface{}) *SelectQuery {
|
||||
b.SelectBuilder.Join(dbr.I(table).As(alias), on)
|
||||
@@ -143,13 +150,12 @@ func (b *SelectQuery) LoadOne(value interface{}) error {
|
||||
}
|
||||
|
||||
func getColumns(dbrColumns []interface{}) string {
|
||||
var columns []string
|
||||
for _, column := range dbrColumns {
|
||||
if c, ok := column.(string); ok {
|
||||
columns = append(columns, c)
|
||||
return c
|
||||
}
|
||||
}
|
||||
return strings.Join(columns, ", ")
|
||||
return "*"
|
||||
}
|
||||
|
||||
func (b *SelectQuery) Count() (count uint32, err error) {
|
||||
|
||||
Reference in New Issue
Block a user