Skip to content

Commit b9e8aca

Browse files
committed
Fix off chain vote data missing
Fixes #1805
1 parent f76c30f commit b9e8aca

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

cardano-db/src/Cardano/Db/Schema.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ share
691691
json Text sqltype=jsonb
692692
bytes ByteString sqltype=bytea
693693
pmrId PoolMetadataRefId noreference
694-
UniqueOffChainPoolData poolId hash
694+
UniqueOffChainPoolData poolId pmrId
695695
deriving Show
696696

697697
-- The pool metadata fetch error. We duplicate the poolId for easy access.

schema/migration-2-0042-20240808.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- Persistent generated migration.
2+
3+
CREATE FUNCTION migrate() RETURNS void AS $$
4+
DECLARE
5+
next_version int ;
6+
BEGIN
7+
SELECT stage_two + 1 INTO next_version FROM schema_version ;
8+
IF next_version = 42 THEN
9+
EXECUTE 'ALTER TABLE "voting_procedure" ADD COLUMN "invalid" INT8 NULL' ;
10+
EXECUTE 'CREATe TABLE "event_info"("id" SERIAL8 PRIMARY KEY UNIQUE,"tx_id" INT8 NULL,"epoch" word31type NOT NULL,"type" VARCHAR NOT NULL,"explanation" VARCHAR NULL)' ;
11+
EXECUTE 'ALTER TABLE "off_chain_pool_data" DROP CONSTRAINT "unique_off_chain_pool_data"' ;
12+
EXECUTE 'ALTER TABLE "off_chain_pool_data" ADD CONSTRAINT "unique_off_chain_pool_data" UNIQUE("pool_id","pmr_id")' ;
13+
-- Hand written SQL statements can be added here.
14+
UPDATE schema_version SET stage_two = next_version ;
15+
RAISE NOTICE 'DB has been migrated to stage_two version %', next_version ;
16+
END IF ;
17+
END ;
18+
$$ LANGUAGE plpgsql ;
19+
20+
SELECT migrate() ;
21+
22+
DROP FUNCTION migrate() ;

0 commit comments

Comments
 (0)