Skip to content

Commit

Permalink
Fix committee fkey cascade behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
kderme committed Aug 28, 2024
1 parent 61d22d3 commit c1443b8
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Revision history for cardano-db-sync

## 13.5.0.0
- Fix a crtitical bug with committee foreign key, that could cause crashes

## 13.4.1.0
- Fix consumed_by option for Byron inputs. A migration fixes old wrong values in place. [#1821]
- Fix only-utxo preset populating the metadata instead of the multiassets
Expand Down
2 changes: 1 addition & 1 deletion cardano-chain-gen/cardano-chain-gen.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.6

name: cardano-chain-gen
version: 13.4.1.0
version: 13.5.0.0
synopsis: A fake chain generator for testing cardano DB sync.
description: A fake chain generator for testing cardano DB sync.
homepage: https://github.com/IntersectMBO/cardano-db-sync
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-sync/cardano-db-sync.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.6

name: cardano-db-sync
version: 13.4.1.0
version: 13.5.0.0
synopsis: The Cardano DB Sync node
description: A Cardano node that follows the Cardano chain and inserts data from the
chain into a PostgresQL database.
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Sync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ dbSyncProtocols syncEnv metricsSetters tc codecConfig version bversion =
case consumedFixed of
Nothing -> oldActionFixes channel
Just wrongEntriesSize | wrongEntriesSize == 0 -> do
logInfo tracer "Found no wrong entries"
logInfo tracer "Found no wrong consumed_by_tx_id entries"
oldActionFixes channel
Just wrongEntriesSize -> do
logInfo tracer $
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-tool/cardano-db-tool.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.6

name: cardano-db-tool
version: 13.4.1.0
version: 13.5.0.0
synopsis: Utilities to manage the cardano-db-sync databases.
description: Utilities and executable, used to manage and validate the
PostgreSQL db and the ledger database of the cardano-db-sync node
Expand Down
2 changes: 1 addition & 1 deletion cardano-db/cardano-db.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.6

name: cardano-db
version: 13.4.1.0
version: 13.5.0.0
synopsis: A base PostgreSQL component for the cardano-db-sync node.
description: Code for the Cardano DB Sync node that is shared between the
cardano-db-node and other components.
Expand Down
2 changes: 1 addition & 1 deletion cardano-db/src/Cardano/Db/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ share
quorumDenominator Word64

CommitteeMember
committeeId CommitteeId -- here intentionally we use foreign keys
committeeId CommitteeId OnDeleteCascade -- here intentionally we use foreign keys
committeeHashId CommitteeHashId noreference
expirationEpoch Word64 sqltype=word31type

Expand Down
2 changes: 1 addition & 1 deletion cardano-db/test/cardano-db-test.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.6

name: cardano-db-test
version: 13.4.1.0
version: 13.5.0.0
synopsis: Tests for the base functionality of the cardano-db library
description: Code for the Cardano DB Sync node that is shared between the
cardano-db-node and other components.
Expand Down
2 changes: 1 addition & 1 deletion cardano-smash-server/cardano-smash-server.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.6

name: cardano-smash-server
version: 13.4.1.0
version: 13.5.0.0
synopsis: The Cardano smash server
description: Please see the README on GitHub at
<https://github.com/IntersectMBO/cardano-db-sync/cardano-smash-server/#readme>
Expand Down
2 changes: 0 additions & 2 deletions doc/schema.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Schema Documentation for cardano-db-sync

**Note:** This file is auto-generated from the documentation in cardano-db/src/Cardano/Db/Schema.hs by the command `cabal run -- gen-schema-docs doc/schema.md`. This document should only be updated during the release process and updated on the release branch.

### `schema_version`

The version of the database schema. Schema versioning is split into three stages as detailed below. This table should only ever have a single row.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ services:
max-file: "10"

cardano-db-sync:
image: ghcr.io/intersectmbo/cardano-db-sync:13.4.0.0
image: ghcr.io/intersectmbo/cardano-db-sync:13.5.0.0
environment:
- DB_SYNC_CONFIG=${DB_SYNC_CONFIG:-}
- DISABLE_LEDGER=${DISABLE_LEDGER}
Expand Down
20 changes: 20 additions & 0 deletions schema/migration-2-0043-20240828.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Persistent generated migration.

CREATE FUNCTION migrate() RETURNS void AS $$
DECLARE
next_version int ;
BEGIN
SELECT stage_two + 1 INTO next_version FROM schema_version ;
IF next_version = 43 THEN
EXECUTE 'ALTER TABLE "committee_member" DROP CONSTRAINT "committee_member_committee_id_fkey"' ;
EXECUTE 'ALTER TABLE "committee_member" ADD CONSTRAINT "committee_member_committee_id_fkey" FOREIGN KEY("committee_id") REFERENCES "committee"("id") ON DELETE CASCADE ON UPDATE RESTRICT' ;
-- Hand written SQL statements can be added here.
UPDATE schema_version SET stage_two = next_version ;
RAISE NOTICE 'DB has been migrated to stage_two version %', next_version ;
END IF ;
END ;
$$ LANGUAGE plpgsql ;

SELECT migrate() ;

DROP FUNCTION migrate() ;

0 comments on commit c1443b8

Please sign in to comment.