-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation for Apple config profiles.
- Loading branch information
Showing
8 changed files
with
265 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
server/datastore/mysql/migrations/tables/20241223115925_AddSecretsUpdatedAt.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package tables | ||
|
||
import ( | ||
"database/sql" | ||
"fmt" | ||
) | ||
|
||
func init() { | ||
MigrationClient.AddMigration(Up_20241223115925, Down_20241223115925) | ||
} | ||
|
||
func Up_20241223115925(tx *sql.Tx) error { | ||
// secrets_updated_at are updated when profile contents have not changed but secret variables in the profile have changed | ||
_, err := tx.Exec(`ALTER TABLE mdm_apple_configuration_profiles | ||
ADD COLUMN secrets_updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), | ||
MODIFY COLUMN created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), | ||
MODIFY COLUMN uploaded_at TIMESTAMP(6) NULL DEFAULT NULL`) | ||
if err != nil { | ||
return fmt.Errorf("failed to alter mdm_apple_configuration_profiles table: %w", err) | ||
} | ||
|
||
// Add secrets_updated_at column to host_mdm_apple_profiles | ||
_, err = tx.Exec(`ALTER TABLE host_mdm_apple_profiles | ||
ADD COLUMN secrets_updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)`) | ||
if err != nil { | ||
return fmt.Errorf("failed to add secrets_updated_at to host_mdm_apple_profiles table: %w", err) | ||
} | ||
|
||
// secrets_updated_at are updated when profile contents have not changed but secret variables in the profile have changed | ||
_, err = tx.Exec(`ALTER TABLE mdm_apple_declarations | ||
ADD COLUMN secrets_updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), | ||
MODIFY COLUMN created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), | ||
MODIFY COLUMN uploaded_at TIMESTAMP(6) NULL DEFAULT NULL`) | ||
if err != nil { | ||
return fmt.Errorf("failed to alter mdm_apple_declarations table: %w", err) | ||
} | ||
|
||
// Add secrets_updated_at column to host_mdm_apple_declarations | ||
_, err = tx.Exec(`ALTER TABLE host_mdm_apple_declarations | ||
-- defaulting to NULL for backward compatibility with existing declarations | ||
ADD COLUMN secrets_updated_at TIMESTAMP(6) NULL`) | ||
if err != nil { | ||
return fmt.Errorf("failed to add secrets_updated_at to host_mdm_apple_declarations table: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func Down_20241223115925(_ *sql.Tx) error { | ||
return nil | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.