Remove boards product references (#23855)

Automatic Merge
Этот коммит содержится в:
Miguel de la Cruz
2023-07-18 14:17:29 +02:00
коммит произвёл GitHub
родитель 62495f16bd
Коммит 150c6e7aef
1371 изменённых файлов: 17 добавлений и 264248 удалений

Просмотреть файл

@@ -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 {