Skip to content

Commit

Permalink
blknum and addr composite pk for contracts, tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
bsh98 committed Dec 24, 2021
1 parent b62a2f1 commit 1a0bac2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ethereumetl/streaming/postgres_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from sqlalchemy import Table, Column, Integer, BigInteger, Boolean, String, Numeric, MetaData, VARCHAR, TIMESTAMP
from sqlalchemy import Table, Column, Integer, BigInteger, Boolean, String, Numeric, \
MetaData, PrimaryKeyConstraint, VARCHAR, TIMESTAMP
from sqlalchemy.dialects.postgresql import ARRAY

metadata = MetaData()
Expand Down Expand Up @@ -130,20 +131,23 @@

TOKENS = Table(
'tokens', metadata,
Column('address', VARCHAR(42), primary_key=True),
Column('address', VARCHAR(42)),
Column('name', String),
Column('symbol', String),
Column('decimals', Integer),
Column('function_sighashes', ARRAY(String)),
Column('total_supply', Numeric(78)),
Column('block_number', BigInteger),
PrimaryKeyConstraint('address', 'block_number', name='tokens_pk'),
)

CONTRACTS = Table(
'contracts', metadata,
Column('address', VARCHAR(42), primary_key=True),
Column('address', VARCHAR(42)),
Column('bytecode', String),
Column('function_sighashes', ARRAY(String)),
Column('is_erc20', Boolean),
Column('is_erc721', Boolean),
Column('block_number', BigInteger),
PrimaryKeyConstraint('address', 'block_number', name='contracts_pk'),
)

0 comments on commit 1a0bac2

Please sign in to comment.