query(<<<'SQL' CREATE TABLE IF NOT EXISTS `limited_backoffice_employees` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `managed_group_id` INT NOT NULL, `role_key` VARCHAR(64) NOT NULL, `department_ids` LONGTEXT NOT NULL, `created_by_user_id` INT NOT NULL, `updated_by_user_id` INT NULL, `deactivated_at` DATETIME NULL, `created_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uniq_limited_backoffice_employees_user_id` (`user_id`), KEY `idx_limited_backoffice_employees_group_id` (`managed_group_id`), KEY `idx_limited_backoffice_employees_role_key` (`role_key`), KEY `idx_limited_backoffice_employees_deactivated_at` (`deactivated_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci SQL); $db->query(<<<'SQL' CREATE TABLE IF NOT EXISTS `limited_backoffice_login_grants` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `grant_id` CHAR(32) NOT NULL, `secret_hash` CHAR(64) NOT NULL, `target_user_id` INT NOT NULL, `actor_user_id` INT NOT NULL, `purpose` VARCHAR(64) NOT NULL, `idempotency_key_hash` CHAR(64) NULL, `expires_at` BIGINT UNSIGNED NOT NULL, `consumed_at` DATETIME NULL, `revoked_at` DATETIME NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uniq_limited_backoffice_login_grants_grant_id` (`grant_id`), UNIQUE KEY `uniq_limited_backoffice_login_grants_secret_hash` (`secret_hash`), UNIQUE KEY `uniq_limited_backoffice_login_grants_idempotency` (`actor_user_id`, `target_user_id`, `purpose`, `idempotency_key_hash`), KEY `idx_limited_backoffice_login_grants_target` (`target_user_id`, `expires_at`), KEY `idx_limited_backoffice_login_grants_expiry` (`expires_at`), KEY `idx_limited_backoffice_login_grants_state` (`consumed_at`, `revoked_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci SQL); $db->query(<<<'SQL' CREATE TABLE IF NOT EXISTS `limited_backoffice_action_idempotency` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `actor_user_id` INT NOT NULL, `action_type` VARCHAR(64) NOT NULL, `idempotency_key_hash` CHAR(64) NOT NULL, `payload_hash` CHAR(64) NOT NULL, `result_user_id` INT NULL, `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `uniq_limited_backoffice_action_idempotency` (`actor_user_id`, `action_type`, `idempotency_key_hash`), KEY `idx_limited_backoffice_action_result` (`result_user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci SQL); self::$initialized = true; } }