Views:
Disclaimer:
The installation of MySQL databases is not part of DocuWare support.
As MySQL is a third party application, we have no way of troubleshooting any issues, recommending any additional settings or checking if the installation is fully complete.
DocuWare is not responsible for any corrupted systems if the database is damaged during or after the installation.


Question:
How to upgrade an Internal Database V3 (MySQL 8) to an Internal Database V4 (MySQL 8.4)

Answer:
Updating from MySQL 8 to MySQL 8.4 takes two steps.
You can check your current installed MySQL version by executing
SHOW VARIABLES LIKE "%version%";

All needed files can be downloaded here:
Click here

Important notes:
Ensure to shut down all applications accessing the database before any backup/dump attempts.
Make sure to have a valid backup of your database.

Make sure to have a backup of your installation directory.

Do not upgrade DocuWare directly after upgrading MySQL.
Let the system run for some time to check if the complete functionality is still given.


MySQL 8 to MySQL 8.4
Stop MySQL service

If you want to create a new service using the correct names, delete the current existing MySQL service.
By recreating the service with the new name later, you will see the Internal Database as "Internal Database V4" within the ServiceControl.
Else you can use the old Service using the old "Internal Database V3" name.
sc delete DWMySQL3
 
Go into the installation folder of MySQL and remove/relocate all current files.
Extract InternalDatabaseV4.zip into the default location “C:\Program Files\DocuWare\Internal Database V4” or to a location of your choice.
Copy or replace the my.ini file to the top level data directory (default: C:\ProgramData\DocuWare\Internal Database V4\my.ini).
 
If a location other than the default is used, adjust the following paths in the my.ini file in the top level data directory:
basedir
datadir
secure-file-priv

As default, basedir is set to "C:/Program Files/DocuWare/Internal Database V4", datadir to "C:/Program Files/DocuWare/Internal Database V4/Data" and secure-file-priv to "C:/ProgramData/DocuWare/Internal Database V4/Uploads".
Make sure that all paths are valid - in doubt, access all paths in the file explorer.

If you deleted the service at the beginning of this step, recreate the service as shown:
sc create DWMySQL4 binPath= "\"C:\Program Files\DocuWare\Internal Database V4\bin\mysqld.exe\" --defaults-file=\"C:\Program Files\DocuWare\Internal Database V4\my.ini\" DWMySQL4" DisplayName= "DocuWare Internal Database V4" start= "auto"

For altered folder paths, please adjust accordingly, but make sure to include the masked characters correctly.

If everything was done correctly, you can start the MySQL service by either using the Service Control, Windows Services or the command
sc start DWMySQL4

Upon start of MySQL 8.4, the tables will be updated automatically.

Change collations and character set of the databases in MySQL 8.4
Connect to the MySQL server via the MySQL Workbench or a similar tool and log in as a privileged user.
Run the following MySQL script to create the stored procedure that will be used to change the collation and character set of the DocuWare databases.

DELIMITER //
CREATE PROCEDURE `dwsystem`.`UpdateCharsetAndCollation`(IN DATABASE_NAME VARCHAR(255))
BEGIN
    DECLARE done INT DEFAULT FALSE;
    DECLARE column_done INT DEFAULT FALSE;
    DECLARE tableName VARCHAR(255);
    DECLARE columnName VARCHAR(255);
    DECLARE columnType VARCHAR(255);
    DECLARE columnCollation VARCHAR(255);

    DECLARE table_cursor CURSOR FOR
        SELECT table_name
        FROM information_schema.tables
        WHERE table_schema = DATABASE_NAME;

    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

    OPEN table_cursor;
    read_loop: LOOP
        FETCH table_cursor INTO tableName;
        IF done THEN
            LEAVE read_loop;
        END IF;

        SET @table_sql = CONCAT('ALTER TABLE ', DATABASE_NAME, '.', tableName, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;');
        
        PREPARE stmt FROM @table_sql;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
        
    END LOOP read_loop;
    CLOSE table_cursor;
END//
DELIMITER ;

 
Execute the following MySQL script once for each DocuWare database (e.g. dwdata, dwnotification, dwsystem and dwworkflowengine).
SET @@FOREIGN_KEY_CHECKS = 0;
ALTER DATABASE dwsystem CHARACTER SET = utf8mb4 COLLATE = 'utf8mb4_0900_ai_ci';
call UpdateCharsetAndCollation('dwsystem');
SET @@FOREIGN_KEY_CHECKS=1;

If any error occurs during the upgrade, you sadly have to roll back to the last functioning version.