Skip to content

Commit

Permalink
db: Minor improvements to database domain types
Browse files Browse the repository at this point in the history
Closes: #365
  • Loading branch information
erikd committed Oct 20, 2020
1 parent 2be3add commit b93bf7b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions schema/migration-1-0001-20190730.sql
Expand Up @@ -12,7 +12,7 @@ BEGIN
-- can be any Word64 value so we need this :cry:.
EXECUTE 'CREATE DOMAIN lovelace AS numeric (20, 0) CHECK (VALUE >= 0 AND VALUE <= 18446744073709551615);';

EXECUTE 'CREATE DOMAIN txindex AS smallint CHECK (VALUE >= 0 AND VALUE < 1024);';
EXECUTE 'CREATE DOMAIN txindex AS smallint CHECK (VALUE >= 0);';
EXECUTE 'CREATE DOMAIN uinteger AS integer CHECK (VALUE >= 0);';

-- Blocks, transactions and merkel roots use a 32 byte hash.
Expand All @@ -26,7 +26,7 @@ BEGIN

-- 'maxBound :: Word128' as a decimal has 39 digits, so we only need to check that it
-- is positive.
EXECUTE 'CREATE DOMAIN word128type AS numeric (38, 0) CHECK (VALUE >= 0);';
EXECUTE 'CREATE DOMAIN word128type AS numeric (38, 0) CHECK (VALUE >= (0)::numeric AND VALUE <= (340282366920938463463374607431768211455)::numeric);';

This comment has been minimized.

Copy link
@dcoutts

dcoutts Oct 20, 2020

Contributor

Needs to be 39 digits right?


-- 'maxBound :: Word64' as a decimal has 20 digits but not all 20 digit values are less than
-- 'maxBound :: Word64'.
Expand Down

0 comments on commit b93bf7b

Please sign in to comment.