|
| 1 | +CREATE TABLE aggregated__fungible_tokens |
| 2 | +( |
| 3 | + id bigserial NOT NULL, |
| 4 | + included_in_transaction_hash text NOT NULL, |
| 5 | + included_in_transaction_timestamp numeric(20, 0) NOT NULL, |
| 6 | + transaction_status execution_outcome_status NOT NULL, |
| 7 | + issued_contract_id text NOT NULL, |
| 8 | + called_method text NOT NULL, |
| 9 | + predecessor_account_id text NOT NULL, |
| 10 | + receiver_account_id text NOT NULL, |
| 11 | + amount numeric(45, 0) NOT NULL, |
| 12 | + args jsonb NOT NULL |
| 13 | +); |
| 14 | + |
| 15 | +ALTER TABLE ONLY aggregated__fungible_tokens |
| 16 | + ADD CONSTRAINT aggregated__fungible_tokens_pkey PRIMARY KEY (id); |
| 17 | + |
| 18 | +CREATE INDEX aggregated__fungible_tokens_timestamp_idx ON aggregated__fungible_tokens USING btree (included_in_transaction_timestamp); |
| 19 | + |
| 20 | +ALTER TABLE ONLY aggregated__fungible_tokens |
| 21 | + ADD CONSTRAINT aggregated__fungible_tokens_fk FOREIGN KEY (included_in_transaction_hash) REFERENCES transactions (transaction_hash) ON DELETE CASCADE; |
| 22 | + |
| 23 | +ALTER TABLE ONLY aggregated__fungible_tokens |
| 24 | + ADD CONSTRAINT aggregated__ft_issued_contract_id_fk FOREIGN KEY (issued_contract_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |
| 25 | + |
| 26 | +ALTER TABLE ONLY aggregated__fungible_tokens |
| 27 | + ADD CONSTRAINT aggregated__ft_predecessor_account_id_fk FOREIGN KEY (predecessor_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |
| 28 | + |
| 29 | +ALTER TABLE ONLY aggregated__fungible_tokens |
| 30 | + ADD CONSTRAINT aggregated__ft_receiver_account_id_fk FOREIGN KEY (receiver_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |
| 31 | + |
| 32 | +CREATE TABLE aggregated__non_fungible_tokens |
| 33 | +( |
| 34 | + id bigserial NOT NULL, |
| 35 | + included_in_transaction_hash text NOT NULL, |
| 36 | + included_in_transaction_timestamp numeric(20, 0) NOT NULL, |
| 37 | + transaction_status execution_outcome_status NOT NULL, |
| 38 | + issued_contract_id text NOT NULL, |
| 39 | + called_method text NOT NULL, |
| 40 | + non_fungible_token_id text NOT NULL, |
| 41 | + predecessor_account_id text NOT NULL, |
| 42 | + receiver_account_id text NOT NULL, |
| 43 | + amount numeric(45, 0) NOT NULL, |
| 44 | + args jsonb NOT NULL |
| 45 | +); |
| 46 | + |
| 47 | +ALTER TABLE ONLY aggregated__non_fungible_tokens |
| 48 | + ADD CONSTRAINT aggregated__non_fungible_tokens_pkey PRIMARY KEY (id); |
| 49 | + |
| 50 | +CREATE INDEX aggregated__non_fungible_tokens_timestamp_idx ON aggregated__non_fungible_tokens USING btree (included_in_transaction_timestamp); |
| 51 | + |
| 52 | +ALTER TABLE ONLY aggregated__non_fungible_tokens |
| 53 | + ADD CONSTRAINT aggregated__non_fungible_tokens_fk FOREIGN KEY (included_in_transaction_hash) REFERENCES transactions (transaction_hash) ON DELETE CASCADE; |
| 54 | + |
| 55 | +ALTER TABLE ONLY aggregated__non_fungible_tokens |
| 56 | + ADD CONSTRAINT aggregated__nft_issued_contract_id_fk FOREIGN KEY (issued_contract_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |
| 57 | + |
| 58 | +ALTER TABLE ONLY aggregated__non_fungible_tokens |
| 59 | + ADD CONSTRAINT aggregated__nft_predecessor_account_id_fk FOREIGN KEY (predecessor_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |
| 60 | + |
| 61 | +ALTER TABLE ONLY aggregated__non_fungible_tokens |
| 62 | + ADD CONSTRAINT aggregated__nft_receiver_account_id_fk FOREIGN KEY (receiver_account_id) REFERENCES accounts (account_id) ON DELETE CASCADE; |
0 commit comments