From 0f546d185d615f1bb21424b52bef96be285b2a3e Mon Sep 17 00:00:00 2001 From: Cmdv Date: Tue, 22 Oct 2024 10:52:16 +0100 Subject: [PATCH] add cmd line docs and update rollback queries --- .../src/Cardano/Db/Operations/Delete.hs | 74 +++++++++---------- doc/command-line-options | 36 +++++++++ 2 files changed, 73 insertions(+), 37 deletions(-) create mode 100644 doc/command-line-options diff --git a/cardano-db/src/Cardano/Db/Operations/Delete.hs b/cardano-db/src/Cardano/Db/Operations/Delete.hs index 69b27d127..ebcf84966 100644 --- a/cardano-db/src/Cardano/Db/Operations/Delete.hs +++ b/cardano-db/src/Cardano/Db/Operations/Delete.hs @@ -145,43 +145,6 @@ deleteUsingEpochNo epochN = do pure [("GovActionProposal Nulled", a + b + c + e)] pure $ countLogs <> nullLogs -queryDelete :: - forall m record field. - (MonadIO m, PersistEntity record, PersistField field, PersistEntityBackend record ~ SqlBackend) => - EntityField record field -> - field -> - ReaderT SqlBackend m () -queryDelete fieldIdField fieldId = do - mRecordId <- queryMinRefId fieldIdField fieldId - case mRecordId of - Nothing -> pure () - Just recordId -> deleteWhere [persistIdField @record >=. recordId] - -queryDeleteAndLog :: - forall m record field. - (MonadIO m, PersistEntity record, PersistField field, PersistEntityBackend record ~ SqlBackend) => - Text -> - EntityField record field -> - field -> - ReaderT SqlBackend m [(Text, Int64)] -queryDeleteAndLog tableName txIdField fieldId = do - mRecordId <- queryMinRefId txIdField fieldId - case mRecordId of - Nothing -> pure [(tableName, 0)] - Just recordId -> do - count <- deleteWhereCount [persistIdField @record >=. recordId] - pure [(tableName, count)] - -onlyDelete :: - forall m record. - (MonadIO m, PersistEntity record, PersistEntityBackend record ~ SqlBackend) => - Text -> - [Filter record] -> - ReaderT SqlBackend m [(Text, Int64)] -onlyDelete tableName filters = do - count <- deleteWhereCount filters - pure [(tableName, count)] - deleteTablesAfterBlockId :: MonadIO m => TxOutTableType -> @@ -334,6 +297,43 @@ deleteTablesAfterTxId txOutTableType mtxId minIdsW = do -- Return the combined logs of all operations pure $ minIdsLogs <> txIdLogs +queryDelete :: + forall m record field. + (MonadIO m, PersistEntity record, PersistField field, PersistEntityBackend record ~ SqlBackend) => + EntityField record field -> + field -> + ReaderT SqlBackend m () +queryDelete fieldIdField fieldId = do + mRecordId <- queryMinRefId fieldIdField fieldId + case mRecordId of + Nothing -> pure () + Just recordId -> deleteWhere [persistIdField @record >=. recordId] + +queryDeleteAndLog :: + forall m record field. + (MonadIO m, PersistEntity record, PersistField field, PersistEntityBackend record ~ SqlBackend) => + Text -> + EntityField record field -> + field -> + ReaderT SqlBackend m [(Text, Int64)] +queryDeleteAndLog tableName txIdField fieldId = do + mRecordId <- queryMinRefId txIdField fieldId + case mRecordId of + Nothing -> pure [(tableName, 0)] + Just recordId -> do + count <- deleteWhereCount [persistIdField @record >=. recordId] + pure [(tableName, count)] + +onlyDelete :: + forall m record. + (MonadIO m, PersistEntity record, PersistEntityBackend record ~ SqlBackend) => + Text -> + [Filter record] -> + ReaderT SqlBackend m [(Text, Int64)] +onlyDelete tableName filters = do + count <- deleteWhereCount filters + pure [(tableName, count)] + queryThenNull :: forall m record field. (MonadIO m, PersistEntity record, PersistField field, PersistEntityBackend record ~ SqlBackend) => diff --git a/doc/command-line-options b/doc/command-line-options new file mode 100644 index 000000000..7c7bdf299 --- /dev/null +++ b/doc/command-line-options @@ -0,0 +1,36 @@ +### Command Line Options + +- **General Options:** + - `--config FILEPATH`: Path to the db-sync node config file + - `--socket-path FILEPATH`: Path to a cardano-node socket + - `--state-dir FILEPATH`: The directory for persisting ledger state. + - `--schema-dir FILEPATH`: The directory containing the migrations. + - `--pg-pass-env ENV`: Alternative env variable to use, defaults to `PGPASSFILE` env variable. + - `--disable-epoch`: Makes epoch table remain empty. + - `--skip-fix`: Disables the db-sync fix procedure for the wrong datum and redeemer_data bytes. + - `--force-indexes`: Forces the Index creation at the start of db-sync. Normally they're created later. + - `--fix-only`: Runs only the db-sync fix procedure for the wrong datum, redeemer_data, and plutus script bytes and exits. + - `--disable-cache`: Disables the db-sync caches. Reduces memory usage but it takes longer to sync. + - `--rollback-to-slot SLOTNO`: Force a rollback to the specified slot, if the given slot doesn't exist it will use the next greater slot. + - `--disable-in-out`: Disables the `tx_in` and `tx_out` table. + +- **Deprecated Options (for historical reference only):** + - For more details, refer to [Configuration Documentation](https://github.com/IntersectMBO/cardano-db-sync/blob/master/doc/configuration.md) + - `--disable-offline-data` + - `--disable-ledger` + - `--dont-use-ledger` + - `--keep-tx-metadata` + - `--disable-shelley` + - `--disable-multiassets` + - `--disable-metadata` + - `--disable-plutus-extra` + - `--disable-gov` + - `--disable-offchain-pool-data` + - `--force-tx-in` + - `--disable-all` + - `--full` + - `--only-utxo` + - `--only-gov` + - `--consumed-tx-out` + - `--prune-tx-out` + - `--bootstrap-tx-out`