public static function db_init($dir)
    {
        $db = self::db();

        $file = $dir . '/' . $db->db_provider . '.initial.sql';
        if (!file_exists($file)) {
            rcube::raise_error("DDL file $file not found", false, true);
        }

        echo "Creating database schema... ";

        if ($sql = file_get_contents($file)) {
            if (!$db->exec_script($sql)) {
                $error = $db->is_error();
            }
        }
        else {
            $error = "Unable to read file $file or it is empty";
        }

        if ($error) {
            echo "[FAILED]\n";
            rcube::raise_error($error, false, true);
        }
        else {
            echo "[OK]\n";
        }
    }