private function ab_fix_Sessions()
    {
        $ouputTable = new Table($this->output);

        $title = sprintf("fixing table \"%s.%s\"", $this->appBox->get_dbname(), "Sessions");
        $ouputTable->setHeaders([new TableCell($title, ['colspan'=>2])]);

        $site = $this->getContainer()['conf']->get(['main', 'key']);

        // if autoincrement, get the current value as a minimum
        $max_SessionId = $this->box_getMax(
            $this->appBox,
            'Sessions',
            [],          // no sub-tables
            $ouputTable
        );

        // get max session from databoxes, using the "log" table which refers to ab.Sessions ids
        foreach ($this->databoxes as $databox) {
            $db = $databox->get_connection();

            $sql = "SELECT MAX(`sit_session`) FROM `log` WHERE `site` = :site";
            $stmt = $db->executeQuery($sql, [':site' => $site]);
            $id = $stmt->fetchColumn(0);

            $ouputTable->addRow([sprintf("%s.log.sit_session", $databox->get_dbname()), sprintf("%s", is_null($id) ? 'null' : $id)]);

            if(!is_null($id)) {
                $id = (int)$id + 1;
                if ($id > $max_SessionId) {
                    $max_SessionId = $id;
                }
            }
            $stmt->closeCursor();
        }

        // fix using different methods
        foreach ([
                    // 4.0 with autoincrement
                    [
                        'sql'   => "ALTER TABLE `Sessions` AUTO_INCREMENT = " . $max_SessionId,   // can't use parameter here
                        'parms' => [],
                        'msg'   => ["ab.Sessions.AUTO_INCREMENT set to", $max_SessionId],
                    ],
                    /* --- custon generators not yet implemented in phraseanet
                    // 4.0 with custom generator already set
                    [
                        'sql'   => "UPDATE `Id` SET value = :v WHERE `id` = :k",
                        'parms' => [':v' => $max_SessionId, ':k' => 'Alchemy\\Phrasea\\Model\\Entities\\Session'],
                        'msg'   => ["ab.Id['Sessions']' set to", $max_SessionId],
                    ],
                    // 4.0 with custom generator not yet set
                    [
                        'sql'   => "INSERT INTO `Id` (`id`, `value`) VALUES (:k, :v)",
                        'parms' => [':v' => $max_SessionId, ':k' => 'Alchemy\\Phrasea\\Model\\Entities\\Session'],
                        'msg'   => ["ab.Id['Sessions']' set to", $max_SessionId],
                    ]
                    --- */
                ] as $sql) {

            // one or more sql will fail, no pb
            $this->box_setSQL($this->appBox, $sql['sql'], $sql['parms'], $sql['msg'], $ouputTable);
        }

        $ouputTable->render();

        $this->output->writeln("");

        return $this;
    }