Skip to content

Commit

Permalink
update ddl
Browse files Browse the repository at this point in the history
  • Loading branch information
gclaramunt committed Dec 19, 2024
1 parent 4ef8578 commit 578d2f0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
78 changes: 59 additions & 19 deletions sql/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

CREATE TABLE global_snapshot (
ordinal int8 NOT NULL,
hash text NOT NULL,
hash varchar NOT NULL,
height int8 NOT NULL,
subheight int8 NOT NULL,
last_snapshot_hash text NULL,
created_at timestamp NULL,
updated_at timestamp NULL,
last_snapshot_hash varchar NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL,
CONSTRAINT global_snapshot_pkey PRIMARY KEY (ordinal)
);
CREATE INDEX global_snapshot_hash_idx ON public.global_snapshot USING btree (hash);
Expand All @@ -25,28 +25,68 @@ CREATE INDEX global_snapshot_hash_idx ON public.global_snapshot USING btree (has

CREATE TABLE dag_balance_change (
ordinal int8 NOT NULL,
address text NOT NULL,
address varchar NOT NULL,
balance int8 NULL,
CONSTRAINT dag_balance_change_pk PRIMARY KEY (ordinal, address),
CONSTRAINT dag_balance_change_global_snapshot_fk FOREIGN KEY (ordinal) REFERENCES global_snapshot(ordinal)
);


-- public.block definition

-- Drop table

-- DROP TABLE block;

CREATE TABLE block (
hash varchar NOT NULL,
height int8 NOT NULL,
parent jsonb NULL,
lock_timestamp timestamp NOT NULL,
snapshot_hash varchar NOT NULL,
snapshot_ordinal int8 NOT NULL,
CONSTRAINT block_pkey PRIMARY KEY (hash)
);

CREATE TABLE dag_block (
hash varchar NOT NULL,
CONSTRAINT dag_block_pkey PRIMARY KEY (hash)
);

CREATE TABLE currency_block (
hash varchar NOT NULL,
currency_id int8, -- ?????????????
CONSTRAINT currency_block_pkey PRIMARY KEY (hash)
);


-- public.reward_transaction definition

-- Drop table

-- DROP TABLE reward_transaction;

CREATE TABLE reward_transaction (
destination_tx varchar NOT NULL,
amount int8 NOT NULL
);


-- public.dag_transaction definition

-- Drop table

-- DROP TABLE dag_transaction;

CREATE TABLE dag_transaction (
hash text NOT NULL,
hash varchar NOT NULL,
global_ordinal int8 NULL,
block text NULL,
"source" text NOT NULL,
destination text NOT NULL,
block varchar NULL,
source_addr varchar NOT NULL,
destination_addr varchar NOT NULL,
amount int8 NOT NULL,
fee int8 NOT NULL,
block_hash text NOT NULL,
block_hash varchar NOT NULL,
transaction_original_id int4 NULL,
created_at timestamp NULL,
updated_at timestamp NULL,
Expand All @@ -62,13 +102,13 @@ CREATE TABLE dag_transaction (
-- DROP TABLE metagraph_snapshot;

CREATE TABLE metagraph_snapshot (
metagraph_id text NOT NULL,
metagraph_id varchar NOT NULL,
ordinal int8 NOT NULL,
global_ordinal int8 NULL,
hash text NOT NULL,
hash varchar NOT NULL,
height int8 NOT NULL,
subheight int8 NOT NULL,
last_snapshot_hash text NULL,
last_snapshot_hash varchar NULL,
created_at timestamp NULL,
updated_at timestamp NULL,
CONSTRAINT metagraph_snapshot_pk PRIMARY KEY (metagraph_id, ordinal),
Expand All @@ -83,14 +123,14 @@ CREATE TABLE metagraph_snapshot (
-- DROP TABLE metagraph_transaction;

CREATE TABLE metagraph_transaction (
hash text NOT NULL,
metagraph_id text NULL,
block text NULL,
"source" text NOT NULL,
destination text NOT NULL,
hash varchar NOT NULL,
metagraph_id varchar NULL,
block varchar NULL,
source_addr varchar NOT NULL,
destination_addr varchar NOT NULL,
amount int8 NOT NULL,
fee int8 NOT NULL,
block_hash text NOT NULL,
block_hash varchar NOT NULL,
transaction_original_id int4 NULL,
created_at timestamp NULL,
updated_at timestamp NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.constellation.snapshotstreaming.db

object SnapshotDb {
object SnapshotDAO {


}

0 comments on commit 578d2f0

Please sign in to comment.