mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-24 07:52:14 +03:00
01d8a37706
Co-authored-by: Rakesh Emmadi <12475069+rakeshkky@users.noreply.github.com> GitOrigin-RevId: 9b8afb502e94dd371a8596ccde97d023bd2344a9
27 lines
963 B
Haskell
27 lines
963 B
Haskell
module Hasura.Backends.Postgres.DDL.Source.Version where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import qualified Database.PG.Query as Q
|
|
|
|
import Hasura.Backends.Postgres.Connection
|
|
|
|
|
|
latestSourceCatalogVersion :: Integer
|
|
latestSourceCatalogVersion = 2
|
|
|
|
latestSourceCatalogVersionText :: Text
|
|
latestSourceCatalogVersionText = tshow latestSourceCatalogVersion
|
|
|
|
setSourceCatalogVersion :: MonadTx m => m ()
|
|
setSourceCatalogVersion = liftTx $ Q.unitQE defaultTxErrorHandler [Q.sql|
|
|
INSERT INTO hdb_catalog.hdb_source_catalog_version(version, upgraded_on)
|
|
VALUES ($1, NOW())
|
|
ON CONFLICT ((version IS NOT NULL))
|
|
DO UPDATE SET version = $1, upgraded_on = NOW()
|
|
|] (Identity latestSourceCatalogVersionText) False
|
|
|
|
getSourceCatalogVersion :: MonadTx m => m Text
|
|
getSourceCatalogVersion = liftTx $ runIdentity . Q.getRow <$> Q.withQE defaultTxErrorHandler
|
|
[Q.sql| SELECT version FROM hdb_catalog.hdb_source_catalog_version |] () False
|