mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
abb57e58c8
</details> PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3392 Co-authored-by: Divi <32202683+imperfect-fourth@users.noreply.github.com> GitOrigin-RevId: 9df6b0aa7d91f22571b72d3e467da23b916c9140
33 lines
1.2 KiB
Haskell
33 lines
1.2 KiB
Haskell
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Hasura.Backends.MSSQL.DDL.Source.Version
|
|
( latestSourceCatalogVersion,
|
|
setSourceCatalogVersion,
|
|
getSourceCatalogVersion,
|
|
latestSourceCatalogVersionText,
|
|
)
|
|
where
|
|
|
|
import Database.MSSQL.Transaction
|
|
import Database.ODBC.SQLServer
|
|
import Database.ODBC.TH qualified as ODBC
|
|
import Hasura.Backends.MSSQL.Connection (MonadMSSQLTx (..))
|
|
import Hasura.Backends.MSSQL.SQL.Error qualified as HGE
|
|
import Hasura.Prelude
|
|
|
|
latestSourceCatalogVersion :: Int
|
|
latestSourceCatalogVersion = 1
|
|
|
|
latestSourceCatalogVersionText :: Text
|
|
latestSourceCatalogVersionText = tshow latestSourceCatalogVersion
|
|
|
|
setSourceCatalogVersion :: MonadMSSQLTx m => Int -> m ()
|
|
setSourceCatalogVersion version = liftMSSQLTx $ unitQueryE HGE.defaultMSSQLTxErrorHandler setSourceCatalogVersionQuery
|
|
where
|
|
setSourceCatalogVersionQuery = [ODBC.sql| INSERT INTO hdb_catalog.hdb_source_catalog_version(version, upgraded_on) VALUES ($version, SYSDATETIMEOFFSET()) |]
|
|
|
|
getSourceCatalogVersion :: MonadMSSQLTx m => m Int
|
|
getSourceCatalogVersion =
|
|
liftMSSQLTx $
|
|
singleRowQueryE HGE.defaultMSSQLTxErrorHandler [ODBC.sql| SELECT version FROM hdb_catalog.hdb_source_catalog_version |]
|