From 902b4084b7c6cc730c51b5505259da9d020a4fef Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Thu, 7 Mar 2024 16:46:12 -0300 Subject: [PATCH 1/6] add migrations for commands for #16830 --- .../20240307162019_AddUserIDToCommands.go | 56 ++++++++ ...20240307162019_AddUserIDToCommands_test.go | 120 ++++++++++++++++++ server/datastore/mysql/schema.sql | 28 +++- 3 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go create mode 100644 server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go diff --git a/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go b/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go new file mode 100644 index 00000000000..a66e1dd2961 --- /dev/null +++ b/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go @@ -0,0 +1,56 @@ +package tables + +import ( + "database/sql" + "fmt" +) + +func init() { + MigrationClient.AddMigration(Up_20240307162019, Down_20240307162019) +} + +func Up_20240307162019(tx *sql.Tx) error { + + tables := []string{ + "nano_commands", "windows_mdm_commands", + "mdm_apple_configuration_profiles", "mdm_windows_configuration_profiles", + } + + for _, t := range tables { + _, err := tx.Exec(fmt.Sprintf(` + ALTER TABLE`+" `%s` "+` + -- user_id references the user that created the entity. + -- it's NULL for rows created prior to this migration, + -- and also for entities that don't have an user + -- associated with it (eg: Fleet initiated actions) + ADD COLUMN user_id int(10) unsigned DEFAULT NULL, + + -- fleet_owned indicates if the entity is managed by Fleet. + ADD COLUMN fleet_owned tinyint(1) DEFAULT NULL + + -- this check is only parsed in MySQL 8+ + CHECK ( + (user_id IS NOT NULL AND fleet_owned = 0) OR + (user_id IS NULL AND fleet_owned = 1) OR + (user_id IS NULL AND fleet_ownded IS NULL) + )`, t)) + if err != nil { + return fmt.Errorf("failed to add user_id and fleet_owned to %s: %w", t, err) + } + + _, err = tx.Exec(fmt.Sprintf(` + ALTER TABLE`+" `%s` "+` + ADD CONSTRAINT`+" `fk_%s_users` "+` + FOREIGN KEY (user_id) REFERENCES users(id) + ON DELETE SET NULL`, t, t)) + if err != nil { + return fmt.Errorf("failed to add user_id foreign key to %s: %w", t, err) + } + } + + return nil +} + +func Down_20240307162019(tx *sql.Tx) error { + return nil +} diff --git a/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go b/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go new file mode 100644 index 00000000000..65f5a748d7d --- /dev/null +++ b/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go @@ -0,0 +1,120 @@ +package tables + +import ( + "fmt" + "strings" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestUp_20240307162019(t *testing.T) { + db := applyUpToPrev(t) + + dataStmts := ` +INSERT INTO users VALUES + (1,'2023-07-21','2023-07-21',_binary '$2a$12$n6hwsD7OU2bAXX94551DQOBcNNhfsEPS3Y6JEuLDjsLNvry3lgJjy','0fF81xRQIriYzm5fdXouk3V3tRwsZJhV','admin','admin@email.com',0,'','',0,'admin',0); + +INSERT INTO nano_commands + (command_uuid, request_type, command, created_at, updated_at) +VALUES + ('nano-command-uuid-1', 'nano', ' Date: Wed, 13 Mar 2024 16:51:30 -0300 Subject: [PATCH 2/6] fix migrations --- .../20240307162019_AddUserIDToCommands.go | 56 - ...ackUserReferencesForCommandsAndProfiles.go | 84 ++ ...rReferencesForCommandsAndProfiles_test.go} | 61 +- server/datastore/mysql/schema.sql | 1122 ++++++++--------- 4 files changed, 684 insertions(+), 639 deletions(-) delete mode 100644 server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go create mode 100644 server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go rename server/datastore/mysql/migrations/tables/{20240307162019_AddUserIDToCommands_test.go => 20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go} (60%) diff --git a/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go b/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go deleted file mode 100644 index 5adf343ec5c..00000000000 --- a/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands.go +++ /dev/null @@ -1,56 +0,0 @@ -package tables - -import ( - "database/sql" - "fmt" -) - -func init() { - MigrationClient.AddMigration(Up_20240307162019, Down_20240307162019) -} - -func Up_20240307162019(tx *sql.Tx) error { - - tables := []string{ - "nano_commands", "windows_mdm_commands", - "mdm_apple_configuration_profiles", "mdm_windows_configuration_profiles", - } - - for _, t := range tables { - _, err := tx.Exec(fmt.Sprintf(` - ALTER TABLE`+" `%s` "+` - -- user_id references the user that created the entity. - -- it's NULL for rows created prior to this migration, - -- and also for entities that don't have an user - -- associated with it (eg: Fleet initiated actions) - ADD COLUMN user_id int(10) unsigned DEFAULT NULL, - - -- fleet_owned indicates if the entity is managed by Fleet. - ADD COLUMN fleet_owned tinyint(1) DEFAULT NULL - - -- this check is only parsed in MySQL 8+ - -- CHECK ( - -- (user_id IS NOT NULL AND fleet_owned = 0) OR - -- (user_id IS NULL AND fleet_owned = 1) OR - -- (user_id IS NULL AND fleet_ownded IS NULL) - -- )`, t)) - if err != nil { - return fmt.Errorf("failed to add user_id and fleet_owned to %s: %w", t, err) - } - - _, err = tx.Exec(fmt.Sprintf(` - ALTER TABLE`+" `%s` "+` - ADD CONSTRAINT`+" `fk_%s_users` "+` - FOREIGN KEY (user_id) REFERENCES users(id) - ON DELETE SET NULL`, t, t)) - if err != nil { - return fmt.Errorf("failed to add user_id foreign key to %s: %w", t, err) - } - } - - return nil -} - -func Down_20240307162019(tx *sql.Tx) error { - return nil -} diff --git a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go new file mode 100644 index 00000000000..d6c6b8f2c86 --- /dev/null +++ b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go @@ -0,0 +1,84 @@ +package tables + +import ( + "database/sql" + "fmt" +) + +func init() { + MigrationClient.AddMigration(Up_20240313143039, Down_20240313143039) +} + +func Up_20240313143039(tx *sql.Tx) error { + // create a new table to store user information that's persisted after + // users are deleted. + _, err := tx.Exec(` + CREATE TABLE IF NOT EXISTS user_persistent_info ( + -- id is an unique identifier for the row, independent from whatever is stored in 'users' + id int(10) unsigned NOT NULL AUTO_INCREMENT, + + -- user_id is a nullable FK reference to the users table + user_id int(10) unsigned DEFAULT NULL, + + -- user_name mirrors the users.name value + user_name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + + -- timestamps + created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + PRIMARY KEY (id), + FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL + ) + `) + if err != nil { + return fmt.Errorf("failed to add user_persistent_info table: %w", err) + } + + // migrate existing data. + _, err = tx.Exec(` + INSERT INTO user_persistent_info (user_id, user_name) + SELECT id, name + FROM users + `) + if err != nil { + return fmt.Errorf("failed to add user information into the user_persistent_info table: %w", err) + } + + tables := []string{ + "nano_commands", "windows_mdm_commands", + "mdm_apple_configuration_profiles", "mdm_windows_configuration_profiles", + } + + for _, t := range tables { + _, err := tx.Exec(fmt.Sprintf(` + ALTER TABLE`+" `%s` "+` + -- user_id references the user that created the entity. + -- it's NULL for rows created prior to this migration, + -- and also for entities that don't have an user + -- associated with it (eg: Fleet initiated actions) + ADD COLUMN user_persistent_info_id int(10) unsigned DEFAULT NULL, + + -- fleet_owned indicates if the entity is managed by Fleet. + ADD COLUMN fleet_owned tinyint(1) DEFAULT NULL + `, t)) + if err != nil { + return fmt.Errorf("failed to add user_id and fleet_owned to %s: %w", t, err) + } + + _, err = tx.Exec(fmt.Sprintf(` + ALTER TABLE`+" `%s` "+` + ADD CONSTRAINT`+" `fk_%s_user_info` "+` + FOREIGN KEY (user_persistent_info_id) REFERENCES user_persistent_info(id) + ON DELETE RESTRICT`, t, t)) + if err != nil { + return fmt.Errorf("failed to add user_id foreign key to %s: %w", t, err) + } + } + + return nil +} + +func Down_20240313143039(tx *sql.Tx) error { + return nil +} diff --git a/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go similarity index 60% rename from server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go rename to server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go index 65f5a748d7d..c9e03760b10 100644 --- a/server/datastore/mysql/migrations/tables/20240307162019_AddUserIDToCommands_test.go +++ b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go @@ -6,15 +6,18 @@ import ( "testing" "time" + "github.com/fleetdm/fleet/v4/server/ptr" "github.com/stretchr/testify/require" ) -func TestUp_20240307162019(t *testing.T) { +func TestUp_20240313143039(t *testing.T) { db := applyUpToPrev(t) dataStmts := ` INSERT INTO users VALUES - (1,'2023-07-21','2023-07-21',_binary '$2a$12$n6hwsD7OU2bAXX94551DQOBcNNhfsEPS3Y6JEuLDjsLNvry3lgJjy','0fF81xRQIriYzm5fdXouk3V3tRwsZJhV','admin','admin@email.com',0,'','',0,'admin',0); + (1,'2023-07-21','2023-07-21',_binary '$2a$12$n6hwsD7OU2bAXX94551DQOBcNNhfsEPS3Y6JEuLDjsLNvry3lgJjy','0fF81xRQIriYzm5fdXouk3V3tRwsZJhV','admin','admin@email.com',0,'','',0,'admin',0), + (2,'2023-07-21','2023-07-21',_binary '$2a$12$YxPPOd5TOmYhDlH5CfGIfuxBe4GJ78gbwvtxoBHTTw.symxpVcEZS','JPDLcBcv4j1QwIU+rHoRWBt3HVJC8hnf','User 1','user1@email.com',0,'','',0,NULL,0), + (3,'2023-07-21','2023-07-21',_binary '$2a$12$u3kuHl44jMojsols1NayLu0pPBwZvnWH6j6ZuDk6HsN4r0jgg7BRu','MoWlTEHH9zR7blcJ0l7/1c4EMnkh/dxq','User 2','user2@email.com',0,'','',0,NULL,0); INSERT INTO nano_commands (command_uuid, request_type, command, created_at, updated_at) @@ -48,6 +51,38 @@ INSERT INTO applyNext(t, db) + // check the newly created user_info tables + type userInfo struct { + ID uint `db:"id"` + UserID *uint `db:"user_id"` + UserName string `db:"user_name"` + } + var userInfos []userInfo + err = db.Select( + &userInfos, + `SELECT user_id, user_name, id FROM user_persistent_info`, + ) + require.NoError(t, err) + require.ElementsMatch(t, []userInfo{ + {ID: uint(1), UserID: ptr.Uint(1), UserName: "admin"}, + {ID: uint(2), UserID: ptr.Uint(2), UserName: "User 1"}, + {ID: uint(3), UserID: ptr.Uint(3), UserName: "User 2"}, + }, userInfos) + + // deleting an user doesn't delete the user info + _, err = db.Exec(`DELETE FROM users WHERE name = "User 1"`) + require.NoError(t, err) + + var info userInfo + err = db.Get( + &info, + `SELECT user_id, user_name, id FROM user_persistent_info WHERE user_name = "User 1"`, + ) + require.NoError(t, err) + require.Nil(t, info.UserID) + require.Equal(t, "User 1", info.UserName) + + // check the other tables for timestamps and references expectedDate, err := time.Parse("2006-01-02", "2023-07-21") require.NoError(t, err) @@ -57,11 +92,11 @@ INSERT INTO } type entity struct { - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` - UploadedAt time.Time `db:"uploaded_at"` - UserID *uint `db:"user_id"` - FleetOwned *bool `db:"fleet_owned"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` + UploadedAt time.Time `db:"uploaded_at"` + UserPersistentInfoID *uint `db:"user_persistent_info_id"` + FleetOwned *bool `db:"fleet_owned"` } for _, table := range tables { @@ -77,7 +112,7 @@ INSERT INTO err = db.Select( &entities, fmt.Sprintf(` - SELECT user_id, fleet_owned, created_at, %s + SELECT user_persistent_info_id, fleet_owned, created_at, %s FROM %s`, updatedTimestamp, table), ) return entities @@ -93,7 +128,7 @@ INSERT INTO require.EqualValues(t, expectedDate, entity.CreatedAt) require.EqualValues(t, wantUpdated, entity.UpdatedAt) require.EqualValues(t, wantUploaded, entity.UploadedAt) - require.Nil(t, entity.UserID) + require.Nil(t, entity.UserPersistentInfoID) require.Nil(t, entity.FleetOwned) } @@ -101,19 +136,19 @@ INSERT INTO require.NoError(t, err) entities = fetchEntities() for _, entity := range entities { - require.Nil(t, entity.UserID) + require.Nil(t, entity.UserPersistentInfoID) require.True(t, *entity.FleetOwned) } - _, err = db.Exec(fmt.Sprintf("UPDATE %s SET fleet_owned = 0, user_id = 1", table)) + _, err = db.Exec(fmt.Sprintf("UPDATE %s SET fleet_owned = 0, user_persistent_info_id = 1", table)) require.NoError(t, err) entities = fetchEntities() for _, entity := range entities { - require.Equal(t, uint(1), *entity.UserID) + require.Equal(t, uint(1), *entity.UserPersistentInfoID) require.False(t, *entity.FleetOwned) } - _, err = db.Exec(fmt.Sprintf("UPDATE %s SET user_id = 9", table)) + _, err = db.Exec(fmt.Sprintf("UPDATE %s SET user_persistent_info_id = 9", table)) require.ErrorContains(t, err, "foreign key constraint fails") } diff --git a/server/datastore/mysql/schema.sql b/server/datastore/mysql/schema.sql index fd69c1eef8b..3a7f7cdc782 100644 --- a/server/datastore/mysql/schema.sql +++ b/server/datastore/mysql/schema.sql @@ -1,9 +1,9 @@ /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `activities` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `user_id` int unsigned DEFAULT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `user_id` int(10) unsigned DEFAULT NULL, `user_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `activity_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `details` json DEFAULT NULL, @@ -14,71 +14,71 @@ CREATE TABLE `activities` ( KEY `activities_streamed_idx` (`streamed`), KEY `activities_created_at_idx` (`created_at`), CONSTRAINT `activities_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `aggregated_stats` ( - `id` bigint unsigned NOT NULL, + `id` bigint(20) unsigned NOT NULL, `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `json_value` json NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `global_stats` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`,`type`,`global_stats`), KEY `idx_aggregated_stats_updated_at` (`updated_at`), KEY `aggregated_stats_type_idx` (`type`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `app_config_json` ( - `id` int unsigned NOT NULL DEFAULT '1', + `id` int(10) unsigned NOT NULL DEFAULT '1', `json_value` json NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `app_config_json` VALUES (1,'{\"mdm\": {\"macos_setup\": {\"bootstrap_package\": null, \"macos_setup_assistant\": null, \"enable_end_user_authentication\": false}, \"macos_updates\": {\"deadline\": null, \"minimum_version\": null}, \"macos_settings\": {\"custom_settings\": null}, \"macos_migration\": {\"mode\": \"\", \"enable\": false, \"webhook_url\": \"\"}, \"windows_updates\": {\"deadline_days\": null, \"grace_period_days\": null}, \"windows_settings\": {\"custom_settings\": null}, \"apple_bm_default_team\": \"\", \"apple_bm_terms_expired\": false, \"enable_disk_encryption\": false, \"enabled_and_configured\": false, \"end_user_authentication\": {\"idp_name\": \"\", \"metadata\": \"\", \"entity_id\": \"\", \"issuer_uri\": \"\", \"metadata_url\": \"\"}, \"windows_enabled_and_configured\": false, \"apple_bm_enabled_and_configured\": false}, \"scripts\": null, \"features\": {\"enable_host_users\": true, \"enable_software_inventory\": false}, \"org_info\": {\"org_name\": \"\", \"contact_url\": \"\", \"org_logo_url\": \"\", \"org_logo_url_light_background\": \"\"}, \"integrations\": {\"jira\": null, \"zendesk\": null}, \"sso_settings\": {\"idp_name\": \"\", \"metadata\": \"\", \"entity_id\": \"\", \"enable_sso\": false, \"issuer_uri\": \"\", \"metadata_url\": \"\", \"idp_image_url\": \"\", \"enable_jit_role_sync\": false, \"enable_sso_idp_login\": false, \"enable_jit_provisioning\": false}, \"agent_options\": {\"config\": {\"options\": {\"logger_plugin\": \"tls\", \"pack_delimiter\": \"/\", \"logger_tls_period\": 10, \"distributed_plugin\": \"tls\", \"disable_distributed\": false, \"logger_tls_endpoint\": \"/api/osquery/log\", \"distributed_interval\": 10, \"distributed_tls_max_attempts\": 3}, \"decorators\": {\"load\": [\"SELECT uuid AS host_uuid FROM system_info;\", \"SELECT hostname AS hostname FROM system_info;\"]}}, \"overrides\": {}}, \"fleet_desktop\": {\"transparency_url\": \"\"}, \"smtp_settings\": {\"port\": 587, \"domain\": \"\", \"server\": \"\", \"password\": \"\", \"user_name\": \"\", \"configured\": false, \"enable_smtp\": false, \"enable_ssl_tls\": true, \"sender_address\": \"\", \"enable_start_tls\": true, \"verify_ssl_certs\": true, \"authentication_type\": \"0\", \"authentication_method\": \"0\"}, \"server_settings\": {\"server_url\": \"\", \"enable_analytics\": false, \"scripts_disabled\": false, \"deferred_save_host\": false, \"live_query_disabled\": false, \"query_reports_disabled\": false}, \"webhook_settings\": {\"interval\": \"0s\", \"host_status_webhook\": {\"days_count\": 0, \"destination_url\": \"\", \"host_percentage\": 0, \"enable_host_status_webhook\": false}, \"vulnerabilities_webhook\": {\"destination_url\": \"\", \"host_batch_size\": 0, \"enable_vulnerabilities_webhook\": false}, \"failing_policies_webhook\": {\"policy_ids\": null, \"destination_url\": \"\", \"host_batch_size\": 0, \"enable_failing_policies_webhook\": false}}, \"host_expiry_settings\": {\"host_expiry_window\": 0, \"host_expiry_enabled\": false}, \"vulnerability_settings\": {\"databases_path\": \"\"}}','2020-01-01 01:01:01','2020-01-01 01:01:01'); /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `carve_blocks` ( - `metadata_id` int unsigned NOT NULL, - `block_id` int NOT NULL, + `metadata_id` int(10) unsigned NOT NULL, + `block_id` int(11) NOT NULL, `data` longblob, PRIMARY KEY (`metadata_id`,`block_id`), CONSTRAINT `carve_blocks_ibfk_1` FOREIGN KEY (`metadata_id`) REFERENCES `carve_metadata` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `carve_metadata` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `block_count` int unsigned NOT NULL, - `block_size` int unsigned NOT NULL, - `carve_size` bigint unsigned NOT NULL, + `block_count` int(10) unsigned NOT NULL, + `block_size` int(10) unsigned NOT NULL, + `carve_size` bigint(20) unsigned NOT NULL, `carve_id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, `request_id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, `session_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `expired` tinyint DEFAULT '0', - `max_block` int DEFAULT '-1', + `expired` tinyint(4) DEFAULT '0', + `max_block` int(11) DEFAULT '-1', `error` text COLLATE utf8mb4_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `idx_session_id` (`session_id`), UNIQUE KEY `idx_name` (`name`), KEY `host_id` (`host_id`), CONSTRAINT `carve_metadata_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `hosts` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `cron_stats` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `instance` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `stats_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -87,70 +87,70 @@ CREATE TABLE `cron_stats` ( `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_cron_stats_name_created_at` (`name`,`created_at`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `cve_meta` ( `cve` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, `cvss_score` double DEFAULT NULL, `epss_probability` double DEFAULT NULL, `cisa_known_exploit` tinyint(1) DEFAULT NULL, `published` timestamp NULL DEFAULT NULL, - `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, + `description` text COLLATE utf8mb4_unicode_ci, PRIMARY KEY (`cve`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `distributed_query_campaign_targets` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `type` int DEFAULT NULL, - `distributed_query_campaign_id` int unsigned DEFAULT NULL, - `target_id` int unsigned DEFAULT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `type` int(11) DEFAULT NULL, + `distributed_query_campaign_id` int(10) unsigned DEFAULT NULL, + `target_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `distributed_query_campaigns` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `query_id` int unsigned DEFAULT NULL, - `status` int DEFAULT NULL, - `user_id` int unsigned DEFAULT NULL, + `query_id` int(10) unsigned DEFAULT NULL, + `status` int(11) DEFAULT NULL, + `user_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `email_changes` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `user_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, `token` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL, `new_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_unique_email_changes_token` (`token`) USING BTREE, KEY `fk_email_changes_users` (`user_id`), CONSTRAINT `fk_email_changes_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `enroll_secrets` ( `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `secret` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, - `team_id` int unsigned DEFAULT NULL, + `team_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`secret`), KEY `fk_enroll_secrets_team_id` (`team_id`), CONSTRAINT `enroll_secrets_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `eulas` ( - `id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL, `token` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `bytes` longblob, @@ -159,80 +159,80 @@ CREATE TABLE `eulas` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_activities` ( - `host_id` int unsigned NOT NULL, - `activity_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, + `activity_id` int(10) unsigned NOT NULL, PRIMARY KEY (`host_id`,`activity_id`), KEY `fk_host_activities_activity_id` (`activity_id`), CONSTRAINT `host_activities_ibfk_1` FOREIGN KEY (`activity_id`) REFERENCES `activities` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_additional` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `additional` json DEFAULT NULL, PRIMARY KEY (`host_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_batteries` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, `serial_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `cycle_count` int NOT NULL, + `cycle_count` int(10) NOT NULL, `health` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_host_batteries_host_id_serial_number` (`host_id`,`serial_number`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_dep_assignments` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `added_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `deleted_at` timestamp NULL DEFAULT NULL, - `profile_uuid` varchar(37) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `assign_profile_response` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `assign_profile_response` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `response_updated_at` timestamp NULL DEFAULT NULL, - `retry_job_id` int unsigned NOT NULL DEFAULT '0', + `retry_job_id` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`host_id`), KEY `idx_hdep_response` (`assign_profile_response`,`response_updated_at`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_device_auth` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`host_id`), UNIQUE KEY `idx_host_device_auth_token` (`token`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_disk_encryption_keys` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `base64_encrypted` text COLLATE utf8mb4_unicode_ci NOT NULL, `decryptable` tinyint(1) DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `reset_requested` tinyint(1) NOT NULL DEFAULT '0', - `client_error` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `client_error` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`host_id`), KEY `idx_host_disk_encryption_keys_decryptable` (`decryptable`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_disks` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `gigs_disk_space_available` decimal(10,2) NOT NULL DEFAULT '0.00', `percent_disk_space_available` decimal(10,2) NOT NULL DEFAULT '0.00', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -241,22 +241,22 @@ CREATE TABLE `host_disks` ( `gigs_total_disk_space` decimal(10,2) NOT NULL DEFAULT '0.00', PRIMARY KEY (`host_id`), KEY `idx_host_disks_gigs_disk_space_available` (`gigs_disk_space_available`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_display_names` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `display_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`host_id`), KEY `display_name` (`display_name`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_emails` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `source` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -264,37 +264,37 @@ CREATE TABLE `host_emails` ( PRIMARY KEY (`id`), KEY `idx_host_emails_host_id_email` (`host_id`,`email`), KEY `idx_host_emails_email` (`email`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_mdm` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `enrolled` tinyint(1) NOT NULL DEFAULT '0', `server_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `installed_from_dep` tinyint(1) NOT NULL DEFAULT '0', - `mdm_id` int unsigned DEFAULT NULL, + `mdm_id` int(10) unsigned DEFAULT NULL, `is_server` tinyint(1) DEFAULT NULL, - `fleet_enroll_ref` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `fleet_enroll_ref` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`host_id`), KEY `host_mdm_mdm_id_idx` (`mdm_id`), KEY `host_mdm_enrolled_installed_from_dep_idx` (`enrolled`,`installed_from_dep`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_mdm_actions` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `lock_ref` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `wipe_ref` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `unlock_pin` varchar(6) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `unlock_ref` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `fleet_platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `fleet_platform` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`host_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_mdm_apple_bootstrap_packages` ( `host_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -304,7 +304,7 @@ CREATE TABLE `host_mdm_apple_bootstrap_packages` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_mdm_apple_profiles` ( `profile_identifier` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `host_uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -314,17 +314,17 @@ CREATE TABLE `host_mdm_apple_profiles` ( `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `profile_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `checksum` binary(16) NOT NULL, - `retries` tinyint unsigned NOT NULL DEFAULT '0', - `profile_uuid` varchar(37) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `retries` tinyint(3) unsigned NOT NULL DEFAULT '0', + `profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`host_uuid`,`profile_uuid`), KEY `status` (`status`), KEY `operation_type` (`operation_type`), CONSTRAINT `host_mdm_apple_profiles_ibfk_1` FOREIGN KEY (`status`) REFERENCES `mdm_delivery_status` (`status`) ON UPDATE CASCADE, CONSTRAINT `host_mdm_apple_profiles_ibfk_2` FOREIGN KEY (`operation_type`) REFERENCES `mdm_operation_types` (`operation_type`) ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_mdm_windows_profiles` ( `host_uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `status` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, @@ -332,68 +332,68 @@ CREATE TABLE `host_mdm_windows_profiles` ( `detail` text COLLATE utf8mb4_unicode_ci, `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `profile_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `retries` tinyint unsigned NOT NULL DEFAULT '0', - `profile_uuid` varchar(37) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `retries` tinyint(3) unsigned NOT NULL DEFAULT '0', + `profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`host_uuid`,`profile_uuid`), KEY `status` (`status`), KEY `operation_type` (`operation_type`), CONSTRAINT `host_mdm_windows_profiles_ibfk_1` FOREIGN KEY (`status`) REFERENCES `mdm_delivery_status` (`status`) ON UPDATE CASCADE, CONSTRAINT `host_mdm_windows_profiles_ibfk_2` FOREIGN KEY (`operation_type`) REFERENCES `mdm_operation_types` (`operation_type`) ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_munki_info` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `deleted_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`host_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_munki_issues` ( - `host_id` int unsigned NOT NULL, - `munki_issue_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, + `munki_issue_id` int(10) unsigned NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`host_id`,`munki_issue_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_operating_system` ( - `host_id` int unsigned NOT NULL, - `os_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, + `os_id` int(10) unsigned NOT NULL, PRIMARY KEY (`host_id`), KEY `idx_host_operating_system_id` (`os_id`), CONSTRAINT `host_operating_system_ibfk_1` FOREIGN KEY (`os_id`) REFERENCES `operating_systems` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_orbit_info` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `version` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`host_id`), KEY `idx_host_orbit_info_version` (`version`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_script_results` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, `execution_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `script_contents` text COLLATE utf8mb4_unicode_ci NOT NULL, `output` text COLLATE utf8mb4_unicode_ci NOT NULL, - `runtime` int unsigned NOT NULL DEFAULT '0', - `exit_code` int DEFAULT NULL, + `runtime` int(10) unsigned NOT NULL DEFAULT '0', + `exit_code` int(10) DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `script_id` int unsigned DEFAULT NULL, - `user_id` int unsigned DEFAULT NULL, + `script_id` int(10) unsigned DEFAULT NULL, + `user_id` int(10) unsigned DEFAULT NULL, `sync_request` tinyint(1) NOT NULL DEFAULT '0', - `script_content_id` int unsigned DEFAULT NULL, + `script_content_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_host_script_results_execution_id` (`execution_id`), KEY `idx_host_script_results_host_exit_created` (`host_id`,`exit_code`,`created_at`), @@ -404,102 +404,102 @@ CREATE TABLE `host_script_results` ( CONSTRAINT `fk_host_script_results_script_id` FOREIGN KEY (`script_id`) REFERENCES `scripts` (`id`) ON DELETE SET NULL, CONSTRAINT `fk_host_script_results_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL, CONSTRAINT `host_script_results_ibfk_1` FOREIGN KEY (`script_content_id`) REFERENCES `script_contents` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_seen_times` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `seen_time` timestamp NULL DEFAULT NULL, PRIMARY KEY (`host_id`), KEY `idx_host_seen_times_seen_time` (`seen_time`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_software` ( - `host_id` int unsigned NOT NULL, - `software_id` bigint unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, + `software_id` bigint(20) unsigned NOT NULL, `last_opened_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`host_id`,`software_id`), KEY `host_software_software_fk` (`software_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_software_installed_paths` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, - `software_id` bigint unsigned NOT NULL, + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, + `software_id` bigint(20) unsigned NOT NULL, `installed_path` text COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `host_id_software_id_idx` (`host_id`,`software_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_updates` ( - `host_id` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `software_updated_at` timestamp NULL DEFAULT NULL, PRIMARY KEY (`host_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `host_users` ( - `host_id` int unsigned NOT NULL, - `uid` int unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, + `uid` int(10) unsigned NOT NULL, `username` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `groupname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `removed_at` timestamp NULL DEFAULT NULL, `user_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `shell` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '', PRIMARY KEY (`host_id`,`uid`,`username`), UNIQUE KEY `idx_uid_username` (`host_id`,`uid`,`username`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `hosts` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `osquery_host_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `osquery_host_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `detail_updated_at` timestamp NULL DEFAULT NULL, `node_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, - `hostname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `platform` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `osquery_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `os_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `build` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `platform_like` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `code_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `uptime` bigint NOT NULL DEFAULT '0', - `memory` bigint NOT NULL DEFAULT '0', - `cpu_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `cpu_subtype` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `cpu_brand` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `cpu_physical_cores` int NOT NULL DEFAULT '0', - `cpu_logical_cores` int NOT NULL DEFAULT '0', - `hardware_vendor` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `hardware_model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `hardware_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `hardware_serial` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `computer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `primary_ip_id` int unsigned DEFAULT NULL, - `distributed_interval` int DEFAULT '0', - `logger_tls_period` int DEFAULT '0', - `config_tls_refresh` int DEFAULT '0', - `primary_ip` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `primary_mac` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `hostname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `platform` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `osquery_version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `os_version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `build` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `platform_like` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `code_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `uptime` bigint(20) NOT NULL DEFAULT '0', + `memory` bigint(20) NOT NULL DEFAULT '0', + `cpu_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `cpu_subtype` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `cpu_brand` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `cpu_physical_cores` int(11) NOT NULL DEFAULT '0', + `cpu_logical_cores` int(11) NOT NULL DEFAULT '0', + `hardware_vendor` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `hardware_model` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `hardware_version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `hardware_serial` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `computer_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `primary_ip_id` int(10) unsigned DEFAULT NULL, + `distributed_interval` int(11) DEFAULT '0', + `logger_tls_period` int(11) DEFAULT '0', + `config_tls_refresh` int(11) DEFAULT '0', + `primary_ip` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `primary_mac` varchar(17) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `label_updated_at` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00', `last_enrolled_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `refetch_requested` tinyint(1) NOT NULL DEFAULT '0', - `team_id` int unsigned DEFAULT NULL, + `team_id` int(10) unsigned DEFAULT NULL, `policy_updated_at` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00', - `public_ip` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `public_ip` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `orbit_node_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, `refetch_critical_queries_until` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), @@ -512,27 +512,27 @@ CREATE TABLE `hosts` ( FULLTEXT KEY `host_ip_mac_search` (`primary_ip`,`primary_mac`), FULLTEXT KEY `hosts_search` (`hostname`,`uuid`,`computer_name`), CONSTRAINT `hosts_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE SET NULL -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `invite_teams` ( - `invite_id` int unsigned NOT NULL, - `team_id` int unsigned NOT NULL, + `invite_id` int(10) unsigned NOT NULL, + `team_id` int(10) unsigned NOT NULL, `role` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`invite_id`,`team_id`), KEY `fk_team_id` (`team_id`), CONSTRAINT `invite_teams_ibfk_1` FOREIGN KEY (`invite_id`) REFERENCES `invites` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invite_teams_ibfk_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `invites` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `invited_by` int unsigned NOT NULL, + `invited_by` int(10) unsigned NOT NULL, `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, @@ -542,66 +542,66 @@ CREATE TABLE `invites` ( PRIMARY KEY (`id`), UNIQUE KEY `idx_invite_unique_email` (`email`), UNIQUE KEY `idx_invite_unique_key` (`token`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `jobs` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `args` json DEFAULT NULL, `state` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `retries` int NOT NULL DEFAULT '0', + `retries` int(11) NOT NULL DEFAULT '0', `error` text COLLATE utf8mb4_unicode_ci, `not_before` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `label_membership` ( - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `label_id` int unsigned NOT NULL, - `host_id` int unsigned NOT NULL, + `label_id` int(10) unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, PRIMARY KEY (`host_id`,`label_id`), KEY `idx_lm_label_id` (`label_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `labels` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `query` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, `platform` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `label_type` int unsigned NOT NULL DEFAULT '1', - `label_membership_type` int unsigned NOT NULL DEFAULT '0', + `label_type` int(10) unsigned NOT NULL DEFAULT '1', + `label_membership_type` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `idx_label_unique_name` (`name`), FULLTEXT KEY `labels_search` (`name`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `locks` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `owner` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `expires_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `expires_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_name` (`name`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_apple_bootstrap_packages` ( - `team_id` int unsigned NOT NULL, + `team_id` int(10) unsigned NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `sha256` binary(32) NOT NULL, `bytes` longblob, @@ -610,38 +610,38 @@ CREATE TABLE `mdm_apple_bootstrap_packages` ( `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`team_id`), UNIQUE KEY `idx_token` (`token`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_apple_configuration_profiles` ( - `profile_id` int unsigned NOT NULL AUTO_INCREMENT, - `team_id` int unsigned NOT NULL DEFAULT '0', + `profile_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `team_id` int(10) unsigned NOT NULL DEFAULT '0', `identifier` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `mobileconfig` blob NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `uploaded_at` timestamp NULL DEFAULT NULL, `checksum` binary(16) NOT NULL, - `profile_uuid` varchar(37) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `user_id` int unsigned DEFAULT NULL, + `profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `user_persistent_info_id` int(10) unsigned DEFAULT NULL, `fleet_owned` tinyint(1) DEFAULT NULL, PRIMARY KEY (`profile_uuid`), UNIQUE KEY `idx_mdm_apple_config_prof_team_identifier` (`team_id`,`identifier`), UNIQUE KEY `idx_mdm_apple_config_prof_team_name` (`team_id`,`name`), UNIQUE KEY `idx_mdm_apple_config_prof_id` (`profile_id`), - KEY `fk_mdm_apple_configuration_profiles_users` (`user_id`), - CONSTRAINT `fk_mdm_apple_configuration_profiles_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + KEY `fk_mdm_apple_configuration_profiles_user_info` (`user_persistent_info_id`), + CONSTRAINT `fk_mdm_apple_configuration_profiles_user_info` FOREIGN KEY (`user_persistent_info_id`) REFERENCES `user_persistent_info` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_apple_default_setup_assistants` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `team_id` int unsigned DEFAULT NULL, - `global_or_team_id` int unsigned NOT NULL DEFAULT '0', + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `team_id` int(10) unsigned DEFAULT NULL, + `global_or_team_id` int(10) unsigned NOT NULL DEFAULT '0', `profile_uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_mdm_default_setup_assistant_global_or_team_id` (`global_or_team_id`), @@ -650,56 +650,56 @@ CREATE TABLE `mdm_apple_default_setup_assistants` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_apple_enrollment_profiles` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `token` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `type` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'automatic', `dep_profile` json DEFAULT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_type` (`type`), UNIQUE KEY `idx_token` (`token`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_apple_installers` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `size` bigint NOT NULL, + `size` bigint(20) NOT NULL, `manifest` text COLLATE utf8mb4_unicode_ci NOT NULL, `installer` longblob, `url_token` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_apple_setup_assistants` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `team_id` int unsigned DEFAULT NULL, - `global_or_team_id` int unsigned NOT NULL DEFAULT '0', + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `team_id` int(10) unsigned DEFAULT NULL, + `global_or_team_id` int(10) unsigned NOT NULL DEFAULT '0', `name` text COLLATE utf8mb4_unicode_ci NOT NULL, `profile` json NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `profile_uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `idx_mdm_setup_assistant_global_or_team_id` (`global_or_team_id`), KEY `fk_mdm_setup_assistant_team_id` (`team_id`), CONSTRAINT `mdm_apple_setup_assistants_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_configuration_profile_labels` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `apple_profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `windows_profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `label_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `label_id` int unsigned DEFAULT NULL, + `label_id` int(10) unsigned DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -708,60 +708,59 @@ CREATE TABLE `mdm_configuration_profile_labels` ( KEY `label_id` (`label_id`), CONSTRAINT `mdm_configuration_profile_labels_ibfk_1` FOREIGN KEY (`apple_profile_uuid`) REFERENCES `mdm_apple_configuration_profiles` (`profile_uuid`) ON DELETE CASCADE, CONSTRAINT `mdm_configuration_profile_labels_ibfk_2` FOREIGN KEY (`windows_profile_uuid`) REFERENCES `mdm_windows_configuration_profiles` (`profile_uuid`) ON DELETE CASCADE, - CONSTRAINT `mdm_configuration_profile_labels_ibfk_3` FOREIGN KEY (`label_id`) REFERENCES `labels` (`id`) ON DELETE SET NULL, - CONSTRAINT `ck_mdm_configuration_profile_labels_apple_or_windows` CHECK (((`apple_profile_uuid` is null) <> (`windows_profile_uuid` is null))) + CONSTRAINT `mdm_configuration_profile_labels_ibfk_3` FOREIGN KEY (`label_id`) REFERENCES `labels` (`id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_delivery_status` ( `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`status`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `mdm_delivery_status` VALUES ('failed'),('pending'),('verified'),('verifying'); /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_idp_accounts` ( `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `username` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `fullname` varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`uuid`), UNIQUE KEY `unique_idp_email` (`email`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_operation_types` ( `operation_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`operation_type`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `mdm_operation_types` VALUES ('install'),('remove'); /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_windows_configuration_profiles` ( - `team_id` int unsigned NOT NULL DEFAULT '0', + `team_id` int(10) unsigned NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `syncml` mediumblob NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `uploaded_at` timestamp NULL DEFAULT NULL, - `profile_uuid` varchar(37) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `user_id` int unsigned DEFAULT NULL, + `profile_uuid` varchar(37) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `user_persistent_info_id` int(10) unsigned DEFAULT NULL, `fleet_owned` tinyint(1) DEFAULT NULL, PRIMARY KEY (`profile_uuid`), UNIQUE KEY `idx_mdm_windows_configuration_profiles_team_id_name` (`team_id`,`name`), - KEY `fk_mdm_windows_configuration_profiles_users` (`user_id`), - CONSTRAINT `fk_mdm_windows_configuration_profiles_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + KEY `fk_mdm_windows_configuration_profiles_user_info` (`user_persistent_info_id`), + CONSTRAINT `fk_mdm_windows_configuration_profiles_user_info` FOREIGN KEY (`user_persistent_info_id`) REFERENCES `user_persistent_info` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mdm_windows_enrollments` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mdm_device_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `mdm_hardware_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `device_state` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -774,103 +773,96 @@ CREATE TABLE `mdm_windows_enrollments` ( `not_in_oobe` tinyint(1) NOT NULL DEFAULT '0', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `host_uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `host_uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `idx_type` (`mdm_hardware_id`), KEY `idx_mdm_windows_enrollments_mdm_device_id` (`mdm_device_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `migration_status_tables` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT, - `version_id` bigint NOT NULL, + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `version_id` bigint(20) NOT NULL, `is_applied` tinyint(1) NOT NULL, `tstamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=257 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=257 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO `migration_status_tables` VALUES (1,0,1,'2020-01-01 01:01:01'),(2,20161118193812,1,'2020-01-01 01:01:01'),(3,20161118211713,1,'2020-01-01 01:01:01'),(4,20161118212436,1,'2020-01-01 01:01:01'),(5,20161118212515,1,'2020-01-01 01:01:01'),(6,20161118212528,1,'2020-01-01 01:01:01'),(7,20161118212538,1,'2020-01-01 01:01:01'),(8,20161118212549,1,'2020-01-01 01:01:01'),(9,20161118212557,1,'2020-01-01 01:01:01'),(10,20161118212604,1,'2020-01-01 01:01:01'),(11,20161118212613,1,'2020-01-01 01:01:01'),(12,20161118212621,1,'2020-01-01 01:01:01'),(13,20161118212630,1,'2020-01-01 01:01:01'),(14,20161118212641,1,'2020-01-01 01:01:01'),(15,20161118212649,1,'2020-01-01 01:01:01'),(16,20161118212656,1,'2020-01-01 01:01:01'),(17,20161118212758,1,'2020-01-01 01:01:01'),(18,20161128234849,1,'2020-01-01 01:01:01'),(19,20161230162221,1,'2020-01-01 01:01:01'),(20,20170104113816,1,'2020-01-01 01:01:01'),(21,20170105151732,1,'2020-01-01 01:01:01'),(22,20170108191242,1,'2020-01-01 01:01:01'),(23,20170109094020,1,'2020-01-01 01:01:01'),(24,20170109130438,1,'2020-01-01 01:01:01'),(25,20170110202752,1,'2020-01-01 01:01:01'),(26,20170111133013,1,'2020-01-01 01:01:01'),(27,20170117025759,1,'2020-01-01 01:01:01'),(28,20170118191001,1,'2020-01-01 01:01:01'),(29,20170119234632,1,'2020-01-01 01:01:01'),(30,20170124230432,1,'2020-01-01 01:01:01'),(31,20170127014618,1,'2020-01-01 01:01:01'),(32,20170131232841,1,'2020-01-01 01:01:01'),(33,20170223094154,1,'2020-01-01 01:01:01'),(34,20170306075207,1,'2020-01-01 01:01:01'),(35,20170309100733,1,'2020-01-01 01:01:01'),(36,20170331111922,1,'2020-01-01 01:01:01'),(37,20170502143928,1,'2020-01-01 01:01:01'),(38,20170504130602,1,'2020-01-01 01:01:01'),(39,20170509132100,1,'2020-01-01 01:01:01'),(40,20170519105647,1,'2020-01-01 01:01:01'),(41,20170519105648,1,'2020-01-01 01:01:01'),(42,20170831234300,1,'2020-01-01 01:01:01'),(43,20170831234301,1,'2020-01-01 01:01:01'),(44,20170831234303,1,'2020-01-01 01:01:01'),(45,20171116163618,1,'2020-01-01 01:01:01'),(46,20171219164727,1,'2020-01-01 01:01:01'),(47,20180620164811,1,'2020-01-01 01:01:01'),(48,20180620175054,1,'2020-01-01 01:01:01'),(49,20180620175055,1,'2020-01-01 01:01:01'),(50,20191010101639,1,'2020-01-01 01:01:01'),(51,20191010155147,1,'2020-01-01 01:01:01'),(52,20191220130734,1,'2020-01-01 01:01:01'),(53,20200311140000,1,'2020-01-01 01:01:01'),(54,20200405120000,1,'2020-01-01 01:01:01'),(55,20200407120000,1,'2020-01-01 01:01:01'),(56,20200420120000,1,'2020-01-01 01:01:01'),(57,20200504120000,1,'2020-01-01 01:01:01'),(58,20200512120000,1,'2020-01-01 01:01:01'),(59,20200707120000,1,'2020-01-01 01:01:01'),(60,20201011162341,1,'2020-01-01 01:01:01'),(61,20201021104586,1,'2020-01-01 01:01:01'),(62,20201102112520,1,'2020-01-01 01:01:01'),(63,20201208121729,1,'2020-01-01 01:01:01'),(64,20201215091637,1,'2020-01-01 01:01:01'),(65,20210119174155,1,'2020-01-01 01:01:01'),(66,20210326182902,1,'2020-01-01 01:01:01'),(67,20210421112652,1,'2020-01-01 01:01:01'),(68,20210506095025,1,'2020-01-01 01:01:01'),(69,20210513115729,1,'2020-01-01 01:01:01'),(70,20210526113559,1,'2020-01-01 01:01:01'),(71,20210601000001,1,'2020-01-01 01:01:01'),(72,20210601000002,1,'2020-01-01 01:01:01'),(73,20210601000003,1,'2020-01-01 01:01:01'),(74,20210601000004,1,'2020-01-01 01:01:01'),(75,20210601000005,1,'2020-01-01 01:01:01'),(76,20210601000006,1,'2020-01-01 01:01:01'),(77,20210601000007,1,'2020-01-01 01:01:01'),(78,20210601000008,1,'2020-01-01 01:01:01'),(79,20210606151329,1,'2020-01-01 01:01:01'),(80,20210616163757,1,'2020-01-01 01:01:01'),(81,20210617174723,1,'2020-01-01 01:01:01'),(82,20210622160235,1,'2020-01-01 01:01:01'),(83,20210623100031,1,'2020-01-01 01:01:01'),(84,20210623133615,1,'2020-01-01 01:01:01'),(85,20210708143152,1,'2020-01-01 01:01:01'),(86,20210709124443,1,'2020-01-01 01:01:01'),(87,20210712155608,1,'2020-01-01 01:01:01'),(88,20210714102108,1,'2020-01-01 01:01:01'),(89,20210719153709,1,'2020-01-01 01:01:01'),(90,20210721171531,1,'2020-01-01 01:01:01'),(91,20210723135713,1,'2020-01-01 01:01:01'),(92,20210802135933,1,'2020-01-01 01:01:01'),(93,20210806112844,1,'2020-01-01 01:01:01'),(94,20210810095603,1,'2020-01-01 01:01:01'),(95,20210811150223,1,'2020-01-01 01:01:01'),(96,20210818151827,1,'2020-01-01 01:01:01'),(97,20210818151828,1,'2020-01-01 01:01:01'),(98,20210818182258,1,'2020-01-01 01:01:01'),(99,20210819131107,1,'2020-01-01 01:01:01'),(100,20210819143446,1,'2020-01-01 01:01:01'),(101,20210903132338,1,'2020-01-01 01:01:01'),(102,20210915144307,1,'2020-01-01 01:01:01'),(103,20210920155130,1,'2020-01-01 01:01:01'),(104,20210927143115,1,'2020-01-01 01:01:01'),(105,20210927143116,1,'2020-01-01 01:01:01'),(106,20211013133706,1,'2020-01-01 01:01:01'),(107,20211013133707,1,'2020-01-01 01:01:01'),(108,20211102135149,1,'2020-01-01 01:01:01'),(109,20211109121546,1,'2020-01-01 01:01:01'),(110,20211110163320,1,'2020-01-01 01:01:01'),(111,20211116184029,1,'2020-01-01 01:01:01'),(112,20211116184030,1,'2020-01-01 01:01:01'),(113,20211202092042,1,'2020-01-01 01:01:01'),(114,20211202181033,1,'2020-01-01 01:01:01'),(115,20211207161856,1,'2020-01-01 01:01:01'),(116,20211216131203,1,'2020-01-01 01:01:01'),(117,20211221110132,1,'2020-01-01 01:01:01'),(118,20220107155700,1,'2020-01-01 01:01:01'),(119,20220125105650,1,'2020-01-01 01:01:01'),(120,20220201084510,1,'2020-01-01 01:01:01'),(121,20220208144830,1,'2020-01-01 01:01:01'),(122,20220208144831,1,'2020-01-01 01:01:01'),(123,20220215152203,1,'2020-01-01 01:01:01'),(124,20220223113157,1,'2020-01-01 01:01:01'),(125,20220307104655,1,'2020-01-01 01:01:01'),(126,20220309133956,1,'2020-01-01 01:01:01'),(127,20220316155700,1,'2020-01-01 01:01:01'),(128,20220323152301,1,'2020-01-01 01:01:01'),(129,20220330100659,1,'2020-01-01 01:01:01'),(130,20220404091216,1,'2020-01-01 01:01:01'),(131,20220419140750,1,'2020-01-01 01:01:01'),(132,20220428140039,1,'2020-01-01 01:01:01'),(133,20220503134048,1,'2020-01-01 01:01:01'),(134,20220524102918,1,'2020-01-01 01:01:01'),(135,20220526123327,1,'2020-01-01 01:01:01'),(136,20220526123328,1,'2020-01-01 01:01:01'),(137,20220526123329,1,'2020-01-01 01:01:01'),(138,20220608113128,1,'2020-01-01 01:01:01'),(139,20220627104817,1,'2020-01-01 01:01:01'),(140,20220704101843,1,'2020-01-01 01:01:01'),(141,20220708095046,1,'2020-01-01 01:01:01'),(142,20220713091130,1,'2020-01-01 01:01:01'),(143,20220802135510,1,'2020-01-01 01:01:01'),(144,20220818101352,1,'2020-01-01 01:01:01'),(145,20220822161445,1,'2020-01-01 01:01:01'),(146,20220831100036,1,'2020-01-01 01:01:01'),(147,20220831100151,1,'2020-01-01 01:01:01'),(148,20220908181826,1,'2020-01-01 01:01:01'),(149,20220914154915,1,'2020-01-01 01:01:01'),(150,20220915165115,1,'2020-01-01 01:01:01'),(151,20220915165116,1,'2020-01-01 01:01:01'),(152,20220928100158,1,'2020-01-01 01:01:01'),(153,20221014084130,1,'2020-01-01 01:01:01'),(154,20221027085019,1,'2020-01-01 01:01:01'),(155,20221101103952,1,'2020-01-01 01:01:01'),(156,20221104144401,1,'2020-01-01 01:01:01'),(157,20221109100749,1,'2020-01-01 01:01:01'),(158,20221115104546,1,'2020-01-01 01:01:01'),(159,20221130114928,1,'2020-01-01 01:01:01'),(160,20221205112142,1,'2020-01-01 01:01:01'),(161,20221216115820,1,'2020-01-01 01:01:01'),(162,20221220195934,1,'2020-01-01 01:01:01'),(163,20221220195935,1,'2020-01-01 01:01:01'),(164,20221223174807,1,'2020-01-01 01:01:01'),(165,20221227163855,1,'2020-01-01 01:01:01'),(166,20221227163856,1,'2020-01-01 01:01:01'),(167,20230202224725,1,'2020-01-01 01:01:01'),(168,20230206163608,1,'2020-01-01 01:01:01'),(169,20230214131519,1,'2020-01-01 01:01:01'),(170,20230303135738,1,'2020-01-01 01:01:01'),(171,20230313135301,1,'2020-01-01 01:01:01'),(172,20230313141819,1,'2020-01-01 01:01:01'),(173,20230315104937,1,'2020-01-01 01:01:01'),(174,20230317173844,1,'2020-01-01 01:01:01'),(175,20230320133602,1,'2020-01-01 01:01:01'),(176,20230330100011,1,'2020-01-01 01:01:01'),(177,20230330134823,1,'2020-01-01 01:01:01'),(178,20230405232025,1,'2020-01-01 01:01:01'),(179,20230408084104,1,'2020-01-01 01:01:01'),(180,20230411102858,1,'2020-01-01 01:01:01'),(181,20230421155932,1,'2020-01-01 01:01:01'),(182,20230425082126,1,'2020-01-01 01:01:01'),(183,20230425105727,1,'2020-01-01 01:01:01'),(184,20230501154913,1,'2020-01-01 01:01:01'),(185,20230503101418,1,'2020-01-01 01:01:01'),(186,20230515144206,1,'2020-01-01 01:01:01'),(187,20230517140952,1,'2020-01-01 01:01:01'),(188,20230517152807,1,'2020-01-01 01:01:01'),(189,20230518114155,1,'2020-01-01 01:01:01'),(190,20230520153236,1,'2020-01-01 01:01:01'),(191,20230525151159,1,'2020-01-01 01:01:01'),(192,20230530122103,1,'2020-01-01 01:01:01'),(193,20230602111827,1,'2020-01-01 01:01:01'),(194,20230608103123,1,'2020-01-01 01:01:01'),(195,20230629140529,1,'2020-01-01 01:01:01'),(196,20230629140530,1,'2020-01-01 01:01:01'),(197,20230711144622,1,'2020-01-01 01:01:01'),(198,20230721135421,1,'2020-01-01 01:01:01'),(199,20230721161508,1,'2020-01-01 01:01:01'),(200,20230726115701,1,'2020-01-01 01:01:01'),(201,20230807100822,1,'2020-01-01 01:01:01'),(202,20230814150442,1,'2020-01-01 01:01:01'),(203,20230823122728,1,'2020-01-01 01:01:01'),(204,20230906152143,1,'2020-01-01 01:01:01'),(205,20230911163618,1,'2020-01-01 01:01:01'),(206,20230912101759,1,'2020-01-01 01:01:01'),(207,20230915101341,1,'2020-01-01 01:01:01'),(208,20230918132351,1,'2020-01-01 01:01:01'),(209,20231004144339,1,'2020-01-01 01:01:01'),(210,20231009094541,1,'2020-01-01 01:01:01'),(211,20231009094542,1,'2020-01-01 01:01:01'),(212,20231009094543,1,'2020-01-01 01:01:01'),(213,20231009094544,1,'2020-01-01 01:01:01'),(214,20231016091915,1,'2020-01-01 01:01:01'),(215,20231024174135,1,'2020-01-01 01:01:01'),(216,20231025120016,1,'2020-01-01 01:01:01'),(217,20231025160156,1,'2020-01-01 01:01:01'),(218,20231031165350,1,'2020-01-01 01:01:01'),(219,20231106144110,1,'2020-01-01 01:01:01'),(220,20231107130934,1,'2020-01-01 01:01:01'),(221,20231109115838,1,'2020-01-01 01:01:01'),(222,20231121054530,1,'2020-01-01 01:01:01'),(223,20231122101320,1,'2020-01-01 01:01:01'),(224,20231130132828,1,'2020-01-01 01:01:01'),(225,20231130132931,1,'2020-01-01 01:01:01'),(226,20231204155427,1,'2020-01-01 01:01:01'),(227,20231206142340,1,'2020-01-01 01:01:01'),(228,20231207102320,1,'2020-01-01 01:01:01'),(229,20231207102321,1,'2020-01-01 01:01:01'),(230,20231207133731,1,'2020-01-01 01:01:01'),(231,20231212094238,1,'2020-01-01 01:01:01'),(232,20231212095734,1,'2020-01-01 01:01:01'),(233,20231212161121,1,'2020-01-01 01:01:01'),(234,20231215122713,1,'2020-01-01 01:01:01'),(235,20231219143041,1,'2020-01-01 01:01:01'),(236,20231224070653,1,'2020-01-01 01:01:01'),(237,20240110134315,1,'2020-01-01 01:01:01'),(238,20240119091637,1,'2020-01-01 01:01:01'),(239,20240126020642,1,'2020-01-01 01:01:01'),(240,20240126020643,1,'2020-01-01 01:01:01'),(241,20240129162819,1,'2020-01-01 01:01:01'),(242,20240130115133,1,'2020-01-01 01:01:01'),(243,20240131083822,1,'2020-01-01 01:01:01'),(244,20240205095928,1,'2020-01-01 01:01:01'),(245,20240205121956,1,'2020-01-01 01:01:01'),(246,20240209110212,1,'2020-01-01 01:01:01'),(247,20240212111533,1,'2020-01-01 01:01:01'),(248,20240221112844,1,'2020-01-01 01:01:01'),(249,20240222073518,1,'2020-01-01 01:01:01'),(250,20240222135115,1,'2020-01-01 01:01:01'),(251,20240226082255,1,'2020-01-01 01:01:01'),(252,20240228082706,1,'2020-01-01 01:01:01'),(253,20240301173035,1,'2020-01-01 01:01:01'),(254,20240302111134,1,'2020-01-01 01:01:01'),(255,20240307162019,1,'2020-01-01 01:01:01'),(256,20240312103753,1,'2020-01-01 01:01:01'); +INSERT INTO `migration_status_tables` VALUES (1,0,1,'2020-01-01 01:01:01'),(2,20161118193812,1,'2020-01-01 01:01:01'),(3,20161118211713,1,'2020-01-01 01:01:01'),(4,20161118212436,1,'2020-01-01 01:01:01'),(5,20161118212515,1,'2020-01-01 01:01:01'),(6,20161118212528,1,'2020-01-01 01:01:01'),(7,20161118212538,1,'2020-01-01 01:01:01'),(8,20161118212549,1,'2020-01-01 01:01:01'),(9,20161118212557,1,'2020-01-01 01:01:01'),(10,20161118212604,1,'2020-01-01 01:01:01'),(11,20161118212613,1,'2020-01-01 01:01:01'),(12,20161118212621,1,'2020-01-01 01:01:01'),(13,20161118212630,1,'2020-01-01 01:01:01'),(14,20161118212641,1,'2020-01-01 01:01:01'),(15,20161118212649,1,'2020-01-01 01:01:01'),(16,20161118212656,1,'2020-01-01 01:01:01'),(17,20161118212758,1,'2020-01-01 01:01:01'),(18,20161128234849,1,'2020-01-01 01:01:01'),(19,20161230162221,1,'2020-01-01 01:01:01'),(20,20170104113816,1,'2020-01-01 01:01:01'),(21,20170105151732,1,'2020-01-01 01:01:01'),(22,20170108191242,1,'2020-01-01 01:01:01'),(23,20170109094020,1,'2020-01-01 01:01:01'),(24,20170109130438,1,'2020-01-01 01:01:01'),(25,20170110202752,1,'2020-01-01 01:01:01'),(26,20170111133013,1,'2020-01-01 01:01:01'),(27,20170117025759,1,'2020-01-01 01:01:01'),(28,20170118191001,1,'2020-01-01 01:01:01'),(29,20170119234632,1,'2020-01-01 01:01:01'),(30,20170124230432,1,'2020-01-01 01:01:01'),(31,20170127014618,1,'2020-01-01 01:01:01'),(32,20170131232841,1,'2020-01-01 01:01:01'),(33,20170223094154,1,'2020-01-01 01:01:01'),(34,20170306075207,1,'2020-01-01 01:01:01'),(35,20170309100733,1,'2020-01-01 01:01:01'),(36,20170331111922,1,'2020-01-01 01:01:01'),(37,20170502143928,1,'2020-01-01 01:01:01'),(38,20170504130602,1,'2020-01-01 01:01:01'),(39,20170509132100,1,'2020-01-01 01:01:01'),(40,20170519105647,1,'2020-01-01 01:01:01'),(41,20170519105648,1,'2020-01-01 01:01:01'),(42,20170831234300,1,'2020-01-01 01:01:01'),(43,20170831234301,1,'2020-01-01 01:01:01'),(44,20170831234303,1,'2020-01-01 01:01:01'),(45,20171116163618,1,'2020-01-01 01:01:01'),(46,20171219164727,1,'2020-01-01 01:01:01'),(47,20180620164811,1,'2020-01-01 01:01:01'),(48,20180620175054,1,'2020-01-01 01:01:01'),(49,20180620175055,1,'2020-01-01 01:01:01'),(50,20191010101639,1,'2020-01-01 01:01:01'),(51,20191010155147,1,'2020-01-01 01:01:01'),(52,20191220130734,1,'2020-01-01 01:01:01'),(53,20200311140000,1,'2020-01-01 01:01:01'),(54,20200405120000,1,'2020-01-01 01:01:01'),(55,20200407120000,1,'2020-01-01 01:01:01'),(56,20200420120000,1,'2020-01-01 01:01:01'),(57,20200504120000,1,'2020-01-01 01:01:01'),(58,20200512120000,1,'2020-01-01 01:01:01'),(59,20200707120000,1,'2020-01-01 01:01:01'),(60,20201011162341,1,'2020-01-01 01:01:01'),(61,20201021104586,1,'2020-01-01 01:01:01'),(62,20201102112520,1,'2020-01-01 01:01:01'),(63,20201208121729,1,'2020-01-01 01:01:01'),(64,20201215091637,1,'2020-01-01 01:01:01'),(65,20210119174155,1,'2020-01-01 01:01:01'),(66,20210326182902,1,'2020-01-01 01:01:01'),(67,20210421112652,1,'2020-01-01 01:01:01'),(68,20210506095025,1,'2020-01-01 01:01:01'),(69,20210513115729,1,'2020-01-01 01:01:01'),(70,20210526113559,1,'2020-01-01 01:01:01'),(71,20210601000001,1,'2020-01-01 01:01:01'),(72,20210601000002,1,'2020-01-01 01:01:01'),(73,20210601000003,1,'2020-01-01 01:01:01'),(74,20210601000004,1,'2020-01-01 01:01:01'),(75,20210601000005,1,'2020-01-01 01:01:01'),(76,20210601000006,1,'2020-01-01 01:01:01'),(77,20210601000007,1,'2020-01-01 01:01:01'),(78,20210601000008,1,'2020-01-01 01:01:01'),(79,20210606151329,1,'2020-01-01 01:01:01'),(80,20210616163757,1,'2020-01-01 01:01:01'),(81,20210617174723,1,'2020-01-01 01:01:01'),(82,20210622160235,1,'2020-01-01 01:01:01'),(83,20210623100031,1,'2020-01-01 01:01:01'),(84,20210623133615,1,'2020-01-01 01:01:01'),(85,20210708143152,1,'2020-01-01 01:01:01'),(86,20210709124443,1,'2020-01-01 01:01:01'),(87,20210712155608,1,'2020-01-01 01:01:01'),(88,20210714102108,1,'2020-01-01 01:01:01'),(89,20210719153709,1,'2020-01-01 01:01:01'),(90,20210721171531,1,'2020-01-01 01:01:01'),(91,20210723135713,1,'2020-01-01 01:01:01'),(92,20210802135933,1,'2020-01-01 01:01:01'),(93,20210806112844,1,'2020-01-01 01:01:01'),(94,20210810095603,1,'2020-01-01 01:01:01'),(95,20210811150223,1,'2020-01-01 01:01:01'),(96,20210818151827,1,'2020-01-01 01:01:01'),(97,20210818151828,1,'2020-01-01 01:01:01'),(98,20210818182258,1,'2020-01-01 01:01:01'),(99,20210819131107,1,'2020-01-01 01:01:01'),(100,20210819143446,1,'2020-01-01 01:01:01'),(101,20210903132338,1,'2020-01-01 01:01:01'),(102,20210915144307,1,'2020-01-01 01:01:01'),(103,20210920155130,1,'2020-01-01 01:01:01'),(104,20210927143115,1,'2020-01-01 01:01:01'),(105,20210927143116,1,'2020-01-01 01:01:01'),(106,20211013133706,1,'2020-01-01 01:01:01'),(107,20211013133707,1,'2020-01-01 01:01:01'),(108,20211102135149,1,'2020-01-01 01:01:01'),(109,20211109121546,1,'2020-01-01 01:01:01'),(110,20211110163320,1,'2020-01-01 01:01:01'),(111,20211116184029,1,'2020-01-01 01:01:01'),(112,20211116184030,1,'2020-01-01 01:01:01'),(113,20211202092042,1,'2020-01-01 01:01:01'),(114,20211202181033,1,'2020-01-01 01:01:01'),(115,20211207161856,1,'2020-01-01 01:01:01'),(116,20211216131203,1,'2020-01-01 01:01:01'),(117,20211221110132,1,'2020-01-01 01:01:01'),(118,20220107155700,1,'2020-01-01 01:01:01'),(119,20220125105650,1,'2020-01-01 01:01:01'),(120,20220201084510,1,'2020-01-01 01:01:01'),(121,20220208144830,1,'2020-01-01 01:01:01'),(122,20220208144831,1,'2020-01-01 01:01:01'),(123,20220215152203,1,'2020-01-01 01:01:01'),(124,20220223113157,1,'2020-01-01 01:01:01'),(125,20220307104655,1,'2020-01-01 01:01:01'),(126,20220309133956,1,'2020-01-01 01:01:01'),(127,20220316155700,1,'2020-01-01 01:01:01'),(128,20220323152301,1,'2020-01-01 01:01:01'),(129,20220330100659,1,'2020-01-01 01:01:01'),(130,20220404091216,1,'2020-01-01 01:01:01'),(131,20220419140750,1,'2020-01-01 01:01:01'),(132,20220428140039,1,'2020-01-01 01:01:01'),(133,20220503134048,1,'2020-01-01 01:01:01'),(134,20220524102918,1,'2020-01-01 01:01:01'),(135,20220526123327,1,'2020-01-01 01:01:01'),(136,20220526123328,1,'2020-01-01 01:01:01'),(137,20220526123329,1,'2020-01-01 01:01:01'),(138,20220608113128,1,'2020-01-01 01:01:01'),(139,20220627104817,1,'2020-01-01 01:01:01'),(140,20220704101843,1,'2020-01-01 01:01:01'),(141,20220708095046,1,'2020-01-01 01:01:01'),(142,20220713091130,1,'2020-01-01 01:01:01'),(143,20220802135510,1,'2020-01-01 01:01:01'),(144,20220818101352,1,'2020-01-01 01:01:01'),(145,20220822161445,1,'2020-01-01 01:01:01'),(146,20220831100036,1,'2020-01-01 01:01:01'),(147,20220831100151,1,'2020-01-01 01:01:01'),(148,20220908181826,1,'2020-01-01 01:01:01'),(149,20220914154915,1,'2020-01-01 01:01:01'),(150,20220915165115,1,'2020-01-01 01:01:01'),(151,20220915165116,1,'2020-01-01 01:01:01'),(152,20220928100158,1,'2020-01-01 01:01:01'),(153,20221014084130,1,'2020-01-01 01:01:01'),(154,20221027085019,1,'2020-01-01 01:01:01'),(155,20221101103952,1,'2020-01-01 01:01:01'),(156,20221104144401,1,'2020-01-01 01:01:01'),(157,20221109100749,1,'2020-01-01 01:01:01'),(158,20221115104546,1,'2020-01-01 01:01:01'),(159,20221130114928,1,'2020-01-01 01:01:01'),(160,20221205112142,1,'2020-01-01 01:01:01'),(161,20221216115820,1,'2020-01-01 01:01:01'),(162,20221220195934,1,'2020-01-01 01:01:01'),(163,20221220195935,1,'2020-01-01 01:01:01'),(164,20221223174807,1,'2020-01-01 01:01:01'),(165,20221227163855,1,'2020-01-01 01:01:01'),(166,20221227163856,1,'2020-01-01 01:01:01'),(167,20230202224725,1,'2020-01-01 01:01:01'),(168,20230206163608,1,'2020-01-01 01:01:01'),(169,20230214131519,1,'2020-01-01 01:01:01'),(170,20230303135738,1,'2020-01-01 01:01:01'),(171,20230313135301,1,'2020-01-01 01:01:01'),(172,20230313141819,1,'2020-01-01 01:01:01'),(173,20230315104937,1,'2020-01-01 01:01:01'),(174,20230317173844,1,'2020-01-01 01:01:01'),(175,20230320133602,1,'2020-01-01 01:01:01'),(176,20230330100011,1,'2020-01-01 01:01:01'),(177,20230330134823,1,'2020-01-01 01:01:01'),(178,20230405232025,1,'2020-01-01 01:01:01'),(179,20230408084104,1,'2020-01-01 01:01:01'),(180,20230411102858,1,'2020-01-01 01:01:01'),(181,20230421155932,1,'2020-01-01 01:01:01'),(182,20230425082126,1,'2020-01-01 01:01:01'),(183,20230425105727,1,'2020-01-01 01:01:01'),(184,20230501154913,1,'2020-01-01 01:01:01'),(185,20230503101418,1,'2020-01-01 01:01:01'),(186,20230515144206,1,'2020-01-01 01:01:01'),(187,20230517140952,1,'2020-01-01 01:01:01'),(188,20230517152807,1,'2020-01-01 01:01:01'),(189,20230518114155,1,'2020-01-01 01:01:01'),(190,20230520153236,1,'2020-01-01 01:01:01'),(191,20230525151159,1,'2020-01-01 01:01:01'),(192,20230530122103,1,'2020-01-01 01:01:01'),(193,20230602111827,1,'2020-01-01 01:01:01'),(194,20230608103123,1,'2020-01-01 01:01:01'),(195,20230629140529,1,'2020-01-01 01:01:01'),(196,20230629140530,1,'2020-01-01 01:01:01'),(197,20230711144622,1,'2020-01-01 01:01:01'),(198,20230721135421,1,'2020-01-01 01:01:01'),(199,20230721161508,1,'2020-01-01 01:01:01'),(200,20230726115701,1,'2020-01-01 01:01:01'),(201,20230807100822,1,'2020-01-01 01:01:01'),(202,20230814150442,1,'2020-01-01 01:01:01'),(203,20230823122728,1,'2020-01-01 01:01:01'),(204,20230906152143,1,'2020-01-01 01:01:01'),(205,20230911163618,1,'2020-01-01 01:01:01'),(206,20230912101759,1,'2020-01-01 01:01:01'),(207,20230915101341,1,'2020-01-01 01:01:01'),(208,20230918132351,1,'2020-01-01 01:01:01'),(209,20231004144339,1,'2020-01-01 01:01:01'),(210,20231009094541,1,'2020-01-01 01:01:01'),(211,20231009094542,1,'2020-01-01 01:01:01'),(212,20231009094543,1,'2020-01-01 01:01:01'),(213,20231009094544,1,'2020-01-01 01:01:01'),(214,20231016091915,1,'2020-01-01 01:01:01'),(215,20231024174135,1,'2020-01-01 01:01:01'),(216,20231025120016,1,'2020-01-01 01:01:01'),(217,20231025160156,1,'2020-01-01 01:01:01'),(218,20231031165350,1,'2020-01-01 01:01:01'),(219,20231106144110,1,'2020-01-01 01:01:01'),(220,20231107130934,1,'2020-01-01 01:01:01'),(221,20231109115838,1,'2020-01-01 01:01:01'),(222,20231121054530,1,'2020-01-01 01:01:01'),(223,20231122101320,1,'2020-01-01 01:01:01'),(224,20231130132828,1,'2020-01-01 01:01:01'),(225,20231130132931,1,'2020-01-01 01:01:01'),(226,20231204155427,1,'2020-01-01 01:01:01'),(227,20231206142340,1,'2020-01-01 01:01:01'),(228,20231207102320,1,'2020-01-01 01:01:01'),(229,20231207102321,1,'2020-01-01 01:01:01'),(230,20231207133731,1,'2020-01-01 01:01:01'),(231,20231212094238,1,'2020-01-01 01:01:01'),(232,20231212095734,1,'2020-01-01 01:01:01'),(233,20231212161121,1,'2020-01-01 01:01:01'),(234,20231215122713,1,'2020-01-01 01:01:01'),(235,20231219143041,1,'2020-01-01 01:01:01'),(236,20231224070653,1,'2020-01-01 01:01:01'),(237,20240110134315,1,'2020-01-01 01:01:01'),(238,20240119091637,1,'2020-01-01 01:01:01'),(239,20240126020642,1,'2020-01-01 01:01:01'),(240,20240126020643,1,'2020-01-01 01:01:01'),(241,20240129162819,1,'2020-01-01 01:01:01'),(242,20240130115133,1,'2020-01-01 01:01:01'),(243,20240131083822,1,'2020-01-01 01:01:01'),(244,20240205095928,1,'2020-01-01 01:01:01'),(245,20240205121956,1,'2020-01-01 01:01:01'),(246,20240209110212,1,'2020-01-01 01:01:01'),(247,20240212111533,1,'2020-01-01 01:01:01'),(248,20240221112844,1,'2020-01-01 01:01:01'),(249,20240222073518,1,'2020-01-01 01:01:01'),(250,20240222135115,1,'2020-01-01 01:01:01'),(251,20240226082255,1,'2020-01-01 01:01:01'),(252,20240228082706,1,'2020-01-01 01:01:01'),(253,20240301173035,1,'2020-01-01 01:01:01'),(254,20240302111134,1,'2020-01-01 01:01:01'),(255,20240312103753,1,'2020-01-01 01:01:01'),(256,20240313143039,1,'2020-01-01 01:01:01'); /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `mobile_device_management_solutions` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `server_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_mobile_device_management_solutions_name` (`name`,`server_url`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `munki_issues` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `issue_type` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_munki_issues_name` (`name`,`issue_type`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `nano_cert_auth_associations` ( `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `sha256` char(64) COLLATE utf8mb4_unicode_ci NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `cert_not_valid_after` timestamp NULL DEFAULT NULL, - `renew_command_uuid` varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `renew_command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`,`sha256`), KEY `renew_command_uuid_fk` (`renew_command_uuid`), - CONSTRAINT `renew_command_uuid_fk` FOREIGN KEY (`renew_command_uuid`) REFERENCES `nano_commands` (`command_uuid`), - CONSTRAINT `nano_cert_auth_associations_chk_1` CHECK ((`id` <> _utf8mb4'')), - CONSTRAINT `nano_cert_auth_associations_chk_2` CHECK ((`sha256` <> _utf8mb4'')) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + CONSTRAINT `renew_command_uuid_fk` FOREIGN KEY (`renew_command_uuid`) REFERENCES `nano_commands` (`command_uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `nano_command_results` ( `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `status` varchar(31) COLLATE utf8mb4_unicode_ci NOT NULL, `result` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, `not_now_at` timestamp NULL DEFAULT NULL, - `not_now_tally` int NOT NULL DEFAULT '0', - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `not_now_tally` int(11) NOT NULL DEFAULT '0', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`,`command_uuid`), KEY `command_uuid` (`command_uuid`), KEY `status` (`status`), CONSTRAINT `nano_command_results_ibfk_1` FOREIGN KEY (`id`) REFERENCES `nano_enrollments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `nano_command_results_ibfk_2` FOREIGN KEY (`command_uuid`) REFERENCES `nano_commands` (`command_uuid`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `nano_command_results_chk_1` CHECK ((`status` <> _utf8mb4'')), - CONSTRAINT `nano_command_results_chk_2` CHECK ((substr(`result`,1,5) = _utf8mb4' _utf8mb4'')), - CONSTRAINT `nano_commands_chk_2` CHECK ((`request_type` <> _utf8mb4'')), - CONSTRAINT `nano_commands_chk_3` CHECK ((substr(`command`,1,5) = _utf8mb4' _utf8mb4''))), - CONSTRAINT `nano_devices_chk_3` CHECK (((`unlock_token` is null) or (length(`unlock_token`) > 0))), - CONSTRAINT `nano_devices_chk_4` CHECK ((`authenticate` <> _utf8mb4'')), - CONSTRAINT `nano_devices_chk_5` CHECK (((`token_update` is null) or (`token_update` <> _utf8mb4''))), - CONSTRAINT `nano_devices_chk_6` CHECK (((`bootstrap_token_b64` is null) or (`bootstrap_token_b64` <> _utf8mb4''))) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + KEY `serial_number` (`serial_number`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `nano_enrollment_queue` ( `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', - `priority` tinyint NOT NULL DEFAULT '0', - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `priority` tinyint(4) NOT NULL DEFAULT '0', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`,`command_uuid`), KEY `command_uuid` (`command_uuid`), - KEY `priority` (`priority` DESC,`created_at`), + KEY `priority` (`priority`,`created_at`), CONSTRAINT `nano_enrollment_queue_ibfk_1` FOREIGN KEY (`id`) REFERENCES `nano_enrollments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `nano_enrollment_queue_ibfk_2` FOREIGN KEY (`command_uuid`) REFERENCES `nano_commands` (`command_uuid`) ON DELETE CASCADE ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `nano_enrollments` ( `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `device_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -945,40 +929,32 @@ CREATE TABLE `nano_enrollments` ( `push_magic` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `token_hex` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `enabled` tinyint(1) NOT NULL DEFAULT '1', - `token_update_tally` int NOT NULL DEFAULT '1', - `last_seen_at` timestamp NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `token_update_tally` int(11) NOT NULL DEFAULT '1', + `last_seen_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`), KEY `device_id` (`device_id`), KEY `type` (`type`), CONSTRAINT `nano_enrollments_ibfk_1` FOREIGN KEY (`device_id`) REFERENCES `nano_devices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `nano_enrollments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `nano_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `nano_enrollments_chk_1` CHECK ((`id` <> _utf8mb4'')), - CONSTRAINT `nano_enrollments_chk_2` CHECK ((`type` <> _utf8mb4'')), - CONSTRAINT `nano_enrollments_chk_3` CHECK ((`topic` <> _utf8mb4'')), - CONSTRAINT `nano_enrollments_chk_4` CHECK ((`push_magic` <> _utf8mb4'')), - CONSTRAINT `nano_enrollments_chk_5` CHECK ((`token_hex` <> _utf8mb4'')) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + CONSTRAINT `nano_enrollments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `nano_users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `nano_push_certs` ( `topic` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `cert_pem` text COLLATE utf8mb4_unicode_ci NOT NULL, `key_pem` text COLLATE utf8mb4_unicode_ci NOT NULL, - `stale_token` int NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`topic`), - CONSTRAINT `nano_push_certs_chk_1` CHECK ((`topic` <> _utf8mb4'')), - CONSTRAINT `nano_push_certs_chk_2` CHECK ((substr(`cert_pem`,1,27) = _utf8mb4'-----BEGIN CERTIFICATE-----')), - CONSTRAINT `nano_push_certs_chk_3` CHECK ((substr(`key_pem`,1,5) = _utf8mb4'-----')) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + `stale_token` int(11) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`topic`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `nano_users` ( `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `device_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -990,20 +966,15 @@ CREATE TABLE `nano_users` ( `user_authenticate_at` timestamp NULL DEFAULT NULL, `user_authenticate_digest` text COLLATE utf8mb4_unicode_ci, `user_authenticate_digest_at` timestamp NULL DEFAULT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`,`device_id`), KEY `device_id` (`device_id`), - CONSTRAINT `nano_users_ibfk_1` FOREIGN KEY (`device_id`) REFERENCES `nano_devices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `nano_users_chk_1` CHECK (((`user_short_name` is null) or (`user_short_name` <> _utf8mb4''))), - CONSTRAINT `nano_users_chk_2` CHECK (((`user_long_name` is null) or (`user_long_name` <> _utf8mb4''))), - CONSTRAINT `nano_users_chk_3` CHECK (((`token_update` is null) or (`token_update` <> _utf8mb4''))), - CONSTRAINT `nano_users_chk_4` CHECK (((`user_authenticate` is null) or (`user_authenticate` <> _utf8mb4''))), - CONSTRAINT `nano_users_chk_5` CHECK (((`user_authenticate_digest` is null) or (`user_authenticate_digest` <> _utf8mb4''))) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + CONSTRAINT `nano_users_ibfk_1` FOREIGN KEY (`device_id`) REFERENCES `nano_devices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; SET @saved_cs_client = @@character_set_client; -/*!50503 SET character_set_client = utf8mb4 */; +SET character_set_client = utf8; /*!50001 CREATE VIEW `nano_view_queue` AS SELECT 1 AS `id`, 1 AS `created_at`, @@ -1017,92 +988,92 @@ SET @saved_cs_client = @@character_set_client; 1 AS `result`*/; SET character_set_client = @saved_cs_client; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `network_interfaces` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, `mac` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `ip_address` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `broadcast` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `ibytes` bigint NOT NULL DEFAULT '0', + `ibytes` bigint(20) NOT NULL DEFAULT '0', `interface` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `ipackets` bigint NOT NULL DEFAULT '0', - `last_change` bigint NOT NULL DEFAULT '0', + `ipackets` bigint(20) NOT NULL DEFAULT '0', + `last_change` bigint(20) NOT NULL DEFAULT '0', `mask` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `metric` int NOT NULL DEFAULT '0', - `mtu` int NOT NULL DEFAULT '0', - `obytes` bigint NOT NULL DEFAULT '0', - `ierrors` bigint NOT NULL DEFAULT '0', - `oerrors` bigint NOT NULL DEFAULT '0', - `opackets` bigint NOT NULL DEFAULT '0', + `metric` int(11) NOT NULL DEFAULT '0', + `mtu` int(11) NOT NULL DEFAULT '0', + `obytes` bigint(20) NOT NULL DEFAULT '0', + `ierrors` bigint(20) NOT NULL DEFAULT '0', + `oerrors` bigint(20) NOT NULL DEFAULT '0', + `opackets` bigint(20) NOT NULL DEFAULT '0', `point_to_point` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `type` int NOT NULL DEFAULT '0', - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `type` int(11) NOT NULL DEFAULT '0', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_network_interfaces_unique_ip_host_intf` (`ip_address`,`host_id`,`interface`), KEY `idx_network_interfaces_hosts_fk` (`host_id`), FULLTEXT KEY `ip_address_search` (`ip_address`), CONSTRAINT `network_interfaces_ibfk_1` FOREIGN KEY (`host_id`) REFERENCES `hosts` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `operating_system_vulnerabilities` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `operating_system_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `operating_system_id` int(10) unsigned NOT NULL, `cve` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `source` smallint DEFAULT '0', + `source` smallint(6) DEFAULT '0', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `resolved_in_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `resolved_in_version` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_os_vulnerabilities_unq_os_id_cve` (`operating_system_id`,`cve`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `operating_systems` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `version` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, `arch` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, `kernel_version` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL, `platform` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, - `display_version` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `os_version_id` int unsigned DEFAULT NULL, + `display_version` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `os_version_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_unique_os` (`name`,`version`,`arch`,`kernel_version`,`platform`,`display_version`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `osquery_options` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `override_type` int NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `override_type` int(1) NOT NULL, `override_identifier` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `options` json NOT NULL, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `osquery_options` VALUES (1,0,'','{\"options\": {\"logger_plugin\": \"tls\", \"pack_delimiter\": \"/\", \"logger_tls_period\": 10, \"distributed_plugin\": \"tls\", \"disable_distributed\": false, \"logger_tls_endpoint\": \"/api/v1/osquery/log\", \"distributed_interval\": 10, \"distributed_tls_max_attempts\": 3}, \"decorators\": {\"load\": [\"SELECT uuid AS host_uuid FROM system_info;\", \"SELECT hostname AS hostname FROM system_info;\"]}}'); /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `pack_targets` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `pack_id` int unsigned DEFAULT NULL, - `type` int DEFAULT NULL, - `target_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `pack_id` int(10) unsigned DEFAULT NULL, + `type` int(11) DEFAULT NULL, + `target_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `constraint_pack_target_unique` (`pack_id`,`target_id`,`type`), CONSTRAINT `pack_targets_ibfk_1` FOREIGN KEY (`pack_id`) REFERENCES `packs` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `packs` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `disabled` tinyint(1) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -1111,32 +1082,32 @@ CREATE TABLE `packs` ( `pack_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_pack_unique_name` (`name`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `password_reset_requests` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `expires_at` timestamp NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `expires_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `user_id` int unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, `token` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `policies` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `team_id` int unsigned DEFAULT NULL, + `team_id` int(10) unsigned DEFAULT NULL, `resolution` text COLLATE utf8mb4_unicode_ci, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `query` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `author_id` int unsigned DEFAULT NULL, + `author_id` int(10) unsigned DEFAULT NULL, `platforms` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `critical` tinyint(1) NOT NULL DEFAULT '0', `checksum` binary(16) NOT NULL, @@ -1146,41 +1117,41 @@ CREATE TABLE `policies` ( KEY `idx_policies_team_id` (`team_id`), CONSTRAINT `policies_ibfk_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `policies_queries_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `users` (`id`) ON DELETE SET NULL -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `policy_automation_iterations` ( - `policy_id` int unsigned NOT NULL, - `iteration` int NOT NULL, + `policy_id` int(10) unsigned NOT NULL, + `iteration` int(11) NOT NULL, PRIMARY KEY (`policy_id`), CONSTRAINT `policy_automation_iterations_ibfk_1` FOREIGN KEY (`policy_id`) REFERENCES `policies` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `policy_membership` ( - `policy_id` int unsigned NOT NULL, - `host_id` int unsigned NOT NULL, + `policy_id` int(10) unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `passes` tinyint(1) DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `automation_iteration` int DEFAULT NULL, + `automation_iteration` int(11) DEFAULT NULL, PRIMARY KEY (`policy_id`,`host_id`), KEY `idx_policy_membership_passes` (`passes`), KEY `idx_policy_membership_policy_id` (`policy_id`), KEY `idx_policy_membership_host_id_passes` (`host_id`,`passes`), CONSTRAINT `policy_membership_ibfk_1` FOREIGN KEY (`policy_id`) REFERENCES `policies` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `policy_stats` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `policy_id` int unsigned NOT NULL, - `inherited_team_id` int unsigned NOT NULL DEFAULT '0', - `passing_host_count` mediumint unsigned NOT NULL DEFAULT '0', - `failing_host_count` mediumint unsigned NOT NULL DEFAULT '0', + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `policy_id` int(10) unsigned NOT NULL, + `inherited_team_id` int(10) unsigned NOT NULL DEFAULT '0', + `passing_host_count` mediumint(8) unsigned NOT NULL DEFAULT '0', + `failing_host_count` mediumint(8) unsigned NOT NULL DEFAULT '0', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), @@ -1189,23 +1160,23 @@ CREATE TABLE `policy_stats` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `queries` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `saved` tinyint(1) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `description` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, `query` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `author_id` int unsigned DEFAULT NULL, + `author_id` int(10) unsigned DEFAULT NULL, `observer_can_run` tinyint(1) NOT NULL DEFAULT '0', - `team_id` int unsigned DEFAULT NULL, + `team_id` int(10) unsigned DEFAULT NULL, `team_id_char` char(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `platform` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `min_osquery_version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `schedule_interval` int unsigned NOT NULL DEFAULT '0', - `automations_enabled` tinyint unsigned NOT NULL DEFAULT '0', + `schedule_interval` int(10) unsigned NOT NULL DEFAULT '0', + `automations_enabled` tinyint(1) unsigned NOT NULL DEFAULT '0', `logging_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'snapshot', `discard_data` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), @@ -1215,61 +1186,59 @@ CREATE TABLE `queries` ( KEY `idx_team_id_saved_auto_interval` (`team_id`,`saved`,`automations_enabled`,`schedule_interval`), CONSTRAINT `queries_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `users` (`id`) ON DELETE SET NULL, CONSTRAINT `queries_ibfk_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `query_results` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `query_id` int unsigned NOT NULL, - `host_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `query_id` int(10) unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, `osquery_version` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `error` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, - `last_fetched` timestamp NOT NULL, + `error` text COLLATE utf8mb4_unicode_ci, + `last_fetched` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `data` json DEFAULT NULL, PRIMARY KEY (`id`), KEY `query_id` (`query_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `scep_certificates` ( - `serial` bigint NOT NULL, + `serial` bigint(20) NOT NULL, `name` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `not_valid_before` datetime NOT NULL, `not_valid_after` datetime NOT NULL, `certificate_pem` text COLLATE utf8mb4_unicode_ci NOT NULL, `revoked` tinyint(1) NOT NULL DEFAULT '0', - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`serial`), - CONSTRAINT `scep_certificates_ibfk_1` FOREIGN KEY (`serial`) REFERENCES `scep_serials` (`serial`), - CONSTRAINT `scep_certificates_chk_1` CHECK ((substr(`certificate_pem`,1,27) = _utf8mb4'-----BEGIN CERTIFICATE-----')), - CONSTRAINT `scep_certificates_chk_2` CHECK (((`name` is null) or (`name` <> _utf8mb4''))) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + CONSTRAINT `scep_certificates_ibfk_1` FOREIGN KEY (`serial`) REFERENCES `scep_serials` (`serial`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `scep_serials` ( - `serial` bigint NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `serial` bigint(20) NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`serial`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `scheduled_queries` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `pack_id` int unsigned DEFAULT NULL, - `query_id` int unsigned DEFAULT NULL, - `interval` int unsigned DEFAULT NULL, + `pack_id` int(10) unsigned DEFAULT NULL, + `query_id` int(10) unsigned DEFAULT NULL, + `interval` int(10) unsigned DEFAULT NULL, `snapshot` tinyint(1) DEFAULT NULL, `removed` tinyint(1) DEFAULT NULL, `platform` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '', `version` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '', - `shard` int unsigned DEFAULT NULL, + `shard` int(10) unsigned DEFAULT NULL, `query_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `description` varchar(1023) COLLATE utf8mb4_unicode_ci DEFAULT '', @@ -1282,73 +1251,73 @@ CREATE TABLE `scheduled_queries` ( KEY `fk_scheduled_queries_queries` (`team_id_char`,`query_name`), CONSTRAINT `scheduled_queries_ibfk_1` FOREIGN KEY (`team_id_char`, `query_name`) REFERENCES `queries` (`team_id_char`, `name`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `scheduled_queries_pack_id` FOREIGN KEY (`pack_id`) REFERENCES `packs` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `scheduled_query_stats` ( - `host_id` int unsigned NOT NULL, - `scheduled_query_id` int unsigned NOT NULL, - `average_memory` bigint unsigned NOT NULL, + `host_id` int(10) unsigned NOT NULL, + `scheduled_query_id` int(10) unsigned NOT NULL, + `average_memory` bigint(20) unsigned NOT NULL, `denylisted` tinyint(1) DEFAULT NULL, - `executions` bigint unsigned NOT NULL, - `schedule_interval` int DEFAULT NULL, - `last_executed` timestamp NULL DEFAULT NULL, - `output_size` bigint unsigned NOT NULL, - `system_time` bigint unsigned NOT NULL, - `user_time` bigint unsigned NOT NULL, - `wall_time` bigint unsigned NOT NULL, - `query_type` tinyint NOT NULL DEFAULT '0', + `executions` bigint(20) unsigned NOT NULL, + `schedule_interval` int(11) DEFAULT NULL, + `last_executed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `output_size` bigint(20) unsigned NOT NULL, + `system_time` bigint(20) unsigned NOT NULL, + `user_time` bigint(20) unsigned NOT NULL, + `wall_time` bigint(20) unsigned NOT NULL, + `query_type` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`host_id`,`scheduled_query_id`,`query_type`), KEY `scheduled_query_id` (`scheduled_query_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `script_contents` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `md5_checksum` binary(16) NOT NULL, - `contents` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `contents` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `idx_script_contents_md5_checksum` (`md5_checksum`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `scripts` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `team_id` int unsigned DEFAULT NULL, - `global_or_team_id` int unsigned NOT NULL DEFAULT '0', + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `team_id` int(10) unsigned DEFAULT NULL, + `global_or_team_id` int(10) unsigned NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `script_contents` text COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `script_content_id` int unsigned DEFAULT NULL, + `script_content_id` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_scripts_global_or_team_id_name` (`global_or_team_id`,`name`), UNIQUE KEY `idx_scripts_team_name` (`team_id`,`name`), KEY `script_content_id` (`script_content_id`), CONSTRAINT `scripts_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `scripts_ibfk_2` FOREIGN KEY (`script_content_id`) REFERENCES `script_contents` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `sessions` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `accessed_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `user_id` int unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_session_unique_key` (`key`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `software` ( - `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `source` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -1359,7 +1328,7 @@ CREATE TABLE `software` ( `vendor` varchar(114) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `browser` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `extension_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `title_id` int unsigned DEFAULT NULL, + `title_id` int(10) unsigned DEFAULT NULL, `checksum` binary(16) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_software_checksum` (`checksum`), @@ -1367,67 +1336,67 @@ CREATE TABLE `software` ( KEY `software_source_vendor_idx` (`source`,`vendor_old`), KEY `title_id` (`title_id`), KEY `idx_sw_name_source_browser` (`name`,`source`,`browser`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `software_cpe` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `software_id` bigint unsigned DEFAULT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `software_id` bigint(20) unsigned DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `cpe` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unq_software_id` (`software_id`), KEY `software_cpe_cpe_idx` (`cpe`), CONSTRAINT `software_cpe_ibfk_1` FOREIGN KEY (`software_id`) REFERENCES `software` (`id`) ON DELETE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `software_cve` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `cve` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `source` int DEFAULT '0', - `software_id` bigint unsigned DEFAULT NULL, - `resolved_in_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `source` int(11) DEFAULT '0', + `software_id` bigint(20) unsigned DEFAULT NULL, + `resolved_in_version` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unq_software_id_cve` (`software_id`,`cve`), KEY `software_cve_software_id` (`software_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `software_host_counts` ( - `software_id` bigint unsigned NOT NULL, - `hosts_count` int unsigned NOT NULL, + `software_id` bigint(20) unsigned NOT NULL, + `hosts_count` int(10) unsigned NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `team_id` int unsigned NOT NULL DEFAULT '0', + `team_id` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`software_id`,`team_id`), KEY `idx_software_host_counts_updated_at_software_id` (`updated_at`,`software_id`), KEY `idx_software_host_counts_team_id_hosts_count_software_id` (`team_id`,`hosts_count`,`software_id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `software_titles` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `source` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, - `browser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `browser` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `idx_sw_titles` (`name`,`source`,`browser`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `software_titles_host_counts` ( - `software_title_id` int unsigned NOT NULL, - `hosts_count` int unsigned NOT NULL, - `team_id` int unsigned NOT NULL DEFAULT '0', + `software_title_id` int(10) unsigned NOT NULL, + `hosts_count` int(10) unsigned NOT NULL, + `team_id` int(10) unsigned NOT NULL DEFAULT '0', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`software_title_id`,`team_id`), @@ -1436,45 +1405,58 @@ CREATE TABLE `software_titles_host_counts` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `statistics` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `anonymous_identifier` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `teams` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `description` varchar(1023) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `config` json DEFAULT NULL, `name_bin` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin GENERATED ALWAYS AS (`name`) VIRTUAL, PRIMARY KEY (`id`), UNIQUE KEY `idx_name_bin` (`name_bin`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_persistent_info` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned DEFAULT NULL, + `user_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `user_persistent_info_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `user_teams` ( - `user_id` int unsigned NOT NULL, - `team_id` int unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `team_id` int(10) unsigned NOT NULL, `role` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`user_id`,`team_id`), KEY `fk_user_teams_team_id` (`team_id`), CONSTRAINT `user_teams_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `user_teams_ibfk_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `users` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `password` varbinary(255) NOT NULL, `salt` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -1483,31 +1465,31 @@ CREATE TABLE `users` ( `admin_forced_password_reset` tinyint(1) NOT NULL DEFAULT '0', `gravatar_url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `position` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', - `sso_enabled` tinyint NOT NULL DEFAULT '0', + `sso_enabled` tinyint(4) NOT NULL DEFAULT '0', `global_role` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `api_only` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `idx_user_unique_email` (`email`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `vulnerability_host_counts` ( `cve` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, - `team_id` int unsigned NOT NULL DEFAULT '0', - `host_count` int unsigned NOT NULL DEFAULT '0', - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `team_id` int(10) unsigned NOT NULL DEFAULT '0', + `host_count` int(10) unsigned NOT NULL DEFAULT '0', + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, UNIQUE KEY `cve_team_id` (`cve`,`team_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `windows_mdm_command_queue` ( - `enrollment_id` int unsigned NOT NULL, + `enrollment_id` int(10) unsigned NOT NULL, `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`enrollment_id`,`command_uuid`), KEY `command_uuid` (`command_uuid`), CONSTRAINT `windows_mdm_command_queue_ibfk_1` FOREIGN KEY (`enrollment_id`) REFERENCES `mdm_windows_enrollments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -1515,15 +1497,15 @@ CREATE TABLE `windows_mdm_command_queue` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `windows_mdm_command_results` ( - `enrollment_id` int unsigned NOT NULL, + `enrollment_id` int(10) unsigned NOT NULL, `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `raw_result` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `response_id` int unsigned NOT NULL, + `response_id` int(10) unsigned NOT NULL, `status_code` varchar(31) COLLATE utf8mb4_unicode_ci NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`enrollment_id`,`command_uuid`), KEY `command_uuid` (`command_uuid`), KEY `response_id` (`response_id`), @@ -1533,47 +1515,47 @@ CREATE TABLE `windows_mdm_command_results` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `windows_mdm_commands` ( `command_uuid` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, `raw_command` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, `target_loc_uri` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `user_id` int unsigned DEFAULT NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `user_persistent_info_id` int(10) unsigned DEFAULT NULL, `fleet_owned` tinyint(1) DEFAULT NULL, PRIMARY KEY (`command_uuid`), - KEY `fk_windows_mdm_commands_users` (`user_id`), - CONSTRAINT `fk_windows_mdm_commands_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + KEY `fk_windows_mdm_commands_user_info` (`user_persistent_info_id`), + CONSTRAINT `fk_windows_mdm_commands_user_info` FOREIGN KEY (`user_persistent_info_id`) REFERENCES `user_persistent_info` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `windows_mdm_responses` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `enrollment_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `enrollment_id` int(10) unsigned NOT NULL, `raw_response` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `enrollment_id` (`enrollment_id`), CONSTRAINT `windows_mdm_responses_ibfk_1` FOREIGN KEY (`enrollment_id`) REFERENCES `mdm_windows_enrollments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `windows_updates` ( - `id` int unsigned NOT NULL AUTO_INCREMENT, - `host_id` int unsigned NOT NULL, - `date_epoch` int unsigned NOT NULL, - `kb_id` int unsigned NOT NULL, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `host_id` int(10) unsigned NOT NULL, + `date_epoch` int(10) unsigned NOT NULL, + `kb_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_unique_windows_updates` (`host_id`,`kb_id`), KEY `idx_update_date` (`host_id`,`date_epoch`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `wstep_cert_auth_associations` ( `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `sha256` char(64) COLLATE utf8mb4_unicode_ci NOT NULL, @@ -1583,9 +1565,9 @@ CREATE TABLE `wstep_cert_auth_associations` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `wstep_certificates` ( - `serial` bigint unsigned NOT NULL, + `serial` bigint(20) unsigned NOT NULL, `name` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL, `not_valid_before` datetime NOT NULL, `not_valid_after` datetime NOT NULL, @@ -1598,12 +1580,12 @@ CREATE TABLE `wstep_certificates` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +/*!40101 SET character_set_client = utf8 */; CREATE TABLE `wstep_serials` ( - `serial` bigint unsigned NOT NULL AUTO_INCREMENT, + `serial` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`serial`) -) /*!50100 TABLESPACE `innodb_system` */ ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!50001 DROP VIEW IF EXISTS `nano_view_queue`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; From 82cc2ad4fa155bf7df02292b2fd033acfb546962 Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Wed, 13 Mar 2024 17:03:23 -0300 Subject: [PATCH 3/6] update comments and error messages --- ...40313143039_TrackUserReferencesForCommandsAndProfiles.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go index d6c6b8f2c86..a86856536e2 100644 --- a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go +++ b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go @@ -53,7 +53,7 @@ func Up_20240313143039(tx *sql.Tx) error { for _, t := range tables { _, err := tx.Exec(fmt.Sprintf(` ALTER TABLE`+" `%s` "+` - -- user_id references the user that created the entity. + -- user_persistent_info_id references the user that created the entity. -- it's NULL for rows created prior to this migration, -- and also for entities that don't have an user -- associated with it (eg: Fleet initiated actions) @@ -63,7 +63,7 @@ func Up_20240313143039(tx *sql.Tx) error { ADD COLUMN fleet_owned tinyint(1) DEFAULT NULL `, t)) if err != nil { - return fmt.Errorf("failed to add user_id and fleet_owned to %s: %w", t, err) + return fmt.Errorf("failed to add user_persistent_info_id and fleet_owned to %s: %w", t, err) } _, err = tx.Exec(fmt.Sprintf(` @@ -72,7 +72,7 @@ func Up_20240313143039(tx *sql.Tx) error { FOREIGN KEY (user_persistent_info_id) REFERENCES user_persistent_info(id) ON DELETE RESTRICT`, t, t)) if err != nil { - return fmt.Errorf("failed to add user_id foreign key to %s: %w", t, err) + return fmt.Errorf("failed to add user_persistent_info_id foreign key to %s: %w", t, err) } } From eb759f89a2455f2ad876baec3041c4f836eda9ee Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Thu, 14 Mar 2024 10:08:40 -0300 Subject: [PATCH 4/6] improvements --- ...ackUserReferencesForCommandsAndProfiles.go | 8 +++-- ...erReferencesForCommandsAndProfiles_test.go | 15 +++++----- server/datastore/mysql/schema.sql | 3 +- server/datastore/mysql/users.go | 24 ++++++++++++++- server/datastore/mysql/users_test.go | 30 +++++++++++++++++++ 5 files changed, 69 insertions(+), 11 deletions(-) diff --git a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go index a86856536e2..2b89cc01958 100644 --- a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go +++ b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go @@ -23,11 +23,15 @@ func Up_20240313143039(tx *sql.Tx) error { -- user_name mirrors the users.name value user_name varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + -- user_email mirrors the users.email value + user_email varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + -- timestamps created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), + UNIQUE INDEX idx_unique_user_id (user_id), FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE SET NULL ) `) @@ -37,8 +41,8 @@ func Up_20240313143039(tx *sql.Tx) error { // migrate existing data. _, err = tx.Exec(` - INSERT INTO user_persistent_info (user_id, user_name) - SELECT id, name + INSERT INTO user_persistent_info (user_id, user_name, user_email) + SELECT id, name, email FROM users `) if err != nil { diff --git a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go index c9e03760b10..915f99d2384 100644 --- a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go +++ b/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go @@ -53,20 +53,21 @@ INSERT INTO // check the newly created user_info tables type userInfo struct { - ID uint `db:"id"` - UserID *uint `db:"user_id"` - UserName string `db:"user_name"` + ID uint `db:"id"` + UserID *uint `db:"user_id"` + UserName string `db:"user_name"` + UserEmail string `db:"user_email"` } var userInfos []userInfo err = db.Select( &userInfos, - `SELECT user_id, user_name, id FROM user_persistent_info`, + `SELECT user_id, user_name, id, user_email FROM user_persistent_info`, ) require.NoError(t, err) require.ElementsMatch(t, []userInfo{ - {ID: uint(1), UserID: ptr.Uint(1), UserName: "admin"}, - {ID: uint(2), UserID: ptr.Uint(2), UserName: "User 1"}, - {ID: uint(3), UserID: ptr.Uint(3), UserName: "User 2"}, + {ID: uint(1), UserID: ptr.Uint(1), UserEmail: "admin@email.com", UserName: "admin"}, + {ID: uint(2), UserID: ptr.Uint(2), UserEmail: "user1@email.com", UserName: "User 1"}, + {ID: uint(3), UserID: ptr.Uint(3), UserEmail: "user2@email.com", UserName: "User 2"}, }, userInfos) // deleting an user doesn't delete the user info diff --git a/server/datastore/mysql/schema.sql b/server/datastore/mysql/schema.sql index 3a7f7cdc782..f142acd9b81 100644 --- a/server/datastore/mysql/schema.sql +++ b/server/datastore/mysql/schema.sql @@ -1433,10 +1433,11 @@ CREATE TABLE `user_persistent_info` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned DEFAULT NULL, `user_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `user_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), - KEY `user_id` (`user_id`), + UNIQUE KEY `idx_unique_user_id` (`user_id`), CONSTRAINT `user_persistent_info_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/server/datastore/mysql/users.go b/server/datastore/mysql/users.go index 5af8255b34b..d0b8f9a05b7 100644 --- a/server/datastore/mysql/users.go +++ b/server/datastore/mysql/users.go @@ -20,7 +20,7 @@ func (ds *Datastore) NewUser(ctx context.Context, user *fleet.User) (*fleet.User return nil, ctxerr.Wrap(ctx, err, "validate role") } - err := ds.withTx(ctx, func(tx sqlx.ExtContext) error { + err := ds.withRetryTxx(ctx, func(tx sqlx.ExtContext) error { sqlStatement := ` INSERT INTO users ( password, @@ -56,6 +56,11 @@ func (ds *Datastore) NewUser(ctx context.Context, user *fleet.User) (*fleet.User if err := saveTeamsForUserDB(ctx, tx, user); err != nil { return err } + + if err := savePersistentInfoForUserDB(ctx, tx, user); err != nil { + return ctxerr.Wrap(ctx, err, "saving persistent info for new user") + } + return nil }) if err != nil { @@ -195,6 +200,10 @@ func saveUserDB(ctx context.Context, tx sqlx.ExtContext, user *fleet.User) error return err } + if err := savePersistentInfoForUserDB(ctx, tx, user); err != nil { + return ctxerr.Wrap(ctx, err, "saving persistent info for existing user") + } + return nil } @@ -271,6 +280,19 @@ func saveTeamsForUserDB(ctx context.Context, tx sqlx.ExtContext, user *fleet.Use return nil } +func savePersistentInfoForUserDB(ctx context.Context, tx sqlx.ExtContext, user *fleet.User) error { + stmt := ` + INSERT INTO user_persistent_info + (user_id, user_name, user_email) + VALUES + (?, ?, ?) + ON DUPLICATE KEY UPDATE + user_name = VALUES(user_name), + user_email = VALUES(user_email)` + _, err := tx.ExecContext(ctx, stmt, user.ID, user.Name, user.Email) + return ctxerr.Wrap(ctx, err, "insert persistent user info") +} + // DeleteUser deletes the associated user func (ds *Datastore) DeleteUser(ctx context.Context, id uint) error { return ds.deleteEntity(ctx, usersTable, id) diff --git a/server/datastore/mysql/users_test.go b/server/datastore/mysql/users_test.go index fa60b9c8a40..70007513bda 100644 --- a/server/datastore/mysql/users_test.go +++ b/server/datastore/mysql/users_test.go @@ -9,6 +9,7 @@ import ( "github.com/fleetdm/fleet/v4/server" "github.com/fleetdm/fleet/v4/server/test" + "github.com/jmoiron/sqlx" "github.com/fleetdm/fleet/v4/server/fleet" "github.com/fleetdm/fleet/v4/server/ptr" @@ -70,6 +71,8 @@ func testUsersCreate(t *testing.T, ds *Datastore) { assert.Equal(t, tt.email, verify.Email) assert.Equal(t, tt.sso, verify.SSOEnabled) assert.Equal(t, tt.resultingPasswordReset, verify.AdminForcedPasswordReset) + + assertPersistentUserInfo(t, ds, []*fleet.User{user}) } } @@ -119,6 +122,7 @@ func testUsersSave(t *testing.T, ds *Datastore) { testUserGlobalRole(t, ds, users) testEmailAttribute(t, ds, users) testPasswordAttribute(t, ds, users) + assertPersistentUserInfo(t, ds, users) } func testPasswordAttribute(t *testing.T, ds fleet.Datastore, users []*fleet.User) { @@ -339,4 +343,30 @@ func testUsersSaveMany(t *testing.T, ds *Datastore) { gotU3, err := ds.UserByID(context.Background(), u3.ID) require.NoError(t, err) assert.True(t, strings.HasSuffix(gotU3.Email, "fleet.com")) + + assertPersistentUserInfo(t, ds, []*fleet.User{u1, u2, u3}) +} + +func assertPersistentUserInfo(t *testing.T, ds *Datastore, users []*fleet.User) { + var persistentInfo struct { + ID uint `db:"id"` + UserID *uint `db:"user_id"` + UserName string `db:"user_name"` + UserEmail string `db:"user_email"` + } + for _, u := range users { + ExecAdhocSQL(t, ds, func(tx sqlx.ExtContext) error { + return sqlx.GetContext( + context.Background(), + tx, + &persistentInfo, + `SELECT user_id, user_name, id, user_email FROM user_persistent_info WHERE user_id = ?`, + u.ID, + ) + }) + require.NotEmpty(t, persistentInfo.ID) + require.Equal(t, u.ID, *persistentInfo.UserID) + require.Equal(t, u.Name, persistentInfo.UserName) + require.Equal(t, u.Email, persistentInfo.UserEmail) + } } From 490c25fbcf29d10f0e28d002ae00266caed79cec Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Thu, 14 Mar 2024 10:18:52 -0300 Subject: [PATCH 5/6] update migration timestamps --- ...0314101544_TrackUserReferencesForCommandsAndProfiles.go} | 6 +++--- ...01544_TrackUserReferencesForCommandsAndProfiles_test.go} | 3 +-- server/datastore/mysql/schema.sql | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) rename server/datastore/mysql/migrations/tables/{20240313143039_TrackUserReferencesForCommandsAndProfiles.go => 20240314101544_TrackUserReferencesForCommandsAndProfiles.go} (94%) rename server/datastore/mysql/migrations/tables/{20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go => 20240314101544_TrackUserReferencesForCommandsAndProfiles_test.go} (99%) diff --git a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go b/server/datastore/mysql/migrations/tables/20240314101544_TrackUserReferencesForCommandsAndProfiles.go similarity index 94% rename from server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go rename to server/datastore/mysql/migrations/tables/20240314101544_TrackUserReferencesForCommandsAndProfiles.go index 2b89cc01958..e96ebe6f3cd 100644 --- a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles.go +++ b/server/datastore/mysql/migrations/tables/20240314101544_TrackUserReferencesForCommandsAndProfiles.go @@ -6,10 +6,10 @@ import ( ) func init() { - MigrationClient.AddMigration(Up_20240313143039, Down_20240313143039) + MigrationClient.AddMigration(Up_20240314101544, Down_20240314101544) } -func Up_20240313143039(tx *sql.Tx) error { +func Up_20240314101544(tx *sql.Tx) error { // create a new table to store user information that's persisted after // users are deleted. _, err := tx.Exec(` @@ -83,6 +83,6 @@ func Up_20240313143039(tx *sql.Tx) error { return nil } -func Down_20240313143039(tx *sql.Tx) error { +func Down_20240314101544(tx *sql.Tx) error { return nil } diff --git a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go b/server/datastore/mysql/migrations/tables/20240314101544_TrackUserReferencesForCommandsAndProfiles_test.go similarity index 99% rename from server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go rename to server/datastore/mysql/migrations/tables/20240314101544_TrackUserReferencesForCommandsAndProfiles_test.go index 915f99d2384..dc43e520e1c 100644 --- a/server/datastore/mysql/migrations/tables/20240313143039_TrackUserReferencesForCommandsAndProfiles_test.go +++ b/server/datastore/mysql/migrations/tables/20240314101544_TrackUserReferencesForCommandsAndProfiles_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestUp_20240313143039(t *testing.T) { +func TestUp_20240314101544(t *testing.T) { db := applyUpToPrev(t) dataStmts := ` @@ -152,5 +152,4 @@ INSERT INTO _, err = db.Exec(fmt.Sprintf("UPDATE %s SET user_persistent_info_id = 9", table)) require.ErrorContains(t, err, "foreign key constraint fails") } - } diff --git a/server/datastore/mysql/schema.sql b/server/datastore/mysql/schema.sql index 4cd4f3dc82d..507a88292c2 100644 --- a/server/datastore/mysql/schema.sql +++ b/server/datastore/mysql/schema.sql @@ -789,7 +789,7 @@ CREATE TABLE `migration_status_tables` ( UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=258 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -INSERT INTO `migration_status_tables` VALUES (1,0,1,'2020-01-01 01:01:01'),(2,20161118193812,1,'2020-01-01 01:01:01'),(3,20161118211713,1,'2020-01-01 01:01:01'),(4,20161118212436,1,'2020-01-01 01:01:01'),(5,20161118212515,1,'2020-01-01 01:01:01'),(6,20161118212528,1,'2020-01-01 01:01:01'),(7,20161118212538,1,'2020-01-01 01:01:01'),(8,20161118212549,1,'2020-01-01 01:01:01'),(9,20161118212557,1,'2020-01-01 01:01:01'),(10,20161118212604,1,'2020-01-01 01:01:01'),(11,20161118212613,1,'2020-01-01 01:01:01'),(12,20161118212621,1,'2020-01-01 01:01:01'),(13,20161118212630,1,'2020-01-01 01:01:01'),(14,20161118212641,1,'2020-01-01 01:01:01'),(15,20161118212649,1,'2020-01-01 01:01:01'),(16,20161118212656,1,'2020-01-01 01:01:01'),(17,20161118212758,1,'2020-01-01 01:01:01'),(18,20161128234849,1,'2020-01-01 01:01:01'),(19,20161230162221,1,'2020-01-01 01:01:01'),(20,20170104113816,1,'2020-01-01 01:01:01'),(21,20170105151732,1,'2020-01-01 01:01:01'),(22,20170108191242,1,'2020-01-01 01:01:01'),(23,20170109094020,1,'2020-01-01 01:01:01'),(24,20170109130438,1,'2020-01-01 01:01:01'),(25,20170110202752,1,'2020-01-01 01:01:01'),(26,20170111133013,1,'2020-01-01 01:01:01'),(27,20170117025759,1,'2020-01-01 01:01:01'),(28,20170118191001,1,'2020-01-01 01:01:01'),(29,20170119234632,1,'2020-01-01 01:01:01'),(30,20170124230432,1,'2020-01-01 01:01:01'),(31,20170127014618,1,'2020-01-01 01:01:01'),(32,20170131232841,1,'2020-01-01 01:01:01'),(33,20170223094154,1,'2020-01-01 01:01:01'),(34,20170306075207,1,'2020-01-01 01:01:01'),(35,20170309100733,1,'2020-01-01 01:01:01'),(36,20170331111922,1,'2020-01-01 01:01:01'),(37,20170502143928,1,'2020-01-01 01:01:01'),(38,20170504130602,1,'2020-01-01 01:01:01'),(39,20170509132100,1,'2020-01-01 01:01:01'),(40,20170519105647,1,'2020-01-01 01:01:01'),(41,20170519105648,1,'2020-01-01 01:01:01'),(42,20170831234300,1,'2020-01-01 01:01:01'),(43,20170831234301,1,'2020-01-01 01:01:01'),(44,20170831234303,1,'2020-01-01 01:01:01'),(45,20171116163618,1,'2020-01-01 01:01:01'),(46,20171219164727,1,'2020-01-01 01:01:01'),(47,20180620164811,1,'2020-01-01 01:01:01'),(48,20180620175054,1,'2020-01-01 01:01:01'),(49,20180620175055,1,'2020-01-01 01:01:01'),(50,20191010101639,1,'2020-01-01 01:01:01'),(51,20191010155147,1,'2020-01-01 01:01:01'),(52,20191220130734,1,'2020-01-01 01:01:01'),(53,20200311140000,1,'2020-01-01 01:01:01'),(54,20200405120000,1,'2020-01-01 01:01:01'),(55,20200407120000,1,'2020-01-01 01:01:01'),(56,20200420120000,1,'2020-01-01 01:01:01'),(57,20200504120000,1,'2020-01-01 01:01:01'),(58,20200512120000,1,'2020-01-01 01:01:01'),(59,20200707120000,1,'2020-01-01 01:01:01'),(60,20201011162341,1,'2020-01-01 01:01:01'),(61,20201021104586,1,'2020-01-01 01:01:01'),(62,20201102112520,1,'2020-01-01 01:01:01'),(63,20201208121729,1,'2020-01-01 01:01:01'),(64,20201215091637,1,'2020-01-01 01:01:01'),(65,20210119174155,1,'2020-01-01 01:01:01'),(66,20210326182902,1,'2020-01-01 01:01:01'),(67,20210421112652,1,'2020-01-01 01:01:01'),(68,20210506095025,1,'2020-01-01 01:01:01'),(69,20210513115729,1,'2020-01-01 01:01:01'),(70,20210526113559,1,'2020-01-01 01:01:01'),(71,20210601000001,1,'2020-01-01 01:01:01'),(72,20210601000002,1,'2020-01-01 01:01:01'),(73,20210601000003,1,'2020-01-01 01:01:01'),(74,20210601000004,1,'2020-01-01 01:01:01'),(75,20210601000005,1,'2020-01-01 01:01:01'),(76,20210601000006,1,'2020-01-01 01:01:01'),(77,20210601000007,1,'2020-01-01 01:01:01'),(78,20210601000008,1,'2020-01-01 01:01:01'),(79,20210606151329,1,'2020-01-01 01:01:01'),(80,20210616163757,1,'2020-01-01 01:01:01'),(81,20210617174723,1,'2020-01-01 01:01:01'),(82,20210622160235,1,'2020-01-01 01:01:01'),(83,20210623100031,1,'2020-01-01 01:01:01'),(84,20210623133615,1,'2020-01-01 01:01:01'),(85,20210708143152,1,'2020-01-01 01:01:01'),(86,20210709124443,1,'2020-01-01 01:01:01'),(87,20210712155608,1,'2020-01-01 01:01:01'),(88,20210714102108,1,'2020-01-01 01:01:01'),(89,20210719153709,1,'2020-01-01 01:01:01'),(90,20210721171531,1,'2020-01-01 01:01:01'),(91,20210723135713,1,'2020-01-01 01:01:01'),(92,20210802135933,1,'2020-01-01 01:01:01'),(93,20210806112844,1,'2020-01-01 01:01:01'),(94,20210810095603,1,'2020-01-01 01:01:01'),(95,20210811150223,1,'2020-01-01 01:01:01'),(96,20210818151827,1,'2020-01-01 01:01:01'),(97,20210818151828,1,'2020-01-01 01:01:01'),(98,20210818182258,1,'2020-01-01 01:01:01'),(99,20210819131107,1,'2020-01-01 01:01:01'),(100,20210819143446,1,'2020-01-01 01:01:01'),(101,20210903132338,1,'2020-01-01 01:01:01'),(102,20210915144307,1,'2020-01-01 01:01:01'),(103,20210920155130,1,'2020-01-01 01:01:01'),(104,20210927143115,1,'2020-01-01 01:01:01'),(105,20210927143116,1,'2020-01-01 01:01:01'),(106,20211013133706,1,'2020-01-01 01:01:01'),(107,20211013133707,1,'2020-01-01 01:01:01'),(108,20211102135149,1,'2020-01-01 01:01:01'),(109,20211109121546,1,'2020-01-01 01:01:01'),(110,20211110163320,1,'2020-01-01 01:01:01'),(111,20211116184029,1,'2020-01-01 01:01:01'),(112,20211116184030,1,'2020-01-01 01:01:01'),(113,20211202092042,1,'2020-01-01 01:01:01'),(114,20211202181033,1,'2020-01-01 01:01:01'),(115,20211207161856,1,'2020-01-01 01:01:01'),(116,20211216131203,1,'2020-01-01 01:01:01'),(117,20211221110132,1,'2020-01-01 01:01:01'),(118,20220107155700,1,'2020-01-01 01:01:01'),(119,20220125105650,1,'2020-01-01 01:01:01'),(120,20220201084510,1,'2020-01-01 01:01:01'),(121,20220208144830,1,'2020-01-01 01:01:01'),(122,20220208144831,1,'2020-01-01 01:01:01'),(123,20220215152203,1,'2020-01-01 01:01:01'),(124,20220223113157,1,'2020-01-01 01:01:01'),(125,20220307104655,1,'2020-01-01 01:01:01'),(126,20220309133956,1,'2020-01-01 01:01:01'),(127,20220316155700,1,'2020-01-01 01:01:01'),(128,20220323152301,1,'2020-01-01 01:01:01'),(129,20220330100659,1,'2020-01-01 01:01:01'),(130,20220404091216,1,'2020-01-01 01:01:01'),(131,20220419140750,1,'2020-01-01 01:01:01'),(132,20220428140039,1,'2020-01-01 01:01:01'),(133,20220503134048,1,'2020-01-01 01:01:01'),(134,20220524102918,1,'2020-01-01 01:01:01'),(135,20220526123327,1,'2020-01-01 01:01:01'),(136,20220526123328,1,'2020-01-01 01:01:01'),(137,20220526123329,1,'2020-01-01 01:01:01'),(138,20220608113128,1,'2020-01-01 01:01:01'),(139,20220627104817,1,'2020-01-01 01:01:01'),(140,20220704101843,1,'2020-01-01 01:01:01'),(141,20220708095046,1,'2020-01-01 01:01:01'),(142,20220713091130,1,'2020-01-01 01:01:01'),(143,20220802135510,1,'2020-01-01 01:01:01'),(144,20220818101352,1,'2020-01-01 01:01:01'),(145,20220822161445,1,'2020-01-01 01:01:01'),(146,20220831100036,1,'2020-01-01 01:01:01'),(147,20220831100151,1,'2020-01-01 01:01:01'),(148,20220908181826,1,'2020-01-01 01:01:01'),(149,20220914154915,1,'2020-01-01 01:01:01'),(150,20220915165115,1,'2020-01-01 01:01:01'),(151,20220915165116,1,'2020-01-01 01:01:01'),(152,20220928100158,1,'2020-01-01 01:01:01'),(153,20221014084130,1,'2020-01-01 01:01:01'),(154,20221027085019,1,'2020-01-01 01:01:01'),(155,20221101103952,1,'2020-01-01 01:01:01'),(156,20221104144401,1,'2020-01-01 01:01:01'),(157,20221109100749,1,'2020-01-01 01:01:01'),(158,20221115104546,1,'2020-01-01 01:01:01'),(159,20221130114928,1,'2020-01-01 01:01:01'),(160,20221205112142,1,'2020-01-01 01:01:01'),(161,20221216115820,1,'2020-01-01 01:01:01'),(162,20221220195934,1,'2020-01-01 01:01:01'),(163,20221220195935,1,'2020-01-01 01:01:01'),(164,20221223174807,1,'2020-01-01 01:01:01'),(165,20221227163855,1,'2020-01-01 01:01:01'),(166,20221227163856,1,'2020-01-01 01:01:01'),(167,20230202224725,1,'2020-01-01 01:01:01'),(168,20230206163608,1,'2020-01-01 01:01:01'),(169,20230214131519,1,'2020-01-01 01:01:01'),(170,20230303135738,1,'2020-01-01 01:01:01'),(171,20230313135301,1,'2020-01-01 01:01:01'),(172,20230313141819,1,'2020-01-01 01:01:01'),(173,20230315104937,1,'2020-01-01 01:01:01'),(174,20230317173844,1,'2020-01-01 01:01:01'),(175,20230320133602,1,'2020-01-01 01:01:01'),(176,20230330100011,1,'2020-01-01 01:01:01'),(177,20230330134823,1,'2020-01-01 01:01:01'),(178,20230405232025,1,'2020-01-01 01:01:01'),(179,20230408084104,1,'2020-01-01 01:01:01'),(180,20230411102858,1,'2020-01-01 01:01:01'),(181,20230421155932,1,'2020-01-01 01:01:01'),(182,20230425082126,1,'2020-01-01 01:01:01'),(183,20230425105727,1,'2020-01-01 01:01:01'),(184,20230501154913,1,'2020-01-01 01:01:01'),(185,20230503101418,1,'2020-01-01 01:01:01'),(186,20230515144206,1,'2020-01-01 01:01:01'),(187,20230517140952,1,'2020-01-01 01:01:01'),(188,20230517152807,1,'2020-01-01 01:01:01'),(189,20230518114155,1,'2020-01-01 01:01:01'),(190,20230520153236,1,'2020-01-01 01:01:01'),(191,20230525151159,1,'2020-01-01 01:01:01'),(192,20230530122103,1,'2020-01-01 01:01:01'),(193,20230602111827,1,'2020-01-01 01:01:01'),(194,20230608103123,1,'2020-01-01 01:01:01'),(195,20230629140529,1,'2020-01-01 01:01:01'),(196,20230629140530,1,'2020-01-01 01:01:01'),(197,20230711144622,1,'2020-01-01 01:01:01'),(198,20230721135421,1,'2020-01-01 01:01:01'),(199,20230721161508,1,'2020-01-01 01:01:01'),(200,20230726115701,1,'2020-01-01 01:01:01'),(201,20230807100822,1,'2020-01-01 01:01:01'),(202,20230814150442,1,'2020-01-01 01:01:01'),(203,20230823122728,1,'2020-01-01 01:01:01'),(204,20230906152143,1,'2020-01-01 01:01:01'),(205,20230911163618,1,'2020-01-01 01:01:01'),(206,20230912101759,1,'2020-01-01 01:01:01'),(207,20230915101341,1,'2020-01-01 01:01:01'),(208,20230918132351,1,'2020-01-01 01:01:01'),(209,20231004144339,1,'2020-01-01 01:01:01'),(210,20231009094541,1,'2020-01-01 01:01:01'),(211,20231009094542,1,'2020-01-01 01:01:01'),(212,20231009094543,1,'2020-01-01 01:01:01'),(213,20231009094544,1,'2020-01-01 01:01:01'),(214,20231016091915,1,'2020-01-01 01:01:01'),(215,20231024174135,1,'2020-01-01 01:01:01'),(216,20231025120016,1,'2020-01-01 01:01:01'),(217,20231025160156,1,'2020-01-01 01:01:01'),(218,20231031165350,1,'2020-01-01 01:01:01'),(219,20231106144110,1,'2020-01-01 01:01:01'),(220,20231107130934,1,'2020-01-01 01:01:01'),(221,20231109115838,1,'2020-01-01 01:01:01'),(222,20231121054530,1,'2020-01-01 01:01:01'),(223,20231122101320,1,'2020-01-01 01:01:01'),(224,20231130132828,1,'2020-01-01 01:01:01'),(225,20231130132931,1,'2020-01-01 01:01:01'),(226,20231204155427,1,'2020-01-01 01:01:01'),(227,20231206142340,1,'2020-01-01 01:01:01'),(228,20231207102320,1,'2020-01-01 01:01:01'),(229,20231207102321,1,'2020-01-01 01:01:01'),(230,20231207133731,1,'2020-01-01 01:01:01'),(231,20231212094238,1,'2020-01-01 01:01:01'),(232,20231212095734,1,'2020-01-01 01:01:01'),(233,20231212161121,1,'2020-01-01 01:01:01'),(234,20231215122713,1,'2020-01-01 01:01:01'),(235,20231219143041,1,'2020-01-01 01:01:01'),(236,20231224070653,1,'2020-01-01 01:01:01'),(237,20240110134315,1,'2020-01-01 01:01:01'),(238,20240119091637,1,'2020-01-01 01:01:01'),(239,20240126020642,1,'2020-01-01 01:01:01'),(240,20240126020643,1,'2020-01-01 01:01:01'),(241,20240129162819,1,'2020-01-01 01:01:01'),(242,20240130115133,1,'2020-01-01 01:01:01'),(243,20240131083822,1,'2020-01-01 01:01:01'),(244,20240205095928,1,'2020-01-01 01:01:01'),(245,20240205121956,1,'2020-01-01 01:01:01'),(246,20240209110212,1,'2020-01-01 01:01:01'),(247,20240212111533,1,'2020-01-01 01:01:01'),(248,20240221112844,1,'2020-01-01 01:01:01'),(249,20240222073518,1,'2020-01-01 01:01:01'),(250,20240222135115,1,'2020-01-01 01:01:01'),(251,20240226082255,1,'2020-01-01 01:01:01'),(252,20240228082706,1,'2020-01-01 01:01:01'),(253,20240301173035,1,'2020-01-01 01:01:01'),(254,20240302111134,1,'2020-01-01 01:01:01'),(255,20240312103753,1,'2020-01-01 01:01:01'),(256,20240313143039,1,'2020-01-01 01:01:01'),(257,20240313143416,1,'2020-01-01 01:01:01'); +INSERT INTO `migration_status_tables` VALUES (1,0,1,'2020-01-01 01:01:01'),(2,20161118193812,1,'2020-01-01 01:01:01'),(3,20161118211713,1,'2020-01-01 01:01:01'),(4,20161118212436,1,'2020-01-01 01:01:01'),(5,20161118212515,1,'2020-01-01 01:01:01'),(6,20161118212528,1,'2020-01-01 01:01:01'),(7,20161118212538,1,'2020-01-01 01:01:01'),(8,20161118212549,1,'2020-01-01 01:01:01'),(9,20161118212557,1,'2020-01-01 01:01:01'),(10,20161118212604,1,'2020-01-01 01:01:01'),(11,20161118212613,1,'2020-01-01 01:01:01'),(12,20161118212621,1,'2020-01-01 01:01:01'),(13,20161118212630,1,'2020-01-01 01:01:01'),(14,20161118212641,1,'2020-01-01 01:01:01'),(15,20161118212649,1,'2020-01-01 01:01:01'),(16,20161118212656,1,'2020-01-01 01:01:01'),(17,20161118212758,1,'2020-01-01 01:01:01'),(18,20161128234849,1,'2020-01-01 01:01:01'),(19,20161230162221,1,'2020-01-01 01:01:01'),(20,20170104113816,1,'2020-01-01 01:01:01'),(21,20170105151732,1,'2020-01-01 01:01:01'),(22,20170108191242,1,'2020-01-01 01:01:01'),(23,20170109094020,1,'2020-01-01 01:01:01'),(24,20170109130438,1,'2020-01-01 01:01:01'),(25,20170110202752,1,'2020-01-01 01:01:01'),(26,20170111133013,1,'2020-01-01 01:01:01'),(27,20170117025759,1,'2020-01-01 01:01:01'),(28,20170118191001,1,'2020-01-01 01:01:01'),(29,20170119234632,1,'2020-01-01 01:01:01'),(30,20170124230432,1,'2020-01-01 01:01:01'),(31,20170127014618,1,'2020-01-01 01:01:01'),(32,20170131232841,1,'2020-01-01 01:01:01'),(33,20170223094154,1,'2020-01-01 01:01:01'),(34,20170306075207,1,'2020-01-01 01:01:01'),(35,20170309100733,1,'2020-01-01 01:01:01'),(36,20170331111922,1,'2020-01-01 01:01:01'),(37,20170502143928,1,'2020-01-01 01:01:01'),(38,20170504130602,1,'2020-01-01 01:01:01'),(39,20170509132100,1,'2020-01-01 01:01:01'),(40,20170519105647,1,'2020-01-01 01:01:01'),(41,20170519105648,1,'2020-01-01 01:01:01'),(42,20170831234300,1,'2020-01-01 01:01:01'),(43,20170831234301,1,'2020-01-01 01:01:01'),(44,20170831234303,1,'2020-01-01 01:01:01'),(45,20171116163618,1,'2020-01-01 01:01:01'),(46,20171219164727,1,'2020-01-01 01:01:01'),(47,20180620164811,1,'2020-01-01 01:01:01'),(48,20180620175054,1,'2020-01-01 01:01:01'),(49,20180620175055,1,'2020-01-01 01:01:01'),(50,20191010101639,1,'2020-01-01 01:01:01'),(51,20191010155147,1,'2020-01-01 01:01:01'),(52,20191220130734,1,'2020-01-01 01:01:01'),(53,20200311140000,1,'2020-01-01 01:01:01'),(54,20200405120000,1,'2020-01-01 01:01:01'),(55,20200407120000,1,'2020-01-01 01:01:01'),(56,20200420120000,1,'2020-01-01 01:01:01'),(57,20200504120000,1,'2020-01-01 01:01:01'),(58,20200512120000,1,'2020-01-01 01:01:01'),(59,20200707120000,1,'2020-01-01 01:01:01'),(60,20201011162341,1,'2020-01-01 01:01:01'),(61,20201021104586,1,'2020-01-01 01:01:01'),(62,20201102112520,1,'2020-01-01 01:01:01'),(63,20201208121729,1,'2020-01-01 01:01:01'),(64,20201215091637,1,'2020-01-01 01:01:01'),(65,20210119174155,1,'2020-01-01 01:01:01'),(66,20210326182902,1,'2020-01-01 01:01:01'),(67,20210421112652,1,'2020-01-01 01:01:01'),(68,20210506095025,1,'2020-01-01 01:01:01'),(69,20210513115729,1,'2020-01-01 01:01:01'),(70,20210526113559,1,'2020-01-01 01:01:01'),(71,20210601000001,1,'2020-01-01 01:01:01'),(72,20210601000002,1,'2020-01-01 01:01:01'),(73,20210601000003,1,'2020-01-01 01:01:01'),(74,20210601000004,1,'2020-01-01 01:01:01'),(75,20210601000005,1,'2020-01-01 01:01:01'),(76,20210601000006,1,'2020-01-01 01:01:01'),(77,20210601000007,1,'2020-01-01 01:01:01'),(78,20210601000008,1,'2020-01-01 01:01:01'),(79,20210606151329,1,'2020-01-01 01:01:01'),(80,20210616163757,1,'2020-01-01 01:01:01'),(81,20210617174723,1,'2020-01-01 01:01:01'),(82,20210622160235,1,'2020-01-01 01:01:01'),(83,20210623100031,1,'2020-01-01 01:01:01'),(84,20210623133615,1,'2020-01-01 01:01:01'),(85,20210708143152,1,'2020-01-01 01:01:01'),(86,20210709124443,1,'2020-01-01 01:01:01'),(87,20210712155608,1,'2020-01-01 01:01:01'),(88,20210714102108,1,'2020-01-01 01:01:01'),(89,20210719153709,1,'2020-01-01 01:01:01'),(90,20210721171531,1,'2020-01-01 01:01:01'),(91,20210723135713,1,'2020-01-01 01:01:01'),(92,20210802135933,1,'2020-01-01 01:01:01'),(93,20210806112844,1,'2020-01-01 01:01:01'),(94,20210810095603,1,'2020-01-01 01:01:01'),(95,20210811150223,1,'2020-01-01 01:01:01'),(96,20210818151827,1,'2020-01-01 01:01:01'),(97,20210818151828,1,'2020-01-01 01:01:01'),(98,20210818182258,1,'2020-01-01 01:01:01'),(99,20210819131107,1,'2020-01-01 01:01:01'),(100,20210819143446,1,'2020-01-01 01:01:01'),(101,20210903132338,1,'2020-01-01 01:01:01'),(102,20210915144307,1,'2020-01-01 01:01:01'),(103,20210920155130,1,'2020-01-01 01:01:01'),(104,20210927143115,1,'2020-01-01 01:01:01'),(105,20210927143116,1,'2020-01-01 01:01:01'),(106,20211013133706,1,'2020-01-01 01:01:01'),(107,20211013133707,1,'2020-01-01 01:01:01'),(108,20211102135149,1,'2020-01-01 01:01:01'),(109,20211109121546,1,'2020-01-01 01:01:01'),(110,20211110163320,1,'2020-01-01 01:01:01'),(111,20211116184029,1,'2020-01-01 01:01:01'),(112,20211116184030,1,'2020-01-01 01:01:01'),(113,20211202092042,1,'2020-01-01 01:01:01'),(114,20211202181033,1,'2020-01-01 01:01:01'),(115,20211207161856,1,'2020-01-01 01:01:01'),(116,20211216131203,1,'2020-01-01 01:01:01'),(117,20211221110132,1,'2020-01-01 01:01:01'),(118,20220107155700,1,'2020-01-01 01:01:01'),(119,20220125105650,1,'2020-01-01 01:01:01'),(120,20220201084510,1,'2020-01-01 01:01:01'),(121,20220208144830,1,'2020-01-01 01:01:01'),(122,20220208144831,1,'2020-01-01 01:01:01'),(123,20220215152203,1,'2020-01-01 01:01:01'),(124,20220223113157,1,'2020-01-01 01:01:01'),(125,20220307104655,1,'2020-01-01 01:01:01'),(126,20220309133956,1,'2020-01-01 01:01:01'),(127,20220316155700,1,'2020-01-01 01:01:01'),(128,20220323152301,1,'2020-01-01 01:01:01'),(129,20220330100659,1,'2020-01-01 01:01:01'),(130,20220404091216,1,'2020-01-01 01:01:01'),(131,20220419140750,1,'2020-01-01 01:01:01'),(132,20220428140039,1,'2020-01-01 01:01:01'),(133,20220503134048,1,'2020-01-01 01:01:01'),(134,20220524102918,1,'2020-01-01 01:01:01'),(135,20220526123327,1,'2020-01-01 01:01:01'),(136,20220526123328,1,'2020-01-01 01:01:01'),(137,20220526123329,1,'2020-01-01 01:01:01'),(138,20220608113128,1,'2020-01-01 01:01:01'),(139,20220627104817,1,'2020-01-01 01:01:01'),(140,20220704101843,1,'2020-01-01 01:01:01'),(141,20220708095046,1,'2020-01-01 01:01:01'),(142,20220713091130,1,'2020-01-01 01:01:01'),(143,20220802135510,1,'2020-01-01 01:01:01'),(144,20220818101352,1,'2020-01-01 01:01:01'),(145,20220822161445,1,'2020-01-01 01:01:01'),(146,20220831100036,1,'2020-01-01 01:01:01'),(147,20220831100151,1,'2020-01-01 01:01:01'),(148,20220908181826,1,'2020-01-01 01:01:01'),(149,20220914154915,1,'2020-01-01 01:01:01'),(150,20220915165115,1,'2020-01-01 01:01:01'),(151,20220915165116,1,'2020-01-01 01:01:01'),(152,20220928100158,1,'2020-01-01 01:01:01'),(153,20221014084130,1,'2020-01-01 01:01:01'),(154,20221027085019,1,'2020-01-01 01:01:01'),(155,20221101103952,1,'2020-01-01 01:01:01'),(156,20221104144401,1,'2020-01-01 01:01:01'),(157,20221109100749,1,'2020-01-01 01:01:01'),(158,20221115104546,1,'2020-01-01 01:01:01'),(159,20221130114928,1,'2020-01-01 01:01:01'),(160,20221205112142,1,'2020-01-01 01:01:01'),(161,20221216115820,1,'2020-01-01 01:01:01'),(162,20221220195934,1,'2020-01-01 01:01:01'),(163,20221220195935,1,'2020-01-01 01:01:01'),(164,20221223174807,1,'2020-01-01 01:01:01'),(165,20221227163855,1,'2020-01-01 01:01:01'),(166,20221227163856,1,'2020-01-01 01:01:01'),(167,20230202224725,1,'2020-01-01 01:01:01'),(168,20230206163608,1,'2020-01-01 01:01:01'),(169,20230214131519,1,'2020-01-01 01:01:01'),(170,20230303135738,1,'2020-01-01 01:01:01'),(171,20230313135301,1,'2020-01-01 01:01:01'),(172,20230313141819,1,'2020-01-01 01:01:01'),(173,20230315104937,1,'2020-01-01 01:01:01'),(174,20230317173844,1,'2020-01-01 01:01:01'),(175,20230320133602,1,'2020-01-01 01:01:01'),(176,20230330100011,1,'2020-01-01 01:01:01'),(177,20230330134823,1,'2020-01-01 01:01:01'),(178,20230405232025,1,'2020-01-01 01:01:01'),(179,20230408084104,1,'2020-01-01 01:01:01'),(180,20230411102858,1,'2020-01-01 01:01:01'),(181,20230421155932,1,'2020-01-01 01:01:01'),(182,20230425082126,1,'2020-01-01 01:01:01'),(183,20230425105727,1,'2020-01-01 01:01:01'),(184,20230501154913,1,'2020-01-01 01:01:01'),(185,20230503101418,1,'2020-01-01 01:01:01'),(186,20230515144206,1,'2020-01-01 01:01:01'),(187,20230517140952,1,'2020-01-01 01:01:01'),(188,20230517152807,1,'2020-01-01 01:01:01'),(189,20230518114155,1,'2020-01-01 01:01:01'),(190,20230520153236,1,'2020-01-01 01:01:01'),(191,20230525151159,1,'2020-01-01 01:01:01'),(192,20230530122103,1,'2020-01-01 01:01:01'),(193,20230602111827,1,'2020-01-01 01:01:01'),(194,20230608103123,1,'2020-01-01 01:01:01'),(195,20230629140529,1,'2020-01-01 01:01:01'),(196,20230629140530,1,'2020-01-01 01:01:01'),(197,20230711144622,1,'2020-01-01 01:01:01'),(198,20230721135421,1,'2020-01-01 01:01:01'),(199,20230721161508,1,'2020-01-01 01:01:01'),(200,20230726115701,1,'2020-01-01 01:01:01'),(201,20230807100822,1,'2020-01-01 01:01:01'),(202,20230814150442,1,'2020-01-01 01:01:01'),(203,20230823122728,1,'2020-01-01 01:01:01'),(204,20230906152143,1,'2020-01-01 01:01:01'),(205,20230911163618,1,'2020-01-01 01:01:01'),(206,20230912101759,1,'2020-01-01 01:01:01'),(207,20230915101341,1,'2020-01-01 01:01:01'),(208,20230918132351,1,'2020-01-01 01:01:01'),(209,20231004144339,1,'2020-01-01 01:01:01'),(210,20231009094541,1,'2020-01-01 01:01:01'),(211,20231009094542,1,'2020-01-01 01:01:01'),(212,20231009094543,1,'2020-01-01 01:01:01'),(213,20231009094544,1,'2020-01-01 01:01:01'),(214,20231016091915,1,'2020-01-01 01:01:01'),(215,20231024174135,1,'2020-01-01 01:01:01'),(216,20231025120016,1,'2020-01-01 01:01:01'),(217,20231025160156,1,'2020-01-01 01:01:01'),(218,20231031165350,1,'2020-01-01 01:01:01'),(219,20231106144110,1,'2020-01-01 01:01:01'),(220,20231107130934,1,'2020-01-01 01:01:01'),(221,20231109115838,1,'2020-01-01 01:01:01'),(222,20231121054530,1,'2020-01-01 01:01:01'),(223,20231122101320,1,'2020-01-01 01:01:01'),(224,20231130132828,1,'2020-01-01 01:01:01'),(225,20231130132931,1,'2020-01-01 01:01:01'),(226,20231204155427,1,'2020-01-01 01:01:01'),(227,20231206142340,1,'2020-01-01 01:01:01'),(228,20231207102320,1,'2020-01-01 01:01:01'),(229,20231207102321,1,'2020-01-01 01:01:01'),(230,20231207133731,1,'2020-01-01 01:01:01'),(231,20231212094238,1,'2020-01-01 01:01:01'),(232,20231212095734,1,'2020-01-01 01:01:01'),(233,20231212161121,1,'2020-01-01 01:01:01'),(234,20231215122713,1,'2020-01-01 01:01:01'),(235,20231219143041,1,'2020-01-01 01:01:01'),(236,20231224070653,1,'2020-01-01 01:01:01'),(237,20240110134315,1,'2020-01-01 01:01:01'),(238,20240119091637,1,'2020-01-01 01:01:01'),(239,20240126020642,1,'2020-01-01 01:01:01'),(240,20240126020643,1,'2020-01-01 01:01:01'),(241,20240129162819,1,'2020-01-01 01:01:01'),(242,20240130115133,1,'2020-01-01 01:01:01'),(243,20240131083822,1,'2020-01-01 01:01:01'),(244,20240205095928,1,'2020-01-01 01:01:01'),(245,20240205121956,1,'2020-01-01 01:01:01'),(246,20240209110212,1,'2020-01-01 01:01:01'),(247,20240212111533,1,'2020-01-01 01:01:01'),(248,20240221112844,1,'2020-01-01 01:01:01'),(249,20240222073518,1,'2020-01-01 01:01:01'),(250,20240222135115,1,'2020-01-01 01:01:01'),(251,20240226082255,1,'2020-01-01 01:01:01'),(252,20240228082706,1,'2020-01-01 01:01:01'),(253,20240301173035,1,'2020-01-01 01:01:01'),(254,20240302111134,1,'2020-01-01 01:01:01'),(255,20240312103753,1,'2020-01-01 01:01:01'),(256,20240313143416,1,'2020-01-01 01:01:01'),(257,20240314101544,1,'2020-01-01 01:01:01'); /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mobile_device_management_solutions` ( From 4243e9dd540201eb893354b6716b5b5b65f4f0d4 Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Thu, 14 Mar 2024 10:55:28 -0300 Subject: [PATCH 6/6] fix tests --- server/fleet/apple_mdm.go | 9 +++++++++ server/fleet/windows_mdm.go | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/server/fleet/apple_mdm.go b/server/fleet/apple_mdm.go index 02a0b65f478..f971c5650f6 100644 --- a/server/fleet/apple_mdm.go +++ b/server/fleet/apple_mdm.go @@ -209,6 +209,15 @@ type MDMAppleConfigProfile struct { Labels []ConfigurationProfileLabel `db:"labels" json:"labels,omitempty"` CreatedAt time.Time `db:"created_at" json:"created_at"` UploadedAt time.Time `db:"uploaded_at" json:"updated_at"` // NOTE: JSON field is still `updated_at` for historical reasons, would be an API breaking change + + // UserPersistentInfoID references user information about the actor + // that created this profile + UserPersistentInfoID *uint `db:"user_persistent_info_id"` + + // FleetOwned indicates if the profile was crated/managed by Fleet. + // Profiles prior to the introduction of this field will have a nil + // value. + FleetOwned *bool `db:"fleet_owned"` } // ConfigurationProfileLabel represents the many-to-many relationship between diff --git a/server/fleet/windows_mdm.go b/server/fleet/windows_mdm.go index a83fa4d5f15..bcf1fb40d9a 100644 --- a/server/fleet/windows_mdm.go +++ b/server/fleet/windows_mdm.go @@ -39,6 +39,15 @@ type MDMWindowsConfigProfile struct { Labels []ConfigurationProfileLabel `db:"labels" json:"labels,omitempty"` CreatedAt time.Time `db:"created_at" json:"created_at"` UploadedAt time.Time `db:"uploaded_at" json:"updated_at"` // NOTE: JSON field is still `updated_at` for historical reasons, would be an API breaking change + + // UserPersistentInfoID references user information about the actor + // that created this profile + UserPersistentInfoID *uint `db:"user_persistent_info_id"` + + // FleetOwned indicates if the profile was crated/managed by Fleet. + // Profiles prior to the introduction of this field will have a nil + // value. + FleetOwned *bool `db:"fleet_owned"` } // ValidateUserProvided ensures that the SyncML content in the profile is valid