Skip to content

Commit

Permalink
Update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
kderme committed Nov 2, 2023
1 parent dc3336b commit 20f97a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion schema/migration-2-0027-20230815.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BEGIN
EXECUTE 'CREATe TABLE "governance_action"("id" SERIAL8 PRIMARY KEY UNIQUE,"tx_id" INT8 NOT NULL,"index" INT8 NOT NULL,"deposit" lovelace NOT NULL,"return_address" INT8 NOT NULL,"voting_anchor_id" INT8 NULL,"type" govactiontype NOT NULL,"description" VARCHAR NOT NULL,"param_proposal" INT8 NULL,"ratified_epoch" word31type NULL,"enacted_epoch" word31type NULL,"dropped_epoch" word31type NULL,"expired_epoch" word31type NULL)' ;
EXECUTE 'CREATe TABLE "treasury_withdrawal"("id" SERIAL8 PRIMARY KEY UNIQUE,"governance_action_id" INT8 NOT NULL,"stake_address_id" INT8 NOT NULL,"amount" lovelace NOT NULL)' ;
EXECUTE 'CREATe TABLE "new_committee"("id" SERIAL8 PRIMARY KEY UNIQUE,"governance_action_id" INT8 NOT NULL,"quorum" DOUBLE PRECISION NOT NULL,"members" VARCHAR NOT NULL)' ;
EXECUTE 'CREATe TABLE "voting_procedure"("id" SERIAL8 PRIMARY KEY UNIQUE,"tx_id" INT8 NOT NULL,"index" INT4 NOT NULL,"governance_action_id" INT8 NOT NULL,"voter_role" voterrole NOT NULL,"comittee_voter" BYTEA NULL,"drep_voter" INT8 NULL,"pool_voter" INT8 NULL,"vote" vote NOT NULL,"voting_anchor_id" INT8 NULL)' ;
EXECUTE 'CREATe TABLE "voting_procedure"("id" SERIAL8 PRIMARY KEY UNIQUE,"tx_id" INT8 NOT NULL,"index" INT4 NOT NULL,"governance_action_id" INT8 NOT NULL,"voter_role" voterrole NOT NULL,"committee_voter" BYTEA NULL,"drep_voter" INT8 NULL,"pool_voter" INT8 NULL,"vote" vote NOT NULL,"voting_anchor_id" INT8 NULL)' ;
EXECUTE 'CREATe TABLE "anchor_offline_data"("id" SERIAL8 PRIMARY KEY UNIQUE,"voting_anchor_id" INT8 NOT NULL,"hash" BYTEA NOT NULL,"json" jsonb NOT NULL,"bytes" bytea NOT NULL)' ;
EXECUTE 'CREATe TABLE "anchor_offline_fetch_error"("id" SERIAL8 PRIMARY KEY UNIQUE,"voting_anchor_id" INT8 NOT NULL,"fetch_error" VARCHAR NOT NULL,"retry_count" word31type NOT NULL)' ;
EXECUTE 'CREATe TABLE "drep_distr"("id" SERIAL8 PRIMARY KEY UNIQUE,"hash_id" INT8 NOT NULL,"amount" INT8 NOT NULL,"epoch_no" word31type NOT NULL)' ;
Expand Down
19 changes: 19 additions & 0 deletions schema/migration-2-0030-20231102.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- 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 = 30 THEN
EXECUTE 'ALTER TABLE "committee_de_registration" ADD COLUMN "voting_anchor_id" INT8 NULL' ;
-- 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 20f97a8

Please sign in to comment.