Merge branch 'fix_migrations' into 'master'
fix migrations See merge request integration-system/isp-system-service!4
This commit is contained in:
commit
d9f8ae19f8
4 files changed
+18
-37
No files matched your search
@@ -1,3 +1,5 @@
|
||||
### v2.2.6
|
||||
* fix migrations
|
||||
### v2.2.5
|
||||
* updated dependencies
|
||||
### v2.2.4
|
||||
|
||||
@@ -4,12 +4,6 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"isp-system-service/conf"
|
||||
"isp-system-service/helper"
|
||||
_ "isp-system-service/migrations"
|
||||
"isp-system-service/model"
|
||||
"isp-system-service/redis"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/backend"
|
||||
"github.com/integration-system/isp-lib/v2/bootstrap"
|
||||
"github.com/integration-system/isp-lib/v2/config/schema"
|
||||
@@ -17,7 +11,12 @@ import (
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/integration-system/isp-log/stdcodes"
|
||||
"isp-system-service/conf"
|
||||
_ "isp-system-service/docs"
|
||||
"isp-system-service/helper"
|
||||
"isp-system-service/migrations"
|
||||
"isp-system-service/model"
|
||||
"isp-system-service/redis"
|
||||
)
|
||||
|
||||
var version = "0.1.0"
|
||||
@@ -48,28 +47,6 @@ func main() {
|
||||
Run()
|
||||
}
|
||||
|
||||
/*func ensureRootToken() {
|
||||
tokens, err := model.TokenRep.GetTokensByAppId(entity.RootAdminApplicationId)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
if len(tokens) > 0 {
|
||||
m, err, _ := controller.GetIdMap(entity.RootAdminApplicationId)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return
|
||||
}
|
||||
for _, token := range tokens {
|
||||
err = controller.SetIdentityMapForToken(token, m)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
func onRemoteErrorReceive(errorMessage map[string]interface{}) {
|
||||
log.WithMetadata(errorMessage).Error(stdcodes.ReceiveErrorFromConfig, "error from config service")
|
||||
}
|
||||
@@ -101,6 +78,7 @@ func onShutdown(_ context.Context, _ os.Signal) {
|
||||
}
|
||||
|
||||
func onRemoteConfigReceive(remoteConfig, oldConfig *conf.RemoteConfig) {
|
||||
migrations.DatabaseConfig = remoteConfig.Database
|
||||
redis.Client.ReceiveConfiguration(remoteConfig.Redis)
|
||||
model.DbClient.ReceiveConfiguration(remoteConfig.Database)
|
||||
metric.InitCollectors(remoteConfig.Metrics, oldConfig.Metrics)
|
||||
|
||||
@@ -5,14 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"isp-system-service/conf"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
"github.com/pressly/goose"
|
||||
"isp-system-service/controller"
|
||||
"isp-system-service/domain"
|
||||
path2 "path"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
"github.com/pressly/goose"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,12 +25,14 @@ const (
|
||||
initFile = "init.json"
|
||||
)
|
||||
|
||||
var DatabaseConfig structure.DBConfiguration
|
||||
|
||||
func init() {
|
||||
goose.AddMigration(Up, Down)
|
||||
}
|
||||
|
||||
func Up(tx *sql.Tx) error {
|
||||
path := path2.Join(database.ResolveMigrationsDirectory(), initFile)
|
||||
path := filepath.Join(database.ResolveMigrationsDirectory(), initFile)
|
||||
bytes, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -42,7 +43,7 @@ func Up(tx *sql.Tx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
schema := config.GetRemote().(*conf.RemoteConfig).Database.Schema
|
||||
schema := DatabaseConfig.Schema
|
||||
lastDomainId := int64(0)
|
||||
lastServiceId := int64(0)
|
||||
lastAppId := int64(0)
|
||||
|
||||
Reference in new issue
Block a user