lbry-sdk/lbry/db/tables.py

85 lines
2.3 KiB
Python
Raw Normal View History

2020-04-12 02:01:10 +02:00
# pylint: skip-file
2020-04-11 23:27:41 +02:00
from sqlalchemy import (
MetaData, Table, Column, ForeignKey,
2020-04-12 02:01:10 +02:00
BINARY, TEXT, SMALLINT, INTEGER, BOOLEAN
2020-04-11 23:27:41 +02:00
)
metadata = MetaData()
Version = Table(
'version', metadata,
2020-04-12 02:01:10 +02:00
Column('version', TEXT, primary_key=True),
2020-04-11 23:27:41 +02:00
)
PubkeyAddress = Table(
'pubkey_address', metadata,
2020-04-12 02:01:10 +02:00
Column('address', TEXT, primary_key=True),
Column('history', TEXT, nullable=True),
Column('used_times', INTEGER, server_default='0'),
2020-04-11 23:27:41 +02:00
)
AccountAddress = Table(
'account_address', metadata,
2020-04-12 02:01:10 +02:00
Column('account', TEXT, primary_key=True),
Column('address', TEXT, ForeignKey(PubkeyAddress.columns.address), primary_key=True),
Column('chain', INTEGER),
Column('pubkey', BINARY),
Column('chain_code', BINARY),
Column('n', INTEGER),
Column('depth', INTEGER),
2020-04-11 23:27:41 +02:00
)
Block = Table(
'block', metadata,
2020-04-12 02:01:10 +02:00
Column('block_hash', BINARY, primary_key=True),
Column('previous_hash', BINARY),
Column('file_number', SMALLINT),
Column('height', INTEGER),
2020-04-11 23:27:41 +02:00
)
TX = Table(
'tx', metadata,
2020-04-12 02:01:10 +02:00
Column('block_hash', BINARY, nullable=True),
Column('tx_hash', BINARY, primary_key=True),
Column('raw', BINARY),
Column('height', INTEGER),
Column('position', SMALLINT),
Column('is_verified', BOOLEAN, server_default='FALSE'),
Column('purchased_claim_hash', BINARY, nullable=True),
Column('day', INTEGER, nullable=True),
2020-04-11 23:27:41 +02:00
)
TXO = Table(
'txo', metadata,
2020-04-12 02:01:10 +02:00
Column('tx_hash', BINARY, ForeignKey(TX.columns.tx_hash)),
Column('txo_hash', BINARY, primary_key=True),
Column('address', TEXT, ForeignKey(AccountAddress.columns.address)),
Column('position', INTEGER),
Column('amount', INTEGER),
Column('script', BINARY),
Column('is_reserved', BOOLEAN, server_default='0'),
Column('txo_type', INTEGER, server_default='0'),
Column('claim_id', TEXT, nullable=True),
Column('claim_hash', BINARY, nullable=True),
Column('claim_name', TEXT, nullable=True),
Column('channel_hash', BINARY, nullable=True),
Column('reposted_claim_hash', BINARY, nullable=True),
2020-04-11 23:27:41 +02:00
)
TXI = Table(
'txi', metadata,
2020-04-12 02:01:10 +02:00
Column('tx_hash', BINARY, ForeignKey(TX.columns.tx_hash)),
Column('txo_hash', BINARY, ForeignKey(TXO.columns.txo_hash), primary_key=True),
Column('address', TEXT, ForeignKey(AccountAddress.columns.address)),
Column('position', INTEGER),
2020-04-11 23:27:41 +02:00
)