mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
#22692 # 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/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#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] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [x] Manual QA for all new/changed functionality
26 lines
565 B
Go
26 lines
565 B
Go
package tables
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
)
|
|
|
|
func init() {
|
|
MigrationClient.AddMigration(Up_20241004005000, Down_20241004005000)
|
|
}
|
|
|
|
func Up_20241004005000(tx *sql.Tx) error {
|
|
if _, err := tx.Exec(`
|
|
ALTER TABLE host_script_results
|
|
ADD COLUMN policy_id INT UNSIGNED DEFAULT NULL,
|
|
ADD FOREIGN KEY fk_script_result_policy_id (policy_id) REFERENCES policies (id) ON DELETE SET NULL
|
|
`); err != nil {
|
|
return fmt.Errorf("failed to add policy_id to host script results: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func Down_20241004005000(tx *sql.Tx) error {
|
|
return nil
|
|
}
|