fleet/server/datastore/mysql/migrations/tables/20240313143416_RemoveScriptContentsColumns.go
Jahziel Villasana-Espinoza 2b9487197c
feat: script content cleanup and column removal (#17374)
> Related issue: #17374

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated tests
- [x] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Manual QA for all new/changed functionality
2024-03-13 15:53:08 -04:00

29 lines
629 B
Go

package tables
import (
"database/sql"
"fmt"
)
func init() {
MigrationClient.AddMigration(Up_20240313143416, Down_20240313143416)
}
func Up_20240313143416(tx *sql.Tx) error {
stmt := `ALTER TABLE scripts DROP COLUMN script_contents`
if _, err := tx.Exec(stmt); err != nil {
return fmt.Errorf("remove scripts.script_contents column: %w", err)
}
stmt = `ALTER TABLE host_script_results DROP COLUMN script_contents`
if _, err := tx.Exec(stmt); err != nil {
return fmt.Errorf("remove host_script_results.script_contents column: %w", err)
}
return nil
}
func Down_20240313143416(tx *sql.Tx) error {
return nil
}