Skip to content

Commit

Permalink
Cleanup in the DB schema. (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolikzinovyev authored Oct 8, 2021
1 parent 18004b0 commit 25058e5
Show file tree
Hide file tree
Showing 7 changed files with 295 additions and 293 deletions.
292 changes: 146 additions & 146 deletions api/generated/common/routes.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/generated/common/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

264 changes: 132 additions & 132 deletions api/generated/v2/routes.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/generated/v2/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/indexer.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@
"type": "string"
},
"sig-type": {
"description": "Indicates what type of signature is used by this account, must be one of:\n* sig\n* msig\n* lsig",
"description": "Indicates what type of signature is used by this account, must be one of:\n* sig\n* msig\n* lsig\n* or null if unknown",
"type": "string",
"enum": [
"sig",
Expand Down
2 changes: 1 addition & 1 deletion api/indexer.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@
"type": "integer"
},
"sig-type": {
"description": "Indicates what type of signature is used by this account, must be one of:\n* sig\n* msig\n* lsig",
"description": "Indicates what type of signature is used by this account, must be one of:\n* sig\n* msig\n* lsig\n* or null if unknown",
"enum": [
"sig",
"msig",
Expand Down
26 changes: 13 additions & 13 deletions idb/postgres/internal/schema/setup_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ CREATE INDEX IF NOT EXISTS block_header_time ON block_header (realtime);

CREATE TABLE IF NOT EXISTS txn (
round bigint NOT NULL,
intra smallint NOT NULL,
intra integer NOT NULL,
typeenum smallint NOT NULL,
asset bigint NOT NULL, -- 0=Algos, otherwise AssetIndex
txid bytea, -- base32 of [32]byte hash, or NULL for inner transactions.
txnbytes bytea, -- msgpack encoding of signed txn with apply data, or NULL for inner transactions.
txn jsonb NOT NULL, -- json encoding of signed txn with apply data
extra jsonb,
extra jsonb NOT NULL,
PRIMARY KEY ( round, intra )
);

Expand All @@ -34,7 +34,7 @@ CREATE INDEX IF NOT EXISTS txn_by_tixid ON txn ( txid );
CREATE TABLE IF NOT EXISTS txn_participation (
addr bytea NOT NULL,
round bigint NOT NULL,
intra smallint NOT NULL
intra integer NOT NULL
);

-- For query account transactions
Expand All @@ -47,10 +47,10 @@ CREATE TABLE IF NOT EXISTS account (
rewardsbase bigint NOT NULL,
rewards_total bigint NOT NULL,
deleted bool NOT NULL, -- whether or not it is currently deleted
created_at bigint NOT NULL DEFAULT 0, -- round that the account is first used
created_at bigint NOT NULL, -- round that the account is first used
closed_at bigint, -- round that the account was last closed
keytype varchar(8), -- sig,msig,lsig
account_data jsonb -- trimmed AccountData that excludes the fields above and the four creatable maps
keytype varchar(8), -- sig, msig, lsig, or null if unknown
account_data jsonb NOT NULL -- trimmed AccountData that excludes the fields above and the four creatable maps
);

-- data.basics.AccountData Assets[asset id] AssetHolding{}
Expand All @@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS account_asset (
amount numeric(20) NOT NULL, -- need the full 18446744073709551615
frozen boolean NOT NULL,
deleted bool NOT NULL, -- whether or not it is currently deleted
created_at bigint NOT NULL DEFAULT 0, -- round that the asset was added to an account
created_at bigint NOT NULL, -- round that the asset was added to an account
closed_at bigint, -- round that the asset was last removed from the account
PRIMARY KEY (addr, assetid)
);
Expand All @@ -77,7 +77,7 @@ CREATE TABLE IF NOT EXISTS asset (
creator_addr bytea NOT NULL,
params jsonb NOT NULL, -- data.basics.AssetParams -- TODO index some fields?
deleted bool NOT NULL, -- whether or not it is currently deleted
created_at bigint NOT NULL DEFAULT 0, -- round that the asset was created
created_at bigint NOT NULL, -- round that the asset was created
closed_at bigint -- round that the asset was closed; cannot be recreated because the index is unique
);

Expand All @@ -95,10 +95,10 @@ CREATE TABLE IF NOT EXISTS metastate (
-- roughly go-algorand/data/basics/userBalance.go AppParams
CREATE TABLE IF NOT EXISTS app (
index bigint PRIMARY KEY,
creator bytea, -- account address
params jsonb,
creator bytea NOT NULL, -- account address
params jsonb NOT NULL,
deleted bool NOT NULL, -- whether or not it is currently deleted
created_at bigint NOT NULL DEFAULT 0, -- round that the asset was created
created_at bigint NOT NULL, -- round that the asset was created
closed_at bigint -- round that the app was deleted; cannot be recreated because the index is unique
);

Expand All @@ -109,9 +109,9 @@ CREATE INDEX IF NOT EXISTS app_by_creator ON app ( creator );
CREATE TABLE IF NOT EXISTS account_app (
addr bytea,
app bigint,
localstate jsonb,
localstate jsonb NOT NULL,
deleted bool NOT NULL, -- whether or not it is currently deleted
created_at bigint NOT NULL DEFAULT 0, -- round that the app was added to an account
created_at bigint NOT NULL, -- round that the app was added to an account
closed_at bigint, -- round that the account_app was last removed from the account
PRIMARY KEY (addr, app)
);
Expand Down

0 comments on commit 25058e5

Please sign in to comment.