Skip to content

Commit 0ee19b0

Browse files
committed
add Entity instance to handle table ids columns
1 parent da2a502 commit 0ee19b0

18 files changed

+1604
-583
lines changed

cardano-db/src/Cardano/Db/Operations/Insert.hs

+28-28
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,17 @@ insertManyDrepDistr = insertManyCheckUnique "Many DrepDistr"
335335
-- insertReverseIndex :: (MonadBaseControl IO m, MonadIO m) => ReverseIndex -> ReaderT SqlBackend m ReverseIndexId
336336
-- insertReverseIndex = insertUnchecked "ReverseIndex"
337337

338-
insertCheckOffChainPoolData :: (MonadBaseControl IO m, MonadIO m) => OffChainPoolData -> ReaderT SqlBackend m ()
339-
insertCheckOffChainPoolData pod = do
340-
foundPool <- existsPoolHashId (offChainPoolDataPoolId pod)
341-
foundMeta <- existsPoolMetadataRefId (offChainPoolDataPmrId pod)
342-
when (foundPool && foundMeta) . void $ insertCheckUnique "OffChainPoolData" pod
343-
344-
insertCheckOffChainPoolFetchError :: (MonadBaseControl IO m, MonadIO m) => OffChainPoolFetchError -> ReaderT SqlBackend m ()
345-
insertCheckOffChainPoolFetchError pofe = do
346-
foundPool <- existsPoolHashId (offChainPoolFetchErrorPoolId pofe)
347-
foundMeta <- existsPoolMetadataRefId (offChainPoolFetchErrorPmrId pofe)
348-
when (foundPool && foundMeta) . void $ insertCheckUnique "OffChainPoolFetchError" pofe
338+
-- insertCheckOffChainPoolData :: (MonadBaseControl IO m, MonadIO m) => OffChainPoolData -> ReaderT SqlBackend m ()
339+
-- insertCheckOffChainPoolData pod = do
340+
-- foundPool <- existsPoolHashId (offChainPoolDataPoolId pod)
341+
-- foundMeta <- existsPoolMetadataRefId (offChainPoolDataPmrId pod)
342+
-- when (foundPool && foundMeta) . void $ insertCheckUnique "OffChainPoolData" pod
343+
344+
-- insertCheckOffChainPoolFetchError :: (MonadBaseControl IO m, MonadIO m) => OffChainPoolFetchError -> ReaderT SqlBackend m ()
345+
-- insertCheckOffChainPoolFetchError pofe = do
346+
-- foundPool <- existsPoolHashId (offChainPoolFetchErrorPoolId pofe)
347+
-- foundMeta <- existsPoolMetadataRefId (offChainPoolFetchErrorPmrId pofe)
348+
-- when (foundPool && foundMeta) . void $ insertCheckUnique "OffChainPoolFetchError" pofe
349349

350350
-- insertOffChainVoteData :: (MonadBaseControl IO m, MonadIO m) => OffChainVoteData -> ReaderT SqlBackend m (Maybe OffChainVoteDataId)
351351
-- insertOffChainVoteData ocvd = do
@@ -384,12 +384,12 @@ insertCheckOffChainPoolFetchError pofe = do
384384
-- insertDelistedPool :: (MonadBaseControl IO m, MonadIO m) => DelistedPool -> ReaderT SqlBackend m DelistedPoolId
385385
-- insertDelistedPool = insertCheckUnique "DelistedPool"
386386

387-
insertExtraMigration :: (MonadBaseControl IO m, MonadIO m) => ExtraMigration -> ReaderT SqlBackend m ()
388-
insertExtraMigration token = void . insert $ ExtraMigrations (textShow token) (Just $ extraDescription token)
387+
-- insertExtraMigration :: (MonadBaseControl IO m, MonadIO m) => ExtraMigration -> ReaderT SqlBackend m ()
388+
-- insertExtraMigration token = void . insert $ ExtraMigrations (textShow token) (Just $ extraDescription token)
389389

390-
insertEpochStakeProgress :: (MonadBaseControl IO m, MonadIO m) => [EpochStakeProgress] -> ReaderT SqlBackend m ()
391-
insertEpochStakeProgress =
392-
insertManyCheckUnique "Many EpochStakeProgress"
390+
-- insertEpochStakeProgress :: (MonadBaseControl IO m, MonadIO m) => [EpochStakeProgress] -> ReaderT SqlBackend m ()
391+
-- insertEpochStakeProgress =
392+
-- insertManyCheckUnique "Many EpochStakeProgress"
393393

394394
updateSetComplete :: MonadIO m => Word64 -> ReaderT SqlBackend m ()
395395
updateSetComplete epoch = do
@@ -606,18 +606,18 @@ insertManyWithManualUnique str contraintExists constraintName =
606606
where
607607
mConstraintName = if contraintExists then Just constraintName else Nothing
608608

609-
insertManyCheckUnique ::
610-
forall m record.
611-
( MonadBaseControl IO m
612-
, MonadIO m
613-
, OnlyOneUniqueKey record
614-
) =>
615-
String ->
616-
[record] ->
617-
ReaderT SqlBackend m ()
618-
insertManyCheckUnique vtype records = do
619-
let constraintName = uniqueDBName $ onlyOneUniqueDef (Proxy @record)
620-
insertManyUnique vtype (Just constraintName) records
609+
-- insertManyCheckUnique ::
610+
-- forall m record.
611+
-- ( MonadBaseControl IO m
612+
-- , MonadIO m
613+
-- , OnlyOneUniqueKey record
614+
-- ) =>
615+
-- String ->
616+
-- [record] ->
617+
-- ReaderT SqlBackend m ()
618+
-- insertManyCheckUnique vtype records = do
619+
-- let constraintName = uniqueDBName $ onlyOneUniqueDef (Proxy @record)
620+
-- insertManyUnique vtype (Just constraintName) records
621621

622622
-- Insert, getting PostgreSQL to check the uniqueness constaint. If it is violated,
623623
-- simply returns the Key, without changing anything.

0 commit comments

Comments
 (0)