Skip to content

CADDM: Migration #49966

Description

@MagnusHJensen

Related user story

#48222

Task

  • Migration creating one tables for activation management, updates two for variable association and dropping an old stale one.
DROP TABLE IF EXISTS mdm_apple_declaration_activation_references;

CREATE TABLE `mdm_apple_ddm_activations` (
   `activation_uuid`          varchar(37)  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
   `team_id`                  int unsigned NOT NULL,
   `identifier`               varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   `raw_json`                 mediumtext   CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
    -- 1:1 mapping 
   `configuration_identifier` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   `secrets_updated_at`       datetime(6)  DEFAULT NULL,
   `created_at`               timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
   `uploaded_at`              timestamp(6) NULL DEFAULT NULL,
   `token`                    binary(16) GENERATED ALWAYS AS
 (unhex(md5(concat(`raw_json`,ifnull(`secrets_updated_at`,_utf8mb4''))))) STORED,
   PRIMARY KEY (`activation_uuid`),
   UNIQUE KEY `idx_mdm_apple_ddm_activation_team_identifier` (`team_id`,`identifier`),
   UNIQUE KEY `idx_mdm_apple_ddm_activation_team_config` (`team_id`,`configuration_identifier`),
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


 ALTER TABLE `mdm_configuration_profile_variables`
   ADD COLUMN `apple_ddm_activation_uuid` varchar(37) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   ADD CONSTRAINT `mdm_config_profile_variables_ddm_activation_fk` FOREIGN KEY (`apple_ddm_activation_uuid`)
 REFERENCES `mdm_apple_ddm_activations` (`activation_uuid`) ON DELETE CASCADE;

ALTER TABLE `host_mdm_apple_declarations`
  ADD COLUMN `activation_updated_at` timestamp(6) NULL DEFAULT NULL;

Condition of satisfaction

The migration have _test.go coverage and apply cleanly; schema.sql regenerated.

Metadata

Metadata

Assignees

Labels

#g-apple-at-workProduct group focused on Apple devices~sub-taskA technical sub-task that is part of a story. (Not QA'd. Not estimated.)

Type

No type

Projects

Status
✅ Ready for release

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions