diff --git a/cardano-db/src/Cardano/Db/Schema.hs b/cardano-db/src/Cardano/Db/Schema.hs index 4ea4cede5..df8c47e45 100644 --- a/cardano-db/src/Cardano/Db/Schema.hs +++ b/cardano-db/src/Cardano/Db/Schema.hs @@ -557,13 +557,13 @@ share CommitteeRegistration txId TxId noreference certIndex Word16 - coldKey ByteString sqltype=addr29type - hotKey ByteString sqltype=addr29type + coldKey ByteString sqltype=bytea + hotKey ByteString sqltype=bytea CommitteeDeRegistration txId TxId noreference certIndex Word16 - hotKey ByteString sqltype=addr29type + hotKey ByteString sqltype=bytea DrepRegistration txId TxId noreference diff --git a/schema/migration-2-0029-20231009.sql b/schema/migration-2-0029-20231009.sql new file mode 100644 index 000000000..f4a546ba2 --- /dev/null +++ b/schema/migration-2-0029-20231009.sql @@ -0,0 +1,21 @@ +-- 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 = 29 THEN + ALTER TABLE committee_registration ALTER COLUMN cold_key SET DATA TYPE bytea; + ALTER TABLE committee_registration ALTER COLUMN hot_key SET DATA TYPE bytea; + ALTER TABLE committee_de_registration ALTER COLUMN hot_key SET DATA TYPE bytea; + -- 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() ;