Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mod - tx_body migration file from cabal, rather than handwritten.
- Loading branch information
Matthew Eric Bassett
committed
Jul 8, 2020
1 parent
c3e0f3f
commit eeb95bd
Showing
2 changed files
with
20 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 2 THEN | ||
EXECUTE 'CREATe TABLE "tx_body"("id" SERIAL8 PRIMARY KEY UNIQUE,"hash" hash32type NOT NULL,"body" bytea NOT NULL)' ; | ||
EXECUTE 'ALTER TABLE "tx_body" ADD CONSTRAINT "unique_tx_body" UNIQUE("hash")' ; | ||
-- Hand written SQL statements can be added here. | ||
UPDATE schema_version SET stage_two = 2 ; | ||
RAISE NOTICE 'DB has been migrated to stage_two version %', next_version ; | ||
END IF ; | ||
END ; | ||
$$ LANGUAGE plpgsql ; | ||
|
||
SELECT migrate() ; | ||
|
||
DROP FUNCTION migrate() ; |
This file was deleted.
Oops, something went wrong.