Skip to content

Commit

Permalink
feat: Formatted database file (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicalBridge authored Nov 21, 2024
1 parent ea66925 commit f8d846c
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions migrations/00001_create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS tokens (
token_name VARCHAR NOT NULL,
collect_amount UINT256 NOT NULL CHECK(collect_amount>0),
timestamp INTEGER NOT NULL CHECK(timestamp>0)
);
);
CREATE INDEX IF NOT EXISTS tokens_timestamp ON tokens(timestamp);
CREATE INDEX IF NOT EXISTS tokens_token_address ON tokens(token_address);

Expand All @@ -49,33 +49,33 @@ CREATE INDEX IF NOT EXISTS addresses_timestamp ON addresses(timestamp);


CREATE TABLE IF NOT EXISTS balances (
guid VARCHAR PRIMARY KEY,
address VARCHAR NOT NULL,
address_type SMALLINT NOT NULL DEFAULT 0,
token_address VARCHAR NOT NULL,
balance UINT256 NOT NULL CHECK(balance>=0),
lock_balance UINT256 NOT NULL,
timestamp INTEGER NOT NULL CHECK(timestamp>0)
guid VARCHAR PRIMARY KEY,
address VARCHAR NOT NULL,
address_type SMALLINT NOT NULL DEFAULT 0,
token_address VARCHAR NOT NULL,
balance UINT256 NOT NULL CHECK(balance>=0),
lock_balance UINT256 NOT NULL,
timestamp INTEGER NOT NULL CHECK(timestamp>0)
);
CREATE INDEX IF NOT EXISTS balances_address ON balances(address);
CREATE INDEX IF NOT EXISTS balances_timestamp ON balances(timestamp);



CREATE TABLE IF NOT EXISTS transactions (
guid VARCHAR PRIMARY KEY,
block_hash VARCHAR NOT NULL,
block_number UINT256 NOT NULL CHECK(block_number>0),
hash VARCHAR NOT NULL,
from_address VARCHAR NOT NULL,
to_address VARCHAR NOT NULL,
token_address VARCHAR NOT NULL,
fee UINT256 NOT NULL,
amount UINT256 NOT NULL,
status SMALLINT NOT NULL DEFAULT 0,
transaction_index UINT256 NOT NULL,
tx_type SMALLINT NOT NULL DEFAULT 0,
timestamp INTEGER NOT NULL CHECK(timestamp>0)
guid VARCHAR PRIMARY KEY,
block_hash VARCHAR NOT NULL,
block_number UINT256 NOT NULL CHECK(block_number>0),
hash VARCHAR NOT NULL,
from_address VARCHAR NOT NULL,
to_address VARCHAR NOT NULL,
token_address VARCHAR NOT NULL,
fee UINT256 NOT NULL,
amount UINT256 NOT NULL,
status SMALLINT NOT NULL DEFAULT 0,
transaction_index UINT256 NOT NULL,
tx_type SMALLINT NOT NULL DEFAULT 0,
timestamp INTEGER NOT NULL CHECK(timestamp>0)
);
CREATE INDEX IF NOT EXISTS transactions_hash ON transactions(hash);
CREATE INDEX IF NOT EXISTS transactions_timestamp ON transactions(timestamp);
Expand Down

0 comments on commit f8d846c

Please sign in to comment.