-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: another attempt to create ft/nft interface
- Loading branch information
1 parent
df479db
commit bcfbcf3
Showing
1 changed file
with
55 additions
and
53 deletions.
There are no files selected for viewing
108 changes: 55 additions & 53 deletions
108
migrations/2021-08-23-161500_aggregated_ft_nft_tables/up.sql
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 |
---|---|---|
@@ -1,62 +1,64 @@ | ||
CREATE TABLE aggregated__fungible_tokens | ||
CREATE TABLE aggregated__fungible_token_operations | ||
( | ||
id bigserial NOT NULL, | ||
included_in_transaction_hash text NOT NULL, | ||
included_in_transaction_timestamp numeric(20, 0) NOT NULL, | ||
transaction_status execution_outcome_status NOT NULL, | ||
issued_contract_id text NOT NULL, | ||
called_method text NOT NULL, | ||
predecessor_account_id text NOT NULL, | ||
receiver_account_id text NOT NULL, | ||
amount numeric(45, 0) NOT NULL, | ||
args jsonb NOT NULL | ||
processed_in_block_timestamp numeric(20, 0) NOT NULL, | ||
processed_in_transaction_hash text NOT NULL, | ||
processing_index_in_chunk integer NOT NULL, | ||
ft_contract_account_id text NOT NULL, | ||
ft_affected_account_id text NOT NULL, | ||
called_method text NOT NULL, | ||
ft_affected_account_balance numeric(45, 0) NOT NULL, | ||
args jsonb NOT NULL | ||
); | ||
|
||
ALTER TABLE ONLY aggregated__fungible_tokens | ||
ADD CONSTRAINT aggregated__fungible_tokens_pkey PRIMARY KEY (id); | ||
ALTER TABLE ONLY aggregated__fungible_token_operations | ||
ADD CONSTRAINT aggregated__fungible_token_operations_pkey PRIMARY KEY (processed_in_transaction_hash, | ||
ft_contract_account_id, | ||
ft_affected_account_id); | ||
|
||
CREATE INDEX aggregated__fungible_tokens_timestamp_idx ON aggregated__fungible_tokens USING btree (included_in_transaction_timestamp); | ||
-- I will edit it after we finalise the naming | ||
-- CREATE INDEX aggregated__fungible_tokens_timestamp_idx ON aggregated__fungible_tokens USING btree (included_in_transaction_timestamp); | ||
-- | ||
-- ALTER TABLE ONLY aggregated__fungible_tokens | ||
-- ADD CONSTRAINT aggregated__fungible_tokens_fk FOREIGN KEY (included_in_transaction_hash) REFERENCES transactions (transaction_hash) ON DELETE CASCADE; | ||
-- | ||
-- ALTER TABLE ONLY aggregated__fungible_tokens | ||
-- ADD CONSTRAINT aggregated__ft_issued_contract_id_fk FOREIGN KEY (issued_contract_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
-- | ||
-- ALTER TABLE ONLY aggregated__fungible_tokens | ||
-- ADD CONSTRAINT aggregated__ft_predecessor_account_id_fk FOREIGN KEY (predecessor_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
-- | ||
-- ALTER TABLE ONLY aggregated__fungible_tokens | ||
-- ADD CONSTRAINT aggregated__ft_receiver_account_id_fk FOREIGN KEY (receiver_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE ONLY aggregated__fungible_tokens | ||
ADD CONSTRAINT aggregated__fungible_tokens_fk FOREIGN KEY (included_in_transaction_hash) REFERENCES transactions (transaction_hash) ON DELETE CASCADE; | ||
|
||
ALTER TABLE ONLY aggregated__fungible_tokens | ||
ADD CONSTRAINT aggregated__ft_issued_contract_id_fk FOREIGN KEY (issued_contract_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE ONLY aggregated__fungible_tokens | ||
ADD CONSTRAINT aggregated__ft_predecessor_account_id_fk FOREIGN KEY (predecessor_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE ONLY aggregated__fungible_tokens | ||
ADD CONSTRAINT aggregated__ft_receiver_account_id_fk FOREIGN KEY (receiver_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
|
||
CREATE TABLE aggregated__non_fungible_tokens | ||
CREATE TABLE aggregated__non_fungible_token_operations | ||
( | ||
id bigserial NOT NULL, | ||
included_in_transaction_hash text NOT NULL, | ||
included_in_transaction_timestamp numeric(20, 0) NOT NULL, | ||
transaction_status execution_outcome_status NOT NULL, | ||
issued_contract_id text NOT NULL, | ||
called_method text NOT NULL, | ||
non_fungible_token_id text NOT NULL, | ||
predecessor_account_id text NOT NULL, | ||
receiver_account_id text NOT NULL, | ||
amount numeric(45, 0) NOT NULL, | ||
args jsonb NOT NULL | ||
processed_in_block_timestamp numeric(20, 0) NOT NULL, | ||
processed_in_transaction_hash text NOT NULL, | ||
processing_index_in_chunk integer NOT NULL, | ||
nft_contract_account_id text NOT NULL, | ||
nft_affected_account_id text NOT NULL, | ||
called_method text NOT NULL, | ||
nft_id text NOT NULL, | ||
args jsonb NOT NULL | ||
); | ||
|
||
ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
ADD CONSTRAINT aggregated__non_fungible_tokens_pkey PRIMARY KEY (id); | ||
|
||
CREATE INDEX aggregated__non_fungible_tokens_timestamp_idx ON aggregated__non_fungible_tokens USING btree (included_in_transaction_timestamp); | ||
|
||
ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
ADD CONSTRAINT aggregated__non_fungible_tokens_fk FOREIGN KEY (included_in_transaction_hash) REFERENCES transactions (transaction_hash) ON DELETE CASCADE; | ||
|
||
ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
ADD CONSTRAINT aggregated__nft_issued_contract_id_fk FOREIGN KEY (issued_contract_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
|
||
ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
ADD CONSTRAINT aggregated__nft_predecessor_account_id_fk FOREIGN KEY (predecessor_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
ALTER TABLE ONLY aggregated__non_fungible_token_operations | ||
ADD CONSTRAINT aggregated__non_fungible_token_operations_pkey PRIMARY KEY (processed_in_transaction_hash, | ||
nft_contract_account_id, | ||
nft_affected_account_id, | ||
nft_id); | ||
|
||
ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
ADD CONSTRAINT aggregated__nft_receiver_account_id_fk FOREIGN KEY (receiver_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
-- I will edit it after we finalise the naming | ||
-- CREATE INDEX aggregated__non_fungible_tokens_timestamp_idx ON aggregated__non_fungible_tokens USING btree (included_in_transaction_timestamp); | ||
-- | ||
-- ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
-- ADD CONSTRAINT aggregated__non_fungible_tokens_fk FOREIGN KEY (included_in_transaction_hash) REFERENCES transactions (transaction_hash) ON DELETE CASCADE; | ||
-- | ||
-- ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
-- ADD CONSTRAINT aggregated__nft_issued_contract_id_fk FOREIGN KEY (issued_contract_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
-- | ||
-- ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
-- ADD CONSTRAINT aggregated__nft_predecessor_account_id_fk FOREIGN KEY (predecessor_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; | ||
-- | ||
-- ALTER TABLE ONLY aggregated__non_fungible_tokens | ||
-- ADD CONSTRAINT aggregated__nft_receiver_account_id_fk FOREIGN KEY (receiver_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |