коммит произвёл
GitHub
родитель
62495f16bd
Коммит
150c6e7aef
@@ -198,67 +198,6 @@ func (h *MainHelper) PreloadMigrations() {
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "Error preloading migrations. Check if you have &multiStatements=true in your DSN if you are using MySQL. Or perhaps the schema changed? If yes, then update the warmup files accordingly"))
|
||||
}
|
||||
|
||||
h.PreloadBoardsMigrationsIfNeeded()
|
||||
}
|
||||
|
||||
// PreloadBoardsMigrationsIfNeeded loads boards migrations if the
|
||||
// focalboard_schema_migrations table exists already.
|
||||
// Besides this, the same compatibility and breaking conditions that
|
||||
// PreloadMigrations has apply here.
|
||||
//
|
||||
// Re-generate the files with:
|
||||
// pg_dump -a -h localhost -U mmuser -d <> --no-comments --inserts -t focalboard_system_settings
|
||||
// mysqldump -u root -p <> --no-create-info --extended-insert=FALSE focalboard_system_settings
|
||||
func (h *MainHelper) PreloadBoardsMigrationsIfNeeded() {
|
||||
tableSchemaFn := "current_schema()"
|
||||
if *h.Settings.DriverName == model.DatabaseDriverMysql {
|
||||
tableSchemaFn = "DATABASE()"
|
||||
}
|
||||
|
||||
basePath := os.Getenv("MM_SERVER_PATH")
|
||||
if basePath == "" {
|
||||
_, errFile := os.Stat("mattermost-server/server")
|
||||
if os.IsNotExist(errFile) {
|
||||
basePath = "mattermost/server"
|
||||
} else {
|
||||
basePath = "mattermost-server/server"
|
||||
}
|
||||
}
|
||||
relPath := "channels/testlib/testdata"
|
||||
|
||||
handle := h.SQLStore.GetMasterX()
|
||||
var boardsTableCount int
|
||||
gErr := handle.Get(&boardsTableCount, `
|
||||
SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = `+tableSchemaFn+`
|
||||
AND TABLE_NAME = 'focalboard_schema_migrations'`)
|
||||
if gErr != nil {
|
||||
panic(errors.Wrap(gErr, "Error preloading migrations. Cannot query INFORMATION_SCHEMA table to check for focalboard_schema_migrations table"))
|
||||
}
|
||||
|
||||
var buf []byte
|
||||
var err error
|
||||
if boardsTableCount != 0 {
|
||||
switch *h.Settings.DriverName {
|
||||
case model.DatabaseDriverPostgres:
|
||||
boardsFinalPath := filepath.Join(basePath, relPath, "boards_postgres_migration_warmup.sql")
|
||||
buf, err = os.ReadFile(boardsFinalPath)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot read file: %v", err))
|
||||
}
|
||||
case model.DatabaseDriverMysql:
|
||||
boardsFinalPath := filepath.Join(basePath, relPath, "boards_mysql_migration_warmup.sql")
|
||||
buf, err = os.ReadFile(boardsFinalPath)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("cannot read file: %v", err))
|
||||
}
|
||||
}
|
||||
if _, err := handle.Exec(string(buf)); err != nil {
|
||||
panic(errors.Wrap(err, "Error preloading boards migrations. Check if you have &multiStatements=true in your DSN if you are using MySQL. Or perhaps the schema changed? If yes, then update the warmup files accordingly"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (h *MainHelper) Close() error {
|
||||
|
||||
Ссылка в новой задаче
Block a user