mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-11 23:29:01 +08:00
fix: disable removing a selected field (#5457)
* fix: disable removing a selected field * fix: comment updated with issue link * fix: remove local db
This commit is contained in:
parent
831de18464
commit
83455e614e
@ -3575,38 +3575,42 @@ func (r *ClickHouseReader) UpdateLogField(ctx context.Context, field *model.Upda
|
||||
}
|
||||
|
||||
} else {
|
||||
// We are not allowing to delete a materialized column
|
||||
// For more details please check https://github.com/SigNoz/signoz/issues/4566
|
||||
return model.ForbiddenError(errors.New("Removing a selected field is not allowed, please reach out to support."))
|
||||
|
||||
// Delete the index first
|
||||
query := fmt.Sprintf("ALTER TABLE %s.%s ON CLUSTER %s DROP INDEX IF EXISTS %s_idx`", r.logsDB, r.logsLocalTable, r.cluster, strings.TrimSuffix(colname, "`"))
|
||||
err := r.db.Exec(ctx, query)
|
||||
if err != nil {
|
||||
return &model.ApiError{Err: err, Typ: model.ErrorInternal}
|
||||
}
|
||||
// query := fmt.Sprintf("ALTER TABLE %s.%s ON CLUSTER %s DROP INDEX IF EXISTS %s_idx`", r.logsDB, r.logsLocalTable, r.cluster, strings.TrimSuffix(colname, "`"))
|
||||
// err := r.db.Exec(ctx, query)
|
||||
// if err != nil {
|
||||
// return &model.ApiError{Err: err, Typ: model.ErrorInternal}
|
||||
// }
|
||||
|
||||
for _, table := range []string{r.logsTable, r.logsLocalTable} {
|
||||
// drop materialized column from logs table
|
||||
query := "ALTER TABLE %s.%s ON CLUSTER %s DROP COLUMN IF EXISTS %s "
|
||||
err := r.db.Exec(ctx, fmt.Sprintf(query,
|
||||
r.logsDB, table,
|
||||
r.cluster,
|
||||
colname,
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return &model.ApiError{Err: err, Typ: model.ErrorInternal}
|
||||
}
|
||||
// for _, table := range []string{r.logsTable, r.logsLocalTable} {
|
||||
// // drop materialized column from logs table
|
||||
// query := "ALTER TABLE %s.%s ON CLUSTER %s DROP COLUMN IF EXISTS %s "
|
||||
// err := r.db.Exec(ctx, fmt.Sprintf(query,
|
||||
// r.logsDB, table,
|
||||
// r.cluster,
|
||||
// colname,
|
||||
// ),
|
||||
// )
|
||||
// if err != nil {
|
||||
// return &model.ApiError{Err: err, Typ: model.ErrorInternal}
|
||||
// }
|
||||
|
||||
// drop exists column on logs table
|
||||
query = "ALTER TABLE %s.%s ON CLUSTER %s DROP COLUMN IF EXISTS %s_exists` "
|
||||
err = r.db.Exec(ctx, fmt.Sprintf(query,
|
||||
r.logsDB, table,
|
||||
r.cluster,
|
||||
strings.TrimSuffix(colname, "`"),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return &model.ApiError{Err: err, Typ: model.ErrorInternal}
|
||||
}
|
||||
}
|
||||
// // drop exists column on logs table
|
||||
// query = "ALTER TABLE %s.%s ON CLUSTER %s DROP COLUMN IF EXISTS %s_exists` "
|
||||
// err = r.db.Exec(ctx, fmt.Sprintf(query,
|
||||
// r.logsDB, table,
|
||||
// r.cluster,
|
||||
// strings.TrimSuffix(colname, "`"),
|
||||
// ),
|
||||
// )
|
||||
// if err != nil {
|
||||
// return &model.ApiError{Err: err, Typ: model.ErrorInternal}
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user