6. How to migrate ArmoniK.Core dependencies during upgrade ?

6.1. 0.29.x -> 0.30.x

6.1.1. Database

This version changes the structure of a Result in the database. It introduces a new field called OpaqueId which holds the identifier of its associated value in the Object Storage. Previously, the ResultId was used. The following MongoDB request converts the ResultId into the OpaqueId to support the new implementation.

db.Result.updateMany({},
    [{
        $addFields: {
            OpaqueId: {
                $function: {
                    body: function(data) {
                        const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
                        const bytes = [];
                        for (let i = 0; i < data.length; i++) {
                            bytes.push(data.charCodeAt(i));
                        }

                        let base64 = '';
                        let i = 0;
                        while (i < bytes.length) {
                            let byte1 = bytes[i++] || 0;
                            let byte2 = bytes[i++] || 0;
                            let byte3 = bytes[i++] || 0;

                            let enc1 = byte1 >> 2;
                            let enc2 = ((byte1 & 3) << 4) | (byte2 >> 4);
                            let enc3 = ((byte2 & 15) << 2) | (byte3 >> 6);
                            let enc4 = byte3 & 63;

                            if (isNaN(byte2)) {
                                enc3 = enc4 = 64;
                            } else if (isNaN(byte3)) {
                                enc4 = 64;
                            }

                            base64 += base64Chars[enc1] + base64Chars[enc2] + base64Chars[enc3] + base64Chars[enc4];
                        }

                        return BinData(0, base64);
                    },
                    args: ["$_id"],
                    lang: "js"
                }
            }
        }
    }])

6.2. 0.34.x -> 0.35.x

6.2.1. Database

This version changes the structure of the authentication related tables (AuthData, RoleData and UserData). Identifiers are now integers instead of strings. They are also used to build the relations between items in the database. The migration procedure is to delete the three tables, set up initialisation related environment variables for authentication that can be found here and let ArmoniK regenerate the database.