Skip to content

Commit 143f370

Browse files
committed
Add missing schema
1 parent 085bedf commit 143f370

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/CommandLineArg/ForceIndex.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ checkForceIndexesArg =
1919
withCustomConfig commandLineForceIndexArgs Nothing babbageConfigDir testLabel $ \_ _ dbSyncEnv -> do
2020
startDBSync dbSyncEnv
2121
threadDelay 3_000_000
22-
assertEqQuery dbSyncEnv DB.queryPgIndexesCount 162 "there wasn't the correct number of indexes"
22+
assertEqQuery dbSyncEnv DB.queryPgIndexesCount 166 "there wasn't the correct number of indexes"
2323
where
2424
testLabel = "CLAcheckForceIndexesArg"
2525
commandLineForceIndexArgs =
@@ -32,7 +32,7 @@ checkNoForceIndexesArg =
3232
withCustomConfigAndDropDB commandLineNoForceIndexArgs Nothing babbageConfigDir testLabel $ \_ _ dbSyncEnv -> do
3333
startDBSync dbSyncEnv
3434
threadDelay 3_000_000
35-
assertEqQuery dbSyncEnv DB.queryPgIndexesCount 97 "there wasn't the correct number of indexes"
35+
assertEqQuery dbSyncEnv DB.queryPgIndexesCount 101 "there wasn't the correct number of indexes"
3636
where
3737
testLabel = "CLAcheckNoForceIndexesArg"
3838
commandLineNoForceIndexArgs =

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/CommandLineArg/ForceIndex.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ checkForceIndexesArg =
1717
startDBSync dbSync
1818

1919
-- Verify number of DB indexes
20-
assertEqQuery dbSync DB.queryPgIndexesCount 162 "unexpected number of indexes"
20+
assertEqQuery dbSync DB.queryPgIndexesCount 166 "unexpected number of indexes"
2121
where
2222
cliArgs = initCommandLineArgs {claForceIndexes = True}
2323
testLabel = "conwayCLACheckForceIndexesArg"
@@ -28,7 +28,7 @@ checkNoForceIndexesArg =
2828
startDBSync dbSync
2929

3030
-- Verify number of DB indexes
31-
assertEqQuery dbSync DB.queryPgIndexesCount 97 "unexpected number of indexes"
31+
assertEqQuery dbSync DB.queryPgIndexesCount 101 "unexpected number of indexes"
3232
where
3333
cliArgs = initCommandLineArgs {claForceIndexes = False}
3434
testLabel = "conwayCLACheckNoForceIndexesArg"

schema/migration-2-0035-20240308.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 = 35 THEN
9+
EXECUTE 'ALTER TABLE "drep_hash" DROP CONSTRAINT "unique_drep_hash"' ;
10+
EXECUTE 'ALTER TABLE "drep_hash" ADD CONSTRAINT "unique_drep_hash" UNIQUE("raw","has_script")' ;
11+
EXECUTE 'CREATe TABLE "committee_hash"("id" SERIAL8 PRIMARY KEY UNIQUE,"raw" hash28type NOT NULL,"has_script" BOOLEAN NOT NULL)' ;
12+
EXECUTE 'ALTER TABLE "committee_hash" ADD CONSTRAINT "unique_committee_hash" UNIQUE("raw","has_script")' ;
13+
EXECUTE 'ALTER TABLE "committee_registration" ADD COLUMN "cold_key_id" INT8 NOT NULL' ;
14+
EXECUTE 'ALTER TABLE "committee_registration" ADD COLUMN "hot_key_id" INT8 NOT NULL' ;
15+
EXECUTE 'ALTER TABLE "committee_registration" DROP COLUMN "cold_key"' ;
16+
EXECUTE 'ALTER TABLE "committee_registration" DROP COLUMN "hot_key"' ;
17+
EXECUTE 'ALTER TABLE "committee_de_registration" ADD COLUMN "cold_key_id" INT8 NOT NULL' ;
18+
EXECUTE 'ALTER TABLE "committee_de_registration" DROP COLUMN "cold_key"' ;
19+
EXECUTE 'CREATe TABLE "new_committee_info"("id" SERIAL8 PRIMARY KEY UNIQUE,"gov_action_proposal_id" INT8 NOT NULL,"quorum_numerator" INT8 NOT NULL,"quorum_denominator" INT8 NOT NULL)' ;
20+
EXECUTE 'CREATe TABLE "new_committee_member"("id" SERIAL8 PRIMARY KEY UNIQUE,"gov_action_proposal_id" INT8 NOT NULL,"committee_hash_id" INT8 NOT NULL,"expiration_epoch" word31type NOT NULL)' ;
21+
EXECUTE 'ALTER TABLE "voting_procedure" DROP COLUMN "committee_voter"';
22+
EXECUTE 'ALTER TABLE "voting_procedure" ADD COLUMN "committee_voter" INT8 NULL' ;
23+
-- Hand written SQL statements can be added here.
24+
UPDATE schema_version SET stage_two = next_version ;
25+
RAISE NOTICE 'DB has been migrated to stage_two version %', next_version ;
26+
END IF ;
27+
END ;
28+
$$ LANGUAGE plpgsql ;
29+
30+
SELECT migrate() ;
31+
32+
DROP FUNCTION migrate() ;

0 commit comments

Comments
 (0)