mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
DB migration: Add require_all column to installers labels tables (#41279)
This commit is contained in:
parent
6527ab7145
commit
f8fa379732
3 changed files with 54 additions and 5 deletions
|
|
@ -0,0 +1,33 @@
|
|||
package tables
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func init() {
|
||||
MigrationClient.AddMigration(Up_20260309182329, Down_20260309182329)
|
||||
}
|
||||
|
||||
func Up_20260309182329(tx *sql.Tx) error {
|
||||
_, err := tx.Exec(`ALTER TABLE in_house_app_labels ADD COLUMN require_all BOOL NOT NULL DEFAULT false`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add require_all to in_house_app_labels: %w", err)
|
||||
}
|
||||
|
||||
_, err = tx.Exec(`ALTER TABLE software_installer_labels ADD COLUMN require_all BOOL NOT NULL DEFAULT false`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add require_all to software_installer_labels: %w", err)
|
||||
}
|
||||
|
||||
_, err = tx.Exec(`ALTER TABLE vpp_app_team_labels ADD COLUMN require_all BOOL NOT NULL DEFAULT false`)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to add require_all to vpp_app_team_labels: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Down_20260309182329(tx *sql.Tx) error {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package tables
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestUp_20260309182329(t *testing.T) {
|
||||
db := applyUpToPrev(t)
|
||||
|
||||
// Just a new column, so no logic to test here.
|
||||
// Leaving it in because it's nice to validate that the migration applies successfully.
|
||||
|
||||
// Apply current migration.
|
||||
applyNext(t, db)
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue