diff --git a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
index c0da0aaff8..8dc1a65e3d 100644
--- a/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
+++ b/src/test/perl/PostgreSQL/Test/AdjustUpgrade.pm
@@ -106,6 +106,16 @@ sub adjust_database_contents
 			'drop extension if exists test_ext7');
 	}
 
+	# we removed the adminpack extension in v17
+	if ($old_version >= 12 && $old_version < 17)
+	{
+		_add_st($result, 'regression',
+			'drop extension if exists adminpack');
+		_add_st($result, 'postgres',
+			'drop database contrib_regression_adminpack');
+		delete($dbnames{'contrib_regression_adminpack'});
+	}
+
 	# we removed this test-support function in v17
 	if ($old_version >= 15 && $old_version < 17)
 	{
