Skip to content

Commit

Permalink
mod - tx_body migration file from cabal, rather than handwritten.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Eric Bassett committed Jul 8, 2020
1 parent c3e0f3f commit eeb95bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
20 changes: 20 additions & 0 deletions schema/migration-2-0002-20200625.sql
@@ -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() ;
30 changes: 0 additions & 30 deletions schema/migration-4-0001-20200605.sql

This file was deleted.

0 comments on commit eeb95bd

Please sign in to comment.