Skip to content

Commit

Permalink
add cmd line docs and update rollback queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Cmdv committed Oct 22, 2024
1 parent 4e51ef9 commit 0f546d1
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 37 deletions.
74 changes: 37 additions & 37 deletions cardano-db/src/Cardano/Db/Operations/Delete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down Expand Up @@ -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) =>
Expand Down
36 changes: 36 additions & 0 deletions doc/command-line-options
Original file line number Diff line number Diff line change
@@ -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`

0 comments on commit 0f546d1

Please sign in to comment.