diff --git a/composer.json b/composer.json
index 2dc16113f6..a600aae077 100644
--- a/composer.json
+++ b/composer.json
@@ -92,6 +92,7 @@
         "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
         "drupal-phpunit-upgrade-check": "Drupal\\Core\\Composer\\Composer::upgradePHPUnit",
         "drupal-phpunit-upgrade": "@composer update phpunit/phpunit symfony/phpunit-bridge phpspec/prophecy symfony/yaml --with-dependencies --no-progress",
+        "drupal-pgsql-fallback": "@composer require drupal/pgsql_fallback:^2",
         "post-update-cmd": [
             "Drupal\\Composer\\Composer::generateMetapackages"
         ],
diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php
index bd87d53922..12bb65e1fe 100644
--- a/core/lib/Drupal/Core/Composer/Composer.php
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -323,6 +323,11 @@ public static function upgradePHPUnit(Event $event) {
         ->getEventDispatcher()
         ->dispatchScript('drupal-phpunit-upgrade');
     }
+
+    // Hack to get DrupalCI to install the pgsql_fallback contrib project.
+    $event->getComposer()
+      ->getEventDispatcher()
+      ->dispatchScript('drupal-pgsql-fallback');
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 719dd29c4d..8a822b751c 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -468,6 +468,12 @@ public static function convertDbUrlToConnectionInfo($url, $root) {
     }
     $driver = $matches[1];
 
+    // Make DrupalCI test the fallback pgsql driver instead of the core one.
+    if ($driver === 'pgsql') {
+      $driver = 'PgsqlFallback';
+      $url .= '?module=pgsql_fallback';
+    }
+
     // Determine if the database driver is provided by a module.
     $module = NULL;
     $connection_class = NULL;
