diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php
index 8d329a8cc6defd98a726dfcc9c6971ba42f654e4..3b98fdbeaf40f15a04e9ac93bdc1779e7143645d 100644
--- a/modules/saml/lib/SP/LogoutStore.php
+++ b/modules/saml/lib/SP/LogoutStore.php
@@ -22,7 +22,16 @@ class LogoutStore
             return;
         } elseif ($tableVer === 1) {
             /* TableVersion 2 increased the column size to 255 which is the maximum length of a FQDN. */
-            $query = 'ALTER TABLE ' . $store->prefix . '_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL';
+            switch ($store->driver) {
+                case 'pgsql':
+                    // This does not affect the NOT NULL constraint
+                    $query = 'ALTER TABLE ' . $store->prefix . '_saml_LogoutStore ALTER COLUMN _authSource TYPE VARCHAR(255)';
+                    break;
+                default:
+                    $query = 'ALTER TABLE ' . $store->prefix . '_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL';
+                    break;
+            }
+
             try {
                 $store->pdo->exec($query);
             } catch (\Exception $e) {