diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,9 @@
 # Changelog for pantry
 
+## v0.5.2.1
+
+* Support persistent 2.13 [#35](https://github.com/commercialhaskell/pantry/issues/35)
+
 ## v0.5.2
 
 * Fall back to BSD tar when type cannot be detected [#33](https://github.com/commercialhaskell/pantry/issues/33)
diff --git a/pantry.cabal b/pantry.cabal
--- a/pantry.cabal
+++ b/pantry.cabal
@@ -1,13 +1,13 @@
 cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.33.0.
+-- This file has been generated from package.yaml by hpack version 0.34.4.
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: fbb4a7b5f91e118dcea35ad7791c78f827ec0a9fb6d2474e391896262d81f826
+-- hash: 339dac5ed1a5c1ff7d64ece01352e881e1006e2a941ed185d3d2aa0aae75816a
 
 name:           pantry
-version:        0.5.2
+version:        0.5.2.1
 synopsis:       Content addressable Haskell package management
 description:    Please see the README on Github at <https://github.com/commercialhaskell/pantry#readme>
 category:       Development
diff --git a/src/Pantry/Storage.hs b/src/Pantry/Storage.hs
--- a/src/Pantry/Storage.hs
+++ b/src/Pantry/Storage.hs
@@ -120,7 +120,7 @@
 import Pantry.HPack (hpackVersion, hpack)
 import Conduit
 import Data.Acquire (with)
-import Pantry.Types (PackageNameP (..), VersionP (..), SHA256, FileSize (..), FileType (..), HasPantryConfig, BlobKey, Repo (..), TreeKey, SafeFilePath, Revision (..), Package (..), SnapshotCacheHash (..))
+import Pantry.Types (PackageNameP (..), VersionP (..), SHA256, FileSize (..), FileType (..), HasPantryConfig, BlobKey, Repo (..), TreeKey, SafeFilePath, Revision (..), Package (..), SnapshotCacheHash (..), connRDBMS)
 import qualified Pantry.SQLite as SQLite
 
 share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
@@ -289,7 +289,7 @@
   :: RdbmsActions env a
   -> ReaderT SqlBackend (RIO env) a
 rdbmsAwareQuery RdbmsActions {raSqlite, raPostgres} = do
-  rdbms <- connRDBMS <$> ask
+  rdbms <- Pantry.Types.connRDBMS <$> ask
   case rdbms of
     "postgresql" -> raPostgres
     "sqlite" -> raSqlite
diff --git a/src/Pantry/Types.hs b/src/Pantry/Types.hs
--- a/src/Pantry/Types.hs
+++ b/src/Pantry/Types.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE DeriveFunctor #-}
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE FlexibleInstances #-}
@@ -111,6 +112,7 @@
   , getGlobalHintsFile
   , bsToBlobKey
   , warnMissingCabalFile
+  , connRDBMS
   ) where
 
 import RIO
@@ -151,6 +153,10 @@
 import Path.IO (resolveFile, resolveDir)
 import qualified Data.List.NonEmpty as NE
 import Casa.Client (CasaRepoPrefix)
+
+#if MIN_VERSION_persistent(2, 13, 0)
+import Database.Persist.SqlBackend.Internal (connRDBMS)
+#endif
 
 -- | Parsed tree with more information on the Haskell package it contains.
 --
