kopia lustrzana https://github.com/bugout-dev/moonstream
Merge pull request #1030 from moonstream-to/mdb-v3-init
Initial version of moonstreamdb-v3pull/1046/head
commit
1f31738b44
|
@ -0,0 +1,197 @@
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=python,visualstudiocode
|
||||||
|
|
||||||
|
### Python ###
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/python,visualstudiocode
|
||||||
|
|
||||||
|
# Envionments
|
||||||
|
.moonstream/
|
||||||
|
.moonstreamdb/
|
||||||
|
.moonstreamdb-v3/
|
||||||
|
.db/
|
||||||
|
.venv/
|
||||||
|
.env/
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
dev.env
|
||||||
|
test.env
|
||||||
|
prod.env
|
||||||
|
moonstreamdb.env
|
||||||
|
moonstreamdb-v3.env
|
||||||
|
docker.env
|
||||||
|
docker.dev.env
|
||||||
|
docker.test.dev
|
||||||
|
docker.prod.env
|
||||||
|
docker.moonstreamdb-v3.env
|
||||||
|
|
||||||
|
.secrets/
|
||||||
|
|
||||||
|
# Alembic migrations
|
||||||
|
alembic.test.ini
|
||||||
|
alembic.dev.ini
|
||||||
|
alembic.prod.ini
|
||||||
|
alembic.moonstreamdb-v3.ini
|
||||||
|
alembic.docker.ini
|
||||||
|
|
||||||
|
# Schematic
|
||||||
|
srv/
|
||||||
|
.schematic.env
|
||||||
|
|
||||||
|
# Custom
|
||||||
|
scratch/
|
|
@ -0,0 +1,3 @@
|
||||||
|
[settings]
|
||||||
|
profile = black
|
||||||
|
multi_line_output = 3
|
|
@ -0,0 +1 @@
|
||||||
|
# moonstreamdb-v3
|
|
@ -0,0 +1,116 @@
|
||||||
|
# A generic, single database configuration.
|
||||||
|
|
||||||
|
[alembic]
|
||||||
|
# path to migration scripts
|
||||||
|
script_location = moonstreamdbv3/alembic
|
||||||
|
|
||||||
|
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
|
||||||
|
# Uncomment the line below if you want the files to be prepended with date and time
|
||||||
|
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
|
||||||
|
# for all available tokens
|
||||||
|
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
||||||
|
|
||||||
|
# sys.path path, will be prepended to sys.path if present.
|
||||||
|
# defaults to the current working directory.
|
||||||
|
prepend_sys_path = .
|
||||||
|
|
||||||
|
# timezone to use when rendering the date within the migration file
|
||||||
|
# as well as the filename.
|
||||||
|
# If specified, requires the python>=3.9 or backports.zoneinfo library.
|
||||||
|
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
|
||||||
|
# string value is passed to ZoneInfo()
|
||||||
|
# leave blank for localtime
|
||||||
|
# timezone =
|
||||||
|
|
||||||
|
# max length of characters to apply to the
|
||||||
|
# "slug" field
|
||||||
|
# truncate_slug_length = 40
|
||||||
|
|
||||||
|
# set to 'true' to run the environment during
|
||||||
|
# the 'revision' command, regardless of autogenerate
|
||||||
|
# revision_environment = false
|
||||||
|
|
||||||
|
# set to 'true' to allow .pyc and .pyo files without
|
||||||
|
# a source .py file to be detected as revisions in the
|
||||||
|
# versions/ directory
|
||||||
|
# sourceless = false
|
||||||
|
|
||||||
|
# version location specification; This defaults
|
||||||
|
# to alembic/versions. When using multiple version
|
||||||
|
# directories, initial revisions must be specified with --version-path.
|
||||||
|
# The path separator used here should be the separator specified by "version_path_separator" below.
|
||||||
|
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions
|
||||||
|
|
||||||
|
# version path separator; As mentioned above, this is the character used to split
|
||||||
|
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
|
||||||
|
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
|
||||||
|
# Valid values for version_path_separator are:
|
||||||
|
#
|
||||||
|
# version_path_separator = :
|
||||||
|
# version_path_separator = ;
|
||||||
|
# version_path_separator = space
|
||||||
|
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
|
||||||
|
|
||||||
|
# set to 'true' to search source files recursively
|
||||||
|
# in each "version_locations" directory
|
||||||
|
# new in Alembic version 1.10
|
||||||
|
# recursive_version_locations = false
|
||||||
|
|
||||||
|
# the output encoding used when revision files
|
||||||
|
# are written from script.py.mako
|
||||||
|
# output_encoding = utf-8
|
||||||
|
|
||||||
|
sqlalchemy.url = driver://user:pass@localhost/dbname
|
||||||
|
|
||||||
|
|
||||||
|
[post_write_hooks]
|
||||||
|
# post_write_hooks defines scripts or Python functions that are run
|
||||||
|
# on newly generated revision scripts. See the documentation for further
|
||||||
|
# detail and examples
|
||||||
|
|
||||||
|
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
||||||
|
# hooks = black
|
||||||
|
# black.type = console_scripts
|
||||||
|
# black.entrypoint = black
|
||||||
|
# black.options = -l 79 REVISION_SCRIPT_FILENAME
|
||||||
|
|
||||||
|
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
|
||||||
|
# hooks = ruff
|
||||||
|
# ruff.type = exec
|
||||||
|
# ruff.executable = %(here)s/.venv/bin/ruff
|
||||||
|
# ruff.options = --fix REVISION_SCRIPT_FILENAME
|
||||||
|
|
||||||
|
# Logging configuration
|
||||||
|
[loggers]
|
||||||
|
keys = root,sqlalchemy,alembic
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys = console
|
||||||
|
|
||||||
|
[formatters]
|
||||||
|
keys = generic
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level = WARN
|
||||||
|
handlers = console
|
||||||
|
qualname =
|
||||||
|
|
||||||
|
[logger_sqlalchemy]
|
||||||
|
level = WARN
|
||||||
|
handlers =
|
||||||
|
qualname = sqlalchemy.engine
|
||||||
|
|
||||||
|
[logger_alembic]
|
||||||
|
level = INFO
|
||||||
|
handlers =
|
||||||
|
qualname = alembic
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class = StreamHandler
|
||||||
|
args = (sys.stderr,)
|
||||||
|
level = NOTSET
|
||||||
|
formatter = generic
|
||||||
|
|
||||||
|
[formatter_generic]
|
||||||
|
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||||
|
datefmt = %H:%M:%S
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
PYTHONPATH=".:$PYTHONPATH" alembic "$@"
|
|
@ -0,0 +1 @@
|
||||||
|
Generic single-database configuration.
|
|
@ -0,0 +1,126 @@
|
||||||
|
from logging.config import fileConfig
|
||||||
|
|
||||||
|
from sqlalchemy import engine_from_config
|
||||||
|
from sqlalchemy import pool
|
||||||
|
|
||||||
|
from alembic import context
|
||||||
|
|
||||||
|
# this is the Alembic Config object, which provides
|
||||||
|
# access to the values within the .ini file in use.
|
||||||
|
config = context.config
|
||||||
|
|
||||||
|
# Interpret the config file for Python logging.
|
||||||
|
# This line sets up loggers basically.
|
||||||
|
if config.config_file_name is not None:
|
||||||
|
fileConfig(config.config_file_name)
|
||||||
|
|
||||||
|
# add your model's MetaData object here
|
||||||
|
# for 'autogenerate' support
|
||||||
|
# from myapp import mymodel
|
||||||
|
# target_metadata = mymodel.Base.metadata
|
||||||
|
from moonstreamdbv3.models import Base as MoonstreamBase
|
||||||
|
|
||||||
|
target_metadata = MoonstreamBase.metadata
|
||||||
|
|
||||||
|
# other values from the config, defined by the needs of env.py,
|
||||||
|
# can be acquired:
|
||||||
|
# my_important_option = config.get_main_option("my_important_option")
|
||||||
|
# ... etc.
|
||||||
|
from moonstreamdbv3.models import (
|
||||||
|
EthereumLabel,
|
||||||
|
SepoliaLabel,
|
||||||
|
PolygonLabel,
|
||||||
|
MumbaiLabel,
|
||||||
|
XDaiLabel,
|
||||||
|
ZkSyncEraLabel,
|
||||||
|
ZkSyncEraSepoliaLabel,
|
||||||
|
BaseLabel,
|
||||||
|
ArbitrumNovaLabel,
|
||||||
|
ArbitrumSepoliaLabel,
|
||||||
|
XaiLabel,
|
||||||
|
XaiSepoliaLabel,
|
||||||
|
AvalancheLabel,
|
||||||
|
AvalancheFujiLabel,
|
||||||
|
StarknetLabel,
|
||||||
|
StarknetSepoliaLabel,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def include_symbol(tablename, schema):
|
||||||
|
return tablename in {
|
||||||
|
EthereumLabel.__tablename__,
|
||||||
|
SepoliaLabel.__tablename__,
|
||||||
|
PolygonLabel.__tablename__,
|
||||||
|
MumbaiLabel.__tablename__,
|
||||||
|
XDaiLabel.__tablename__,
|
||||||
|
ZkSyncEraLabel.__tablename__,
|
||||||
|
ZkSyncEraSepoliaLabel.__tablename__,
|
||||||
|
BaseLabel.__tablename__,
|
||||||
|
ArbitrumNovaLabel.__tablename__,
|
||||||
|
ArbitrumSepoliaLabel.__tablename__,
|
||||||
|
XaiLabel.__tablename__,
|
||||||
|
XaiSepoliaLabel.__tablename__,
|
||||||
|
AvalancheLabel.__tablename__,
|
||||||
|
AvalancheFujiLabel.__tablename__,
|
||||||
|
StarknetLabel.__tablename__,
|
||||||
|
StarknetSepoliaLabel.__tablename__,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_offline() -> None:
|
||||||
|
"""Run migrations in 'offline' mode.
|
||||||
|
|
||||||
|
This configures the context with just a URL
|
||||||
|
and not an Engine, though an Engine is acceptable
|
||||||
|
here as well. By skipping the Engine creation
|
||||||
|
we don't even need a DBAPI to be available.
|
||||||
|
|
||||||
|
Calls to context.execute() here emit the given string to the
|
||||||
|
script output.
|
||||||
|
|
||||||
|
"""
|
||||||
|
url = config.get_main_option("sqlalchemy.url")
|
||||||
|
context.configure(
|
||||||
|
url=url,
|
||||||
|
target_metadata=target_metadata,
|
||||||
|
literal_binds=True,
|
||||||
|
dialect_opts={"paramstyle": "named"},
|
||||||
|
version_table="alembic_version",
|
||||||
|
include_schemas=True,
|
||||||
|
include_symbol=include_symbol,
|
||||||
|
)
|
||||||
|
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
def run_migrations_online() -> None:
|
||||||
|
"""Run migrations in 'online' mode.
|
||||||
|
|
||||||
|
In this scenario we need to create an Engine
|
||||||
|
and associate a connection with the context.
|
||||||
|
|
||||||
|
"""
|
||||||
|
connectable = engine_from_config(
|
||||||
|
config.get_section(config.config_ini_section, {}),
|
||||||
|
prefix="sqlalchemy.",
|
||||||
|
poolclass=pool.NullPool,
|
||||||
|
)
|
||||||
|
|
||||||
|
with connectable.connect() as connection:
|
||||||
|
context.configure(
|
||||||
|
connection=connection,
|
||||||
|
target_metadata=target_metadata,
|
||||||
|
version_table="alembic_version",
|
||||||
|
include_schemas=True,
|
||||||
|
include_symbol=include_symbol,
|
||||||
|
)
|
||||||
|
|
||||||
|
with context.begin_transaction():
|
||||||
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
if context.is_offline_mode():
|
||||||
|
run_migrations_offline()
|
||||||
|
else:
|
||||||
|
run_migrations_online()
|
|
@ -0,0 +1,26 @@
|
||||||
|
"""${message}
|
||||||
|
|
||||||
|
Revision ID: ${up_revision}
|
||||||
|
Revises: ${down_revision | comma,n}
|
||||||
|
Create Date: ${create_date}
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
${imports if imports else ""}
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = ${repr(up_revision)}
|
||||||
|
down_revision: Union[str, None] = ${repr(down_revision)}
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||||
|
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
${upgrades if upgrades else "pass"}
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
${downgrades if downgrades else "pass"}
|
|
@ -0,0 +1,620 @@
|
||||||
|
"""Tables initial generation
|
||||||
|
|
||||||
|
Revision ID: 994e614b5500
|
||||||
|
Revises:
|
||||||
|
Create Date: 2024-03-14 07:03:35.586195
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '994e614b5500'
|
||||||
|
down_revision: Union[str, None] = None
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('arbitrum_nova_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_arbitrum_nova_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_arbitrum_nova_labels_id')),
|
||||||
|
)
|
||||||
|
op.create_index('ix_arbitrum_nova_labels_addr_block_num', 'arbitrum_nova_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_address'), 'arbitrum_nova_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_block_number'), 'arbitrum_nova_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_caller_address'), 'arbitrum_nova_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_label'), 'arbitrum_nova_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_label_name'), 'arbitrum_nova_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_label_type'), 'arbitrum_nova_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_origin_address'), 'arbitrum_nova_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_nova_labels_transaction_hash'), 'arbitrum_nova_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('arbitrum_sepolia_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_arbitrum_sepolia_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_arbitrum_sepolia_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_arbitrum_sepolia_labels_addr_block_num', 'arbitrum_sepolia_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_address'), 'arbitrum_sepolia_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_block_number'), 'arbitrum_sepolia_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_caller_address'), 'arbitrum_sepolia_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_label'), 'arbitrum_sepolia_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_label_name'), 'arbitrum_sepolia_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_label_type'), 'arbitrum_sepolia_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_origin_address'), 'arbitrum_sepolia_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_arbitrum_sepolia_labels_transaction_hash'), 'arbitrum_sepolia_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('base_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_base_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_base_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_base_labels_addr_block_num', 'base_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_address'), 'base_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_block_number'), 'base_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_caller_address'), 'base_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_label'), 'base_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_label_name'), 'base_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_label_type'), 'base_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_origin_address'), 'base_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_base_labels_transaction_hash'), 'base_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('ethereum_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_ethereum_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_ethereum_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_ethereum_labels_addr_block_num', 'ethereum_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_address'), 'ethereum_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_block_number'), 'ethereum_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_caller_address'), 'ethereum_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_label'), 'ethereum_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_label_name'), 'ethereum_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_label_type'), 'ethereum_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_origin_address'), 'ethereum_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_ethereum_labels_transaction_hash'), 'ethereum_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('mumbai_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_mumbai_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_mumbai_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_mumbai_labels_addr_block_num', 'mumbai_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_address'), 'mumbai_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_block_number'), 'mumbai_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_caller_address'), 'mumbai_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_label'), 'mumbai_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_label_name'), 'mumbai_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_label_type'), 'mumbai_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_origin_address'), 'mumbai_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_mumbai_labels_transaction_hash'), 'mumbai_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('polygon_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_polygon_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_polygon_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_polygon_labels_addr_block_num', 'polygon_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_address'), 'polygon_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_block_number'), 'polygon_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_caller_address'), 'polygon_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_label'), 'polygon_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_label_name'), 'polygon_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_label_type'), 'polygon_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_origin_address'), 'polygon_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_polygon_labels_transaction_hash'), 'polygon_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('sepolia_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_sepolia_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_sepolia_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_sepolia_labels_addr_block_num', 'sepolia_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_address'), 'sepolia_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_block_number'), 'sepolia_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_caller_address'), 'sepolia_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_label'), 'sepolia_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_label_name'), 'sepolia_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_label_type'), 'sepolia_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_origin_address'), 'sepolia_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_sepolia_labels_transaction_hash'), 'sepolia_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('xai_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_xai_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_xai_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_xai_labels_addr_block_num', 'xai_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_address'), 'xai_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_block_number'), 'xai_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_caller_address'), 'xai_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_label'), 'xai_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_label_name'), 'xai_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_label_type'), 'xai_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_origin_address'), 'xai_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_labels_transaction_hash'), 'xai_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('xai_sepolia_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_xai_sepolia_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_xai_sepolia_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_xai_sepolia_labels_addr_block_num', 'xai_sepolia_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_address'), 'xai_sepolia_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_block_number'), 'xai_sepolia_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_caller_address'), 'xai_sepolia_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_label'), 'xai_sepolia_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_label_name'), 'xai_sepolia_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_label_type'), 'xai_sepolia_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_origin_address'), 'xai_sepolia_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xai_sepolia_labels_transaction_hash'), 'xai_sepolia_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('xdai_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_xdai_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_xdai_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_xdai_labels_addr_block_num', 'xdai_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_address'), 'xdai_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_block_number'), 'xdai_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_caller_address'), 'xdai_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_label'), 'xdai_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_label_name'), 'xdai_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_label_type'), 'xdai_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_origin_address'), 'xdai_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_xdai_labels_transaction_hash'), 'xdai_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('zksync_era_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_zksync_era_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_zksync_era_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_zksync_era_labels_addr_block_num', 'zksync_era_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_address'), 'zksync_era_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_block_number'), 'zksync_era_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_caller_address'), 'zksync_era_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_label'), 'zksync_era_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_label_name'), 'zksync_era_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_label_type'), 'zksync_era_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_origin_address'), 'zksync_era_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_labels_transaction_hash'), 'zksync_era_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('zksync_era_sepolia_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_zksync_era_sepolia_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_zksync_era_sepolia_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_zksync_era_sepolia_labels_addr_block_num', 'zksync_era_sepolia_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_address'), 'zksync_era_sepolia_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_block_number'), 'zksync_era_sepolia_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_caller_address'), 'zksync_era_sepolia_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_label'), 'zksync_era_sepolia_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_label_name'), 'zksync_era_sepolia_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_label_type'), 'zksync_era_sepolia_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_origin_address'), 'zksync_era_sepolia_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_zksync_era_sepolia_labels_transaction_hash'), 'zksync_era_sepolia_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('avalanche_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_avalanche_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_avalanche_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_avalanche_labels_addr_block_num', 'avalanche_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_address'), 'avalanche_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_block_number'), 'avalanche_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_caller_address'), 'avalanche_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_label'), 'avalanche_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_label_name'), 'avalanche_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_label_type'), 'avalanche_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_origin_address'), 'avalanche_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_labels_transaction_hash'), 'avalanche_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('avalanche_fuji_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_avalanche_fuji_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_avalanche_fuji_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_avalanche_fuji_labels_addr_block_num', 'avalanche_fuji_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_address'), 'avalanche_fuji_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_block_number'), 'avalanche_fuji_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_caller_address'), 'avalanche_fuji_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_label'), 'avalanche_fuji_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_label_name'), 'avalanche_fuji_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_label_type'), 'avalanche_fuji_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_origin_address'), 'avalanche_fuji_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_avalanche_fuji_labels_transaction_hash'), 'avalanche_fuji_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('starknet_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_starknet_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_starknet_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_starknet_labels_addr_block_num', 'starknet_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_address'), 'starknet_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_block_number'), 'starknet_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_caller_address'), 'starknet_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_label'), 'starknet_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_label_name'), 'starknet_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_label_type'), 'starknet_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_origin_address'), 'starknet_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_labels_transaction_hash'), 'starknet_labels', ['transaction_hash'], unique=False)
|
||||||
|
op.create_table('starknet_sepolia_labels',
|
||||||
|
sa.Column('id', sa.UUID(), nullable=False),
|
||||||
|
sa.Column('label', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('transaction_hash', sa.VARCHAR(length=128), nullable=False),
|
||||||
|
sa.Column('log_index', sa.Integer(), nullable=True),
|
||||||
|
sa.Column('block_number', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
|
||||||
|
sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
|
||||||
|
sa.Column('caller_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_name', sa.Text(), nullable=True),
|
||||||
|
sa.Column('label_type', sa.VARCHAR(length=64), nullable=True),
|
||||||
|
sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
|
||||||
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_starknet_sepolia_labels')),
|
||||||
|
sa.UniqueConstraint('id', name=op.f('uq_starknet_sepolia_labels_id'))
|
||||||
|
)
|
||||||
|
op.create_index('ix_starknet_sepolia_labels_addr_block_num', 'starknet_sepolia_labels', ['address', 'block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_address'), 'starknet_sepolia_labels', ['address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_block_number'), 'starknet_sepolia_labels', ['block_number'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_caller_address'), 'starknet_sepolia_labels', ['caller_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_label'), 'starknet_sepolia_labels', ['label'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_label_name'), 'starknet_sepolia_labels', ['label_name'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_label_type'), 'starknet_sepolia_labels', ['label_type'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_origin_address'), 'starknet_sepolia_labels', ['origin_address'], unique=False)
|
||||||
|
op.create_index(op.f('ix_starknet_sepolia_labels_transaction_hash'), 'starknet_sepolia_labels', ['transaction_hash'], unique=False)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_transaction_hash'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_origin_address'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_label_type'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_label_name'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_label'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_caller_address'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_block_number'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_sepolia_labels_address'), table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_index('ix_zksync_era_sepolia_labels_addr_block_num', table_name='zksync_era_sepolia_labels')
|
||||||
|
op.drop_table('zksync_era_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_transaction_hash'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_origin_address'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_label_type'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_label_name'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_label'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_caller_address'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_block_number'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_zksync_era_labels_address'), table_name='zksync_era_labels')
|
||||||
|
op.drop_index('ix_zksync_era_labels_addr_block_num', table_name='zksync_era_labels')
|
||||||
|
op.drop_table('zksync_era_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_transaction_hash'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_origin_address'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_label_type'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_label_name'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_label'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_caller_address'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_block_number'), table_name='xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xdai_labels_address'), table_name='xdai_labels')
|
||||||
|
op.drop_index('ix_xdai_labels_addr_block_num', table_name='xdai_labels')
|
||||||
|
op.drop_table('xdai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_transaction_hash'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_origin_address'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_label_type'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_label_name'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_label'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_caller_address'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_block_number'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_sepolia_labels_address'), table_name='xai_sepolia_labels')
|
||||||
|
op.drop_index('ix_xai_sepolia_labels_addr_block_num', table_name='xai_sepolia_labels')
|
||||||
|
op.drop_table('xai_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_transaction_hash'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_origin_address'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_label_type'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_label_name'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_label'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_caller_address'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_block_number'), table_name='xai_labels')
|
||||||
|
op.drop_index(op.f('ix_xai_labels_address'), table_name='xai_labels')
|
||||||
|
op.drop_index('ix_xai_labels_addr_block_num', table_name='xai_labels')
|
||||||
|
op.drop_table('xai_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_transaction_hash'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_origin_address'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_label_type'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_label_name'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_label'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_caller_address'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_block_number'), table_name='sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_sepolia_labels_address'), table_name='sepolia_labels')
|
||||||
|
op.drop_index('ix_sepolia_labels_addr_block_num', table_name='sepolia_labels')
|
||||||
|
op.drop_table('sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_transaction_hash'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_origin_address'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_label_type'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_label_name'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_label'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_caller_address'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_block_number'), table_name='polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_polygon_labels_address'), table_name='polygon_labels')
|
||||||
|
op.drop_index('ix_polygon_labels_addr_block_num', table_name='polygon_labels')
|
||||||
|
op.drop_table('polygon_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_transaction_hash'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_origin_address'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_label_type'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_label_name'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_label'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_caller_address'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_block_number'), table_name='mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_mumbai_labels_address'), table_name='mumbai_labels')
|
||||||
|
op.drop_index('ix_mumbai_labels_addr_block_num', table_name='mumbai_labels')
|
||||||
|
op.drop_table('mumbai_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_transaction_hash'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_origin_address'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_label_type'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_label_name'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_label'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_caller_address'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_block_number'), table_name='ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_ethereum_labels_address'), table_name='ethereum_labels')
|
||||||
|
op.drop_index('ix_ethereum_labels_addr_block_num', table_name='ethereum_labels')
|
||||||
|
op.drop_table('ethereum_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_transaction_hash'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_origin_address'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_label_type'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_label_name'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_label'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_caller_address'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_block_number'), table_name='base_labels')
|
||||||
|
op.drop_index(op.f('ix_base_labels_address'), table_name='base_labels')
|
||||||
|
op.drop_index('ix_base_labels_addr_block_num', table_name='base_labels')
|
||||||
|
op.drop_table('base_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_transaction_hash'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_origin_address'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_label_type'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_label_name'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_label'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_caller_address'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_block_number'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_sepolia_labels_address'), table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_index('ix_arbitrum_sepolia_labels_addr_block_num', table_name='arbitrum_sepolia_labels')
|
||||||
|
op.drop_table('arbitrum_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_transaction_hash'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_origin_address'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_label_type'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_label_name'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_label'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_caller_address'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_block_number'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_arbitrum_nova_labels_address'), table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_index('ix_arbitrum_nova_labels_addr_block_num', table_name='arbitrum_nova_labels')
|
||||||
|
op.drop_table('arbitrum_nova_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_transaction_hash'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_origin_address'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_label_type'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_label_name'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_label'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_caller_address'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_block_number'), table_name='avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_labels_address'), table_name='avalanche_labels')
|
||||||
|
op.drop_index('ix_avalanche_labels_addr_block_num', table_name='avalanche_labels')
|
||||||
|
op.drop_table('avalanche_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_transaction_hash'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_origin_address'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_label_type'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_label_name'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_label'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_caller_address'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_block_number'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_avalanche_fuji_labels_address'), table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_index('ix_avalanche_fuji_labels_addr_block_num', table_name='avalanche_fuji_labels')
|
||||||
|
op.drop_table('avalanche_fuji_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_transaction_hash'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_origin_address'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_label_type'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_label_name'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_label'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_caller_address'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_block_number'), table_name='starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_labels_address'), table_name='starknet_labels')
|
||||||
|
op.drop_index('ix_starknet_labels_addr_block_num', table_name='starknet_labels')
|
||||||
|
op.drop_table('starknet_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_transaction_hash'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_origin_address'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_label_type'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_label_name'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_label'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_caller_address'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_block_number'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index(op.f('ix_starknet_sepolia_labels_address'), table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_index('ix_starknet_sepolia_labels_addr_block_num', table_name='starknet_sepolia_labels')
|
||||||
|
op.drop_table('starknet_sepolia_labels')
|
||||||
|
# ### end Alembic commands ###
|
|
@ -0,0 +1,147 @@
|
||||||
|
"""
|
||||||
|
Moonstream database connection.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from typing import Generator, Optional
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine
|
||||||
|
from sqlalchemy.orm import Session, sessionmaker
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
MOONSTREAM_DB_URI = os.environ.get("MOONSTREAM_DB_URI")
|
||||||
|
if MOONSTREAM_DB_URI is None:
|
||||||
|
raise Warning("MOONSTREAM_DB_URI environment variable must be set")
|
||||||
|
|
||||||
|
MOONSTREAM_DB_URI_READ_ONLY = os.environ.get("MOONSTREAM_DB_URI_READ_ONLY")
|
||||||
|
if MOONSTREAM_DB_URI_READ_ONLY is None:
|
||||||
|
raise Warning("MOONSTREAM_DB_URI_READ_ONLY environment variable must be set")
|
||||||
|
|
||||||
|
MOONSTREAM_POOL_SIZE_RAW = os.environ.get("MOONSTREAM_POOL_SIZE")
|
||||||
|
MOONSTREAM_POOL_SIZE = 1
|
||||||
|
try:
|
||||||
|
if MOONSTREAM_POOL_SIZE_RAW is not None:
|
||||||
|
MOONSTREAM_POOL_SIZE = int(MOONSTREAM_POOL_SIZE_RAW)
|
||||||
|
except:
|
||||||
|
raise ValueError(
|
||||||
|
f"Could not parse MOONSTREAM_POOL_SIZE as int: {MOONSTREAM_POOL_SIZE_RAW}"
|
||||||
|
)
|
||||||
|
|
||||||
|
MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS_RAW = os.environ.get(
|
||||||
|
"MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS"
|
||||||
|
)
|
||||||
|
MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS = 30000
|
||||||
|
try:
|
||||||
|
if MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS_RAW is not None:
|
||||||
|
MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS = int(
|
||||||
|
MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS_RAW
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
raise ValueError(
|
||||||
|
f"MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS must be an integer: {MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS_RAW}"
|
||||||
|
)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError(e)
|
||||||
|
except Warning:
|
||||||
|
logger.warning("Database variables not set")
|
||||||
|
|
||||||
|
|
||||||
|
def create_moonstream_engine(
|
||||||
|
url: str,
|
||||||
|
pool_size: int,
|
||||||
|
statement_timeout: int,
|
||||||
|
pool_pre_ping: bool = False,
|
||||||
|
schema: Optional[str] = None,
|
||||||
|
):
|
||||||
|
# Pooling: https://docs.sqlalchemy.org/en/14/core/pooling.html#sqlalchemy.pool.QueuePool
|
||||||
|
# Statement timeout: https://stackoverflow.com/a/44936982
|
||||||
|
options = f"-c statement_timeout={statement_timeout}"
|
||||||
|
if schema is not None:
|
||||||
|
options += f" -c search_path={schema}"
|
||||||
|
return create_engine(
|
||||||
|
url=url,
|
||||||
|
pool_pre_ping=pool_pre_ping,
|
||||||
|
pool_size=pool_size,
|
||||||
|
connect_args={"options": options},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MoonstreamDBEngine:
|
||||||
|
def __init__(self, schema: Optional[str] = None) -> None:
|
||||||
|
self._engine = create_moonstream_engine(
|
||||||
|
url=MOONSTREAM_DB_URI, # type: ignore
|
||||||
|
pool_size=MOONSTREAM_POOL_SIZE,
|
||||||
|
statement_timeout=MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS,
|
||||||
|
schema=schema,
|
||||||
|
)
|
||||||
|
self._session_local = sessionmaker(bind=self.engine)
|
||||||
|
|
||||||
|
self._yield_db_session_ctx = contextmanager(self.yield_db_session)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def engine(self):
|
||||||
|
return self._engine
|
||||||
|
|
||||||
|
@property
|
||||||
|
def session_local(self):
|
||||||
|
return self._session_local
|
||||||
|
|
||||||
|
@property
|
||||||
|
def yield_db_session_ctx(self):
|
||||||
|
return self._yield_db_session_ctx
|
||||||
|
|
||||||
|
def yield_db_session(
|
||||||
|
self,
|
||||||
|
) -> Generator[Session, None, None]:
|
||||||
|
"""
|
||||||
|
Yields a database connection (created using environment variables).
|
||||||
|
As per FastAPI docs:
|
||||||
|
https://fastapi.tiangolo.com/tutorial/sql-databases/#create-a-dependency
|
||||||
|
"""
|
||||||
|
session = self._session_local()
|
||||||
|
try:
|
||||||
|
yield session
|
||||||
|
finally:
|
||||||
|
session.close()
|
||||||
|
|
||||||
|
|
||||||
|
class MoonstreamDBEngineRO:
|
||||||
|
def __init__(self, schema: Optional[str] = None) -> None:
|
||||||
|
self._RO_engine = create_moonstream_engine(
|
||||||
|
url=MOONSTREAM_DB_URI_READ_ONLY, # type: ignore
|
||||||
|
pool_size=MOONSTREAM_POOL_SIZE,
|
||||||
|
statement_timeout=MOONSTREAM_DB_STATEMENT_TIMEOUT_MILLIS,
|
||||||
|
schema=schema,
|
||||||
|
)
|
||||||
|
self._RO_session_local = sessionmaker(bind=self.RO_engine)
|
||||||
|
|
||||||
|
self._RO_yield_db_session_ctx = contextmanager(self.yield_db_read_only_session)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def RO_engine(self):
|
||||||
|
return self._RO_engine
|
||||||
|
|
||||||
|
@property
|
||||||
|
def RO_session_local(self):
|
||||||
|
return self._RO_session_local
|
||||||
|
|
||||||
|
@property
|
||||||
|
def RO_yield_db_session_ctx(self):
|
||||||
|
return self._RO_yield_db_session_ctx
|
||||||
|
|
||||||
|
def yield_db_read_only_session(self) -> Generator[Session, None, None]:
|
||||||
|
"""
|
||||||
|
Yields read-only database connection (created using environment variables).
|
||||||
|
As per FastAPI docs:
|
||||||
|
https://fastapi.tiangolo.com/tutorial/sql-databases/#create-a-dependency
|
||||||
|
"""
|
||||||
|
session = self._RO_session_local()
|
||||||
|
try:
|
||||||
|
yield session
|
||||||
|
finally:
|
||||||
|
session.close()
|
|
@ -0,0 +1,421 @@
|
||||||
|
"""
|
||||||
|
Moonstream database V3
|
||||||
|
|
||||||
|
Example of label_data column record:
|
||||||
|
{
|
||||||
|
"label": "ERC20",
|
||||||
|
"label_data": {
|
||||||
|
"name": "Uniswap",
|
||||||
|
"symbol": "UNI"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Exchange"
|
||||||
|
"label_data": {...}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from sqlalchemy import (
|
||||||
|
VARCHAR,
|
||||||
|
BigInteger,
|
||||||
|
Column,
|
||||||
|
DateTime,
|
||||||
|
Index,
|
||||||
|
Integer,
|
||||||
|
MetaData,
|
||||||
|
Text,
|
||||||
|
)
|
||||||
|
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
||||||
|
from sqlalchemy.ext.compiler import compiles
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.sql import expression
|
||||||
|
|
||||||
|
"""
|
||||||
|
Naming conventions doc
|
||||||
|
https://docs.sqlalchemy.org/en/20/core/constraints.html#configuring-constraint-naming-conventions
|
||||||
|
"""
|
||||||
|
convention = {
|
||||||
|
"ix": "ix_%(column_0_label)s",
|
||||||
|
"uq": "uq_%(table_name)s_%(column_0_name)s",
|
||||||
|
"ck": "ck_%(table_name)s_%(constraint_name)s",
|
||||||
|
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
|
||||||
|
"pk": "pk_%(table_name)s",
|
||||||
|
}
|
||||||
|
metadata = MetaData(naming_convention=convention)
|
||||||
|
Base = declarative_base(metadata=metadata)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Creating a utcnow function which runs on the Posgres database server when created_at and updated_at
|
||||||
|
fields are populated.
|
||||||
|
Following:
|
||||||
|
1. https://docs.sqlalchemy.org/en/13/core/compiler.html#utc-timestamp-function
|
||||||
|
2. https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
|
||||||
|
3. https://stackoverflow.com/a/33532154/13659585
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class utcnow(expression.FunctionElement):
|
||||||
|
type = DateTime # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
@compiles(utcnow, "postgresql")
|
||||||
|
def pg_utcnow(element, compiler, **kwargs):
|
||||||
|
return "TIMEZONE('utc', statement_timestamp())"
|
||||||
|
|
||||||
|
|
||||||
|
class EvmBasedLabel(Base): # type: ignore
|
||||||
|
__abstract__ = True
|
||||||
|
|
||||||
|
id = Column(
|
||||||
|
UUID(as_uuid=True),
|
||||||
|
primary_key=True,
|
||||||
|
default=uuid.uuid4,
|
||||||
|
unique=True,
|
||||||
|
nullable=False,
|
||||||
|
)
|
||||||
|
label = Column(VARCHAR(256), nullable=False, index=True)
|
||||||
|
|
||||||
|
transaction_hash = Column(
|
||||||
|
VARCHAR(128),
|
||||||
|
nullable=False,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
log_index = Column(Integer, nullable=True)
|
||||||
|
|
||||||
|
block_number = Column(
|
||||||
|
BigInteger,
|
||||||
|
nullable=False,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
block_hash = Column(VARCHAR(256), nullable=False)
|
||||||
|
block_timestamp = Column(BigInteger, nullable=False)
|
||||||
|
|
||||||
|
caller_address = Column(
|
||||||
|
VARCHAR(64),
|
||||||
|
nullable=True,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
origin_address = Column(
|
||||||
|
VARCHAR(64),
|
||||||
|
nullable=True,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
address = Column(
|
||||||
|
VARCHAR(64),
|
||||||
|
nullable=True,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
label_name = Column(Text, nullable=True, index=True)
|
||||||
|
label_type = Column(VARCHAR(64), nullable=True, index=True)
|
||||||
|
label_data = Column(JSONB, nullable=True)
|
||||||
|
|
||||||
|
created_at = Column(
|
||||||
|
DateTime(timezone=True), server_default=utcnow(), nullable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class EthereumLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "ethereum_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_ethereum_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_ethereum_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SepoliaLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "sepolia_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_sepolia_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_sepolia_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PolygonLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "polygon_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_polygon_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_polygon_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MumbaiLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "mumbai_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_mumbai_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_mumbai_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class XDaiLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "xdai_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_xdai_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_xdai_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ZkSyncEraLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "zksync_era_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_zksync_era_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_zksync_era_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ZkSyncEraSepoliaLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "zksync_era_sepolia_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_zksync_era_sepolia_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_zksync_era_sepolia_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class BaseLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "base_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_base_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_base_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ArbitrumNovaLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "arbitrum_nova_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_arbitrum_nova_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_arbitrum_nova_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ArbitrumSepoliaLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "arbitrum_sepolia_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_arbitrum_sepolia_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_arbitrum_sepolia_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class XaiLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "xai_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_xai_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_xai_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class XaiSepoliaLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "xai_sepolia_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_xai_sepolia_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_xai_sepolia_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AvalancheLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "avalanche_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_avalanche_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_avalanche_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AvalancheFujiLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "avalanche_fuji_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_avalanche_fuji_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_avalanche_fuji_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class StarknetLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "starknet_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_starknet_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_starknet_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class StarknetSepoliaLabel(EvmBasedLabel): # type: ignore
|
||||||
|
__tablename__ = "starknet_sepolia_labels"
|
||||||
|
|
||||||
|
__table_args__ = (
|
||||||
|
Index(
|
||||||
|
"ix_starknet_sepolia_labels_addr_block_num",
|
||||||
|
"address",
|
||||||
|
"block_number",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
Index(
|
||||||
|
"ix_starknet_sepolia_labels_addr_block_ts",
|
||||||
|
"address",
|
||||||
|
"block_timestamp",
|
||||||
|
unique=False,
|
||||||
|
),
|
||||||
|
)
|
|
@ -0,0 +1,11 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
VERSION = "UNKNOWN"
|
||||||
|
|
||||||
|
try:
|
||||||
|
PATH = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
VERSION_FILE = os.path.join(PATH, "version.txt")
|
||||||
|
with open(VERSION_FILE) as ifp:
|
||||||
|
VERSION = ifp.read().strip()
|
||||||
|
except:
|
||||||
|
pass
|
|
@ -0,0 +1 @@
|
||||||
|
0.0.1
|
|
@ -0,0 +1,40 @@
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
|
from moonstreamdbv3.version import VERSION
|
||||||
|
|
||||||
|
long_description = ""
|
||||||
|
with open("README.md") as ifp:
|
||||||
|
long_description = ifp.read()
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="moonstreamdb-v3",
|
||||||
|
version=VERSION,
|
||||||
|
author="Bugout.dev",
|
||||||
|
author_email="engineers@bugout.dev",
|
||||||
|
license="Apache License 2.0",
|
||||||
|
description="Moonstream V3 database",
|
||||||
|
long_description=long_description,
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
|
url="https://github.com/bugout-dev/moonstream",
|
||||||
|
platforms="all",
|
||||||
|
classifiers=[
|
||||||
|
"Development Status :: 2 - Pre-Alpha",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Natural Language :: English",
|
||||||
|
"Programming Language :: Python",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: Implementation :: CPython",
|
||||||
|
"Topic :: Software Development :: Libraries",
|
||||||
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
|
],
|
||||||
|
python_requires=">=3.8",
|
||||||
|
packages=find_packages(),
|
||||||
|
package_data={"moonstreamdbv3": ["py.typed"]},
|
||||||
|
zip_safe=False,
|
||||||
|
install_requires=["alembic", "psycopg2-binary", "sqlalchemy>=2.0.4"],
|
||||||
|
extras_require={
|
||||||
|
"dev": ["black", "isort", "mypy"],
|
||||||
|
"distribute": ["setuptools", "twine", "wheel"],
|
||||||
|
},
|
||||||
|
)
|
Ładowanie…
Reference in New Issue