mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-19 21:41:44 +03:00
2152911e24
GitOrigin-RevId: 0dd10f1ccd338b1cf382ebff59b6ee7f209d39a1
44 lines
1.3 KiB
Haskell
44 lines
1.3 KiB
Haskell
module Hasura.Backends.MSSQL.DDL.Source
|
|
( resolveSourceConfig
|
|
, resolveDatabaseMetadata
|
|
, postDropSourceHook
|
|
)
|
|
where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.Backends.MSSQL.Connection
|
|
import Hasura.Backends.MSSQL.Meta
|
|
import Hasura.Base.Error
|
|
import Hasura.RQL.Types.Common
|
|
import Hasura.RQL.Types.Source
|
|
import Hasura.SQL.Backend
|
|
import Hasura.Server.Types (MaintenanceMode)
|
|
|
|
resolveSourceConfig
|
|
:: (MonadIO m)
|
|
=> SourceName
|
|
-> MSSQLConnConfiguration
|
|
-> m (Either QErr MSSQLSourceConfig)
|
|
resolveSourceConfig _name (MSSQLConnConfiguration connInfo) = runExceptT do
|
|
(connString, mssqlPool) <- createMSSQLPool connInfo
|
|
pure $ MSSQLSourceConfig connString mssqlPool
|
|
|
|
resolveDatabaseMetadata
|
|
:: (MonadIO m)
|
|
=> MSSQLSourceConfig
|
|
-> MaintenanceMode
|
|
-> m (Either QErr (ResolvedSource 'MSSQL))
|
|
resolveDatabaseMetadata config _maintenanceMode = runExceptT do
|
|
dbTablesMetadata <- loadDBMetadata pool
|
|
pure $ ResolvedSource config dbTablesMetadata mempty mempty
|
|
where
|
|
MSSQLSourceConfig _connString pool = config
|
|
|
|
postDropSourceHook
|
|
:: (MonadIO m)
|
|
=> MSSQLSourceConfig -> m ()
|
|
postDropSourceHook (MSSQLSourceConfig _ pool) =
|
|
-- Close the connection
|
|
liftIO $ drainMSSQLPool pool
|