mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-16 13:01:04 +02:00
Change type of columns to binary from string (#1058)
This commit is contained in:
parent
c2e6342470
commit
11d1b4be25
11 changed files with 101 additions and 419 deletions
|
|
@ -1,39 +0,0 @@
|
|||
"""Remove peer uploading and downloading fields, add autoconnect field
|
||||
|
||||
Revision ID: 7868889c72e3
|
||||
Revises: 7f9632136152
|
||||
Create Date: 2021-08-20 14:20:38.979040
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7868889c72e3'
|
||||
down_revision = '7f9632136152'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('peer', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('autoconnect', sa.Boolean(), nullable=False))
|
||||
batch_op.drop_column('downloading')
|
||||
batch_op.drop_column('uploading')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('peer', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('uploading', sa.BOOLEAN(), nullable=False))
|
||||
batch_op.add_column(
|
||||
sa.Column('downloading', sa.BOOLEAN(), nullable=False))
|
||||
batch_op.drop_column('autoconnect')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
"""Rename client_host and client_port columns
|
||||
|
||||
Revision ID: 78b6e078848c
|
||||
Revises: 7868889c72e3
|
||||
Create Date: 2021-08-23 00:25:53.612711
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '78b6e078848c'
|
||||
down_revision = '7868889c72e3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('received_payment', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_host', sa.String(), nullable=False, server_default=sa.literal('')))
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_port', sa.Integer(), nullable=False, server_default=sa.text('0')))
|
||||
batch_op.drop_column('client_port')
|
||||
batch_op.drop_column('client_host')
|
||||
|
||||
with op.batch_alter_table('sent_offer', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_host', sa.String(), nullable=False, server_default=sa.literal('')))
|
||||
batch_op.add_column(
|
||||
sa.Column('peer_port', sa.Integer(), nullable=False, server_default=sa.text('0')))
|
||||
batch_op.drop_column('client_port')
|
||||
batch_op.drop_column('client_host')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sent_offer', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('client_host', sa.VARCHAR(), nullable=False))
|
||||
batch_op.add_column(
|
||||
sa.Column('client_port', sa.INTEGER(), nullable=False))
|
||||
batch_op.drop_column('peer_port')
|
||||
batch_op.drop_column('peer_host')
|
||||
|
||||
with op.batch_alter_table('received_payment', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('client_host', sa.VARCHAR(), nullable=False))
|
||||
batch_op.add_column(
|
||||
sa.Column('client_port', sa.INTEGER(), nullable=False))
|
||||
batch_op.drop_column('peer_port')
|
||||
batch_op.drop_column('peer_host')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
"""Remove sharing field
|
||||
|
||||
Revision ID: 7f9632136152
|
||||
Revises: c874732c09b6
|
||||
Create Date: 2021-08-20 13:58:52.993445
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7f9632136152'
|
||||
down_revision = 'c874732c09b6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('profile', schema=None) as batch_op:
|
||||
batch_op.drop_column('sharing')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('profile', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('sharing', sa.BOOLEAN(), nullable=False))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
"""Initialize all
|
||||
|
||||
Revision ID: 0676aadc35c6
|
||||
Revision ID: 814be7653a69
|
||||
Revises:
|
||||
Create Date: 2021-02-21 17:28:39.366082
|
||||
Create Date: 2021-08-24 18:30:29.854723
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
|
@ -12,7 +12,7 @@ import squeaknode.db.models
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0676aadc35c6'
|
||||
revision = '814be7653a69'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
|
@ -27,8 +27,7 @@ def upgrade():
|
|||
sa.Column('peer_name', sa.String(), nullable=False),
|
||||
sa.Column('host', sa.String(), nullable=False),
|
||||
sa.Column('port', sa.Integer(), nullable=False),
|
||||
sa.Column('uploading', sa.Boolean(), nullable=False),
|
||||
sa.Column('downloading', sa.Boolean(), nullable=False),
|
||||
sa.Column('autoconnect', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('peer_id'),
|
||||
sa.UniqueConstraint(
|
||||
'host', 'port', name='uq_peer_host_port'),
|
||||
|
|
@ -41,7 +40,6 @@ def upgrade():
|
|||
sa.Column('profile_name', sa.String(), nullable=False),
|
||||
sa.Column('private_key', sa.Binary(), nullable=True),
|
||||
sa.Column('address', sa.String(length=35), nullable=False),
|
||||
sa.Column('sharing', sa.Boolean(), nullable=False),
|
||||
sa.Column('following', sa.Boolean(), nullable=False),
|
||||
sa.Column('profile_image', sa.Binary(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('profile_id'),
|
||||
|
|
@ -54,13 +52,10 @@ def upgrade():
|
|||
'received_offer_id', squeaknode.db.models.SLBigInteger(), nullable=False),
|
||||
sa.Column('created', squeaknode.db.models.TZDateTime(
|
||||
), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||
sa.Column('squeak_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('payment_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('nonce', sa.String(length=64), nullable=False),
|
||||
sa.Column('payment_point', sa.String(
|
||||
length=66), nullable=False),
|
||||
sa.Column('squeak_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('payment_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('nonce', sa.Binary(), nullable=False),
|
||||
sa.Column('payment_point', sa.Binary(), nullable=False),
|
||||
sa.Column('invoice_timestamp',
|
||||
sa.Integer(), nullable=False),
|
||||
sa.Column('invoice_expiry', sa.Integer(), nullable=False),
|
||||
|
|
@ -82,15 +77,13 @@ def upgrade():
|
|||
squeaknode.db.models.SLBigInteger(), nullable=False),
|
||||
sa.Column('created', squeaknode.db.models.TZDateTime(
|
||||
), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||
sa.Column('squeak_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('payment_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('squeak_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('payment_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('price_msat', sa.Integer(), nullable=False),
|
||||
sa.Column('settle_index',
|
||||
squeaknode.db.models.SLBigInteger(), nullable=False),
|
||||
sa.Column('client_host', sa.String(), nullable=False),
|
||||
sa.Column('client_port', sa.Integer(), nullable=False),
|
||||
sa.Column('peer_host', sa.String(), nullable=False),
|
||||
sa.Column('peer_port', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('received_payment_id'),
|
||||
sa.UniqueConstraint('payment_hash'),
|
||||
sqlite_autoincrement=True
|
||||
|
|
@ -100,20 +93,17 @@ def upgrade():
|
|||
'sent_offer_id', squeaknode.db.models.SLBigInteger(), nullable=False),
|
||||
sa.Column('created', squeaknode.db.models.TZDateTime(
|
||||
), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||
sa.Column('squeak_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('payment_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('secret_key', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('nonce', sa.String(length=64), nullable=False),
|
||||
sa.Column('squeak_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('payment_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('secret_key', sa.Binary(), nullable=False),
|
||||
sa.Column('nonce', sa.Binary(), nullable=False),
|
||||
sa.Column('price_msat', sa.Integer(), nullable=False),
|
||||
sa.Column('payment_request', sa.String(), nullable=False),
|
||||
sa.Column('invoice_timestamp',
|
||||
sa.Integer(), nullable=False),
|
||||
sa.Column('invoice_expiry', sa.Integer(), nullable=False),
|
||||
sa.Column('client_host', sa.String(), nullable=False),
|
||||
sa.Column('client_port', sa.Integer(), nullable=False),
|
||||
sa.Column('peer_host', sa.String(), nullable=False),
|
||||
sa.Column('peer_port', sa.Integer(), nullable=False),
|
||||
sa.Column('paid', sa.Boolean(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('sent_offer_id'),
|
||||
sa.UniqueConstraint('payment_hash'),
|
||||
|
|
@ -126,12 +116,9 @@ def upgrade():
|
|||
), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||
sa.Column('peer_host', sa.String(), nullable=False),
|
||||
sa.Column('peer_port', sa.Integer(), nullable=False),
|
||||
sa.Column('squeak_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('payment_hash', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('secret_key', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('squeak_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('payment_hash', sa.Binary(), nullable=False),
|
||||
sa.Column('secret_key', sa.Binary(), nullable=False),
|
||||
sa.Column('price_msat', sa.Integer(), nullable=False),
|
||||
sa.Column('node_pubkey', sa.String(
|
||||
length=66), nullable=False),
|
||||
|
|
@ -141,21 +128,21 @@ def upgrade():
|
|||
sqlite_autoincrement=True
|
||||
)
|
||||
op.create_table('squeak',
|
||||
sa.Column('hash', sa.String(length=64), nullable=False),
|
||||
sa.Column('hash', sa.Binary(), nullable=False),
|
||||
sa.Column('created', squeaknode.db.models.TZDateTime(
|
||||
), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||
sa.Column('squeak', sa.Binary(), nullable=False),
|
||||
sa.Column('hash_reply_sqk', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('hash_block', sa.String(
|
||||
length=64), nullable=False),
|
||||
sa.Column('hash_reply_sqk', sa.Binary(), nullable=True),
|
||||
sa.Column('hash_block', sa.Binary(), nullable=False),
|
||||
sa.Column('n_block_height', sa.Integer(), nullable=False),
|
||||
sa.Column('n_time', sa.Integer(), nullable=False),
|
||||
sa.Column('author_address', sa.String(
|
||||
length=35), nullable=False),
|
||||
sa.Column('secret_key', sa.String(
|
||||
length=64), nullable=True),
|
||||
sa.Column('block_header', sa.Binary(), nullable=False),
|
||||
sa.Column('secret_key', sa.Binary(), nullable=True),
|
||||
sa.Column('block_time', sa.Integer(), nullable=False),
|
||||
sa.Column(
|
||||
'liked_time', squeaknode.db.models.TZDateTime(), nullable=True),
|
||||
sa.Column('content', sa.String(length=280), nullable=True),
|
||||
sa.PrimaryKeyConstraint('hash')
|
||||
)
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
"""Add block time column to squeak table
|
||||
|
||||
Revision ID: a35d180bf020
|
||||
Revises: c0316d4931a5
|
||||
Create Date: 2021-08-24 04:27:45.463418
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a35d180bf020'
|
||||
down_revision = 'c0316d4931a5'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('block_time', sa.Integer(), nullable=False, server_default=sa.text('0')))
|
||||
batch_op.drop_column('block_header')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('block_header', sa.BLOB(), nullable=False, server_default=sa.literal('')))
|
||||
batch_op.drop_column('block_time')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
"""Make reply to hash nullable
|
||||
|
||||
Revision ID: adec68bd0785
|
||||
Revises: a35d180bf020
|
||||
Create Date: 2021-08-24 17:10:21.009027
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'adec68bd0785'
|
||||
down_revision = 'a35d180bf020'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.alter_column('hash_reply_sqk',
|
||||
existing_type=sa.VARCHAR(length=64),
|
||||
nullable=True)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.alter_column('hash_reply_sqk',
|
||||
existing_type=sa.VARCHAR(length=64),
|
||||
nullable=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
"""Add content column to squeak table
|
||||
|
||||
Revision ID: c0316d4931a5
|
||||
Revises: 78b6e078848c
|
||||
Create Date: 2021-08-24 02:06:47.850900
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c0316d4931a5'
|
||||
down_revision = '78b6e078848c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('content', sa.String(length=280), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.drop_column('content')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
"""Use timestamp for liked field
|
||||
|
||||
Revision ID: c874732c09b6
|
||||
Revises: f62215acb987
|
||||
Create Date: 2021-06-04 17:03:56.626831
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
import squeaknode.db.models
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c874732c09b6'
|
||||
down_revision = 'f62215acb987'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column('liked_time', squeaknode.db.models.TZDateTime(), nullable=True))
|
||||
batch_op.drop_column('liked')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('liked', sa.BOOLEAN(),
|
||||
server_default=sa.text('0'), nullable=False))
|
||||
batch_op.drop_column('liked_time')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
"""Add liked column
|
||||
|
||||
Revision ID: f62215acb987
|
||||
Revises: 0676aadc35c6
|
||||
Create Date: 2021-02-22 15:18:19.238913
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f62215acb987'
|
||||
down_revision = '0676aadc35c6'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('liked', sa.Boolean(),
|
||||
nullable=False, server_default=sa.false()))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('squeak', schema=None) as batch_op:
|
||||
batch_op.drop_column('liked')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -59,16 +59,16 @@ class Models:
|
|||
self.squeaks = Table(
|
||||
"squeak",
|
||||
self.metadata,
|
||||
Column("hash", String(64), primary_key=True),
|
||||
Column("hash", Binary(32), primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("squeak", Binary, nullable=False),
|
||||
Column("hash_reply_sqk", String(64), nullable=True),
|
||||
Column("hash_block", String(64), nullable=False),
|
||||
Column("hash_reply_sqk", Binary(32), nullable=True),
|
||||
Column("hash_block", Binary(32), nullable=False),
|
||||
Column("n_block_height", Integer, nullable=False),
|
||||
Column("n_time", Integer, nullable=False),
|
||||
Column("author_address", String(35), index=True, nullable=False),
|
||||
Column("secret_key", String(64), nullable=True),
|
||||
Column("secret_key", Binary(32), nullable=True),
|
||||
Column("block_time", Integer, nullable=False),
|
||||
Column("liked_time", TZDateTime,
|
||||
default=None, nullable=True),
|
||||
|
|
@ -110,10 +110,10 @@ class Models:
|
|||
Column("received_offer_id", SLBigInteger, primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("squeak_hash", String(64), nullable=False),
|
||||
Column("payment_hash", String(64), unique=True, nullable=False),
|
||||
Column("nonce", String(64), nullable=False),
|
||||
Column("payment_point", String(66), nullable=False),
|
||||
Column("squeak_hash", Binary(32), nullable=False),
|
||||
Column("payment_hash", Binary(32), unique=True, nullable=False),
|
||||
Column("nonce", Binary(32), nullable=False),
|
||||
Column("payment_point", Binary(33), nullable=False),
|
||||
Column("invoice_timestamp", Integer, nullable=False),
|
||||
Column("invoice_expiry", Integer, nullable=False),
|
||||
Column("price_msat", Integer, nullable=False),
|
||||
|
|
@ -135,9 +135,9 @@ class Models:
|
|||
server_default=func.now(), nullable=False),
|
||||
Column("peer_host", String, nullable=False),
|
||||
Column("peer_port", Integer, nullable=False),
|
||||
Column("squeak_hash", String(64), nullable=False),
|
||||
Column("payment_hash", String(64), unique=True, nullable=False),
|
||||
Column("secret_key", String(64), nullable=False),
|
||||
Column("squeak_hash", Binary(32), nullable=False),
|
||||
Column("payment_hash", Binary(32), unique=True, nullable=False),
|
||||
Column("secret_key", Binary(32), nullable=False),
|
||||
Column("price_msat", Integer, nullable=False, default=0),
|
||||
Column("node_pubkey", String(66), nullable=False),
|
||||
Column("valid", Boolean, nullable=False),
|
||||
|
|
@ -150,10 +150,10 @@ class Models:
|
|||
Column("sent_offer_id", SLBigInteger, primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("squeak_hash", String(64), nullable=False),
|
||||
Column("payment_hash", String(64), unique=True, nullable=False),
|
||||
Column("secret_key", String(64), nullable=False),
|
||||
Column("nonce", String(64), nullable=False),
|
||||
Column("squeak_hash", Binary(32), nullable=False),
|
||||
Column("payment_hash", Binary(32), unique=True, nullable=False),
|
||||
Column("secret_key", Binary(32), nullable=False),
|
||||
Column("nonce", Binary(32), nullable=False),
|
||||
Column("price_msat", Integer, nullable=False, default=0),
|
||||
Column("payment_request", String, nullable=False),
|
||||
Column("invoice_timestamp", Integer, nullable=False),
|
||||
|
|
@ -170,8 +170,8 @@ class Models:
|
|||
Column("received_payment_id", SLBigInteger, primary_key=True),
|
||||
Column("created", TZDateTime,
|
||||
server_default=func.now(), nullable=False),
|
||||
Column("squeak_hash", String(64), nullable=False),
|
||||
Column("payment_hash", String(64), unique=True, nullable=False),
|
||||
Column("squeak_hash", Binary(32), nullable=False),
|
||||
Column("payment_hash", Binary(32), unique=True, nullable=False),
|
||||
Column("price_msat", Integer, nullable=False),
|
||||
Column("settle_index", SLBigInteger, nullable=False),
|
||||
Column("peer_host", String, nullable=False),
|
||||
|
|
|
|||
|
|
@ -165,10 +165,10 @@ class SqueakDb:
|
|||
Return the hash (bytes) of the inserted squeak.
|
||||
"""
|
||||
ins = self.squeaks.insert().values(
|
||||
hash=get_hash(squeak).hex(),
|
||||
hash=get_hash(squeak),
|
||||
squeak=squeak.serialize(),
|
||||
hash_reply_sqk=squeak.hashReplySqk.hex() if squeak.is_reply else None,
|
||||
hash_block=squeak.hashBlock.hex(),
|
||||
hash_reply_sqk=squeak.hashReplySqk if squeak.is_reply else None,
|
||||
hash_block=squeak.hashBlock,
|
||||
n_block_height=squeak.nBlockHeight,
|
||||
n_time=squeak.nTime,
|
||||
author_address=str(squeak.GetAddress()),
|
||||
|
|
@ -186,7 +186,7 @@ class SqueakDb:
|
|||
def get_squeak(self, squeak_hash: bytes) -> Optional[CSqueak]:
|
||||
""" Get a squeak. """
|
||||
s = select([self.squeaks]).where(
|
||||
self.squeaks.c.hash == squeak_hash.hex())
|
||||
self.squeaks.c.hash == squeak_hash)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
row = result.fetchone()
|
||||
|
|
@ -197,7 +197,7 @@ class SqueakDb:
|
|||
def get_squeak_entry(self, squeak_hash: bytes) -> Optional[SqueakEntry]:
|
||||
""" Get a squeak. """
|
||||
s = select([self.squeaks]).where(
|
||||
self.squeaks.c.hash == squeak_hash.hex())
|
||||
self.squeaks.c.hash == squeak_hash)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
row = result.fetchone()
|
||||
|
|
@ -215,7 +215,7 @@ class SqueakDb:
|
|||
self.profiles.c.address == self.squeaks.c.author_address,
|
||||
)
|
||||
)
|
||||
.where(self.squeaks.c.hash == squeak_hash.hex())
|
||||
.where(self.squeaks.c.hash == squeak_hash)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
|
|
@ -300,7 +300,7 @@ class SqueakDb:
|
|||
literal(0).label("depth"),
|
||||
]
|
||||
)
|
||||
.where(self.squeaks.c.hash == squeak_hash.hex())
|
||||
.where(self.squeaks.c.hash == squeak_hash)
|
||||
.cte(recursive=True)
|
||||
)
|
||||
|
||||
|
|
@ -367,7 +367,7 @@ class SqueakDb:
|
|||
self.profiles.c.address == self.squeaks.c.author_address,
|
||||
)
|
||||
)
|
||||
.where(self.squeaks.c.hash_reply_sqk == squeak_hash.hex())
|
||||
.where(self.squeaks.c.hash_reply_sqk == squeak_hash)
|
||||
.order_by(
|
||||
self.squeaks.c.n_block_height.desc(),
|
||||
self.squeaks.c.n_time.desc(),
|
||||
|
|
@ -408,7 +408,7 @@ class SqueakDb:
|
|||
if max_block:
|
||||
s = s.where(self.squeaks.c.n_block_height <= max_block)
|
||||
if reply_to_hash:
|
||||
s = s.where(self.squeaks.c.hash_reply_sqk == reply_to_hash.hex())
|
||||
s = s.where(self.squeaks.c.hash_reply_sqk == reply_to_hash)
|
||||
if not include_locked:
|
||||
s = s.where(self.squeak_has_secret_key)
|
||||
|
||||
|
|
@ -420,7 +420,7 @@ class SqueakDb:
|
|||
# ))
|
||||
result = connection.execute(s)
|
||||
rows = result.fetchall()
|
||||
hashes = [bytes.fromhex(row["hash"]) for row in rows]
|
||||
hashes = [(row["hash"]) for row in rows]
|
||||
return hashes
|
||||
|
||||
def get_number_of_squeaks(self) -> int:
|
||||
|
|
@ -489,7 +489,7 @@ class SqueakDb:
|
|||
# with self.get_connection() as connection:
|
||||
# result = connection.execute(s)
|
||||
# rows = result.fetchall()
|
||||
# hashes = [bytes.fromhex(row["hash"]) for row in rows]
|
||||
# hashes = [(row["hash"]) for row in rows]
|
||||
# return hashes
|
||||
|
||||
def get_old_squeaks_to_delete(
|
||||
|
|
@ -642,9 +642,9 @@ class SqueakDb:
|
|||
""" Set the decryption key and decrypted content of a squeak. """
|
||||
stmt = (
|
||||
self.squeaks.update()
|
||||
.where(self.squeaks.c.hash == squeak_hash.hex())
|
||||
.where(self.squeaks.c.hash == squeak_hash)
|
||||
.values(
|
||||
secret_key=secret_key.hex(),
|
||||
secret_key=secret_key,
|
||||
content=content,
|
||||
)
|
||||
)
|
||||
|
|
@ -655,7 +655,7 @@ class SqueakDb:
|
|||
""" Set the squeak to be liked. """
|
||||
stmt = (
|
||||
self.squeaks.update()
|
||||
.where(self.squeaks.c.hash == squeak_hash.hex())
|
||||
.where(self.squeaks.c.hash == squeak_hash)
|
||||
.values(liked_time=self.datetime_now)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -665,7 +665,7 @@ class SqueakDb:
|
|||
""" Set the squeak to be unliked. """
|
||||
stmt = (
|
||||
self.squeaks.update()
|
||||
.where(self.squeaks.c.hash == squeak_hash.hex())
|
||||
.where(self.squeaks.c.hash == squeak_hash)
|
||||
.values(liked_time=None)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -674,7 +674,7 @@ class SqueakDb:
|
|||
def delete_squeak(self, squeak_hash: bytes) -> None:
|
||||
""" Delete a squeak. """
|
||||
delete_squeak_stmt = self.squeaks.delete().where(
|
||||
self.squeaks.c.hash == squeak_hash.hex()
|
||||
self.squeaks.c.hash == squeak_hash
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(delete_squeak_stmt)
|
||||
|
|
@ -749,10 +749,10 @@ class SqueakDb:
|
|||
def insert_received_offer(self, received_offer: ReceivedOffer):
|
||||
""" Insert a new received offer. """
|
||||
ins = self.received_offers.insert().values(
|
||||
squeak_hash=received_offer.squeak_hash.hex(),
|
||||
payment_hash=received_offer.payment_hash.hex(),
|
||||
nonce=received_offer.nonce.hex(),
|
||||
payment_point=received_offer.payment_point.hex(),
|
||||
squeak_hash=received_offer.squeak_hash,
|
||||
payment_hash=received_offer.payment_hash,
|
||||
nonce=received_offer.nonce,
|
||||
payment_point=received_offer.payment_point,
|
||||
invoice_timestamp=received_offer.invoice_timestamp,
|
||||
invoice_expiry=received_offer.invoice_expiry,
|
||||
price_msat=received_offer.price_msat,
|
||||
|
|
@ -772,7 +772,7 @@ class SqueakDb:
|
|||
""" Get offers with peer for a squeak hash. """
|
||||
s = (
|
||||
select([self.received_offers])
|
||||
.where(self.received_offers.c.squeak_hash == squeak_hash.hex())
|
||||
.where(self.received_offers.c.squeak_hash == squeak_hash)
|
||||
.where(self.received_offer_is_not_paid)
|
||||
.where(self.received_offer_is_not_expired)
|
||||
)
|
||||
|
|
@ -807,7 +807,7 @@ class SqueakDb:
|
|||
""" Get offer with peer for a given peer address and squeak hash . """
|
||||
s = (
|
||||
select([self.received_offers])
|
||||
.where(self.received_offers.c.squeak_hash == squeak_hash.hex())
|
||||
.where(self.received_offers.c.squeak_hash == squeak_hash)
|
||||
.where(self.received_offers.c.peer_host == peer_address.host)
|
||||
.where(self.received_offers.c.peer_port == peer_address.port)
|
||||
.where(self.received_offer_is_not_paid)
|
||||
|
|
@ -834,7 +834,7 @@ class SqueakDb:
|
|||
def delete_offers_for_squeak(self, squeak_hash: bytes):
|
||||
""" Delete all offers for a squeak hash. """
|
||||
s = self.received_offers.delete().where(
|
||||
self.received_offers.c.squeak_hash == squeak_hash.hex())
|
||||
self.received_offers.c.squeak_hash == squeak_hash)
|
||||
with self.get_connection() as connection:
|
||||
res = connection.execute(s)
|
||||
deleted_offers = res.rowcount
|
||||
|
|
@ -843,7 +843,7 @@ class SqueakDb:
|
|||
def delete_offer(self, payment_hash: bytes):
|
||||
""" Delete a received offer by payment hash. """
|
||||
s = self.received_offers.delete().where(
|
||||
self.received_offers.c.payment_hash == payment_hash.hex()
|
||||
self.received_offers.c.payment_hash == payment_hash
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(s)
|
||||
|
|
@ -852,7 +852,7 @@ class SqueakDb:
|
|||
""" Set a received offer is paid. """
|
||||
stmt = (
|
||||
self.received_offers.update()
|
||||
.where(self.received_offers.c.payment_hash == payment_hash.hex())
|
||||
.where(self.received_offers.c.payment_hash == payment_hash)
|
||||
.values(paid=paid)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -863,9 +863,9 @@ class SqueakDb:
|
|||
ins = self.sent_payments.insert().values(
|
||||
peer_host=sent_payment.peer_address.host,
|
||||
peer_port=sent_payment.peer_address.port,
|
||||
squeak_hash=sent_payment.squeak_hash.hex(),
|
||||
payment_hash=sent_payment.payment_hash.hex(),
|
||||
secret_key=sent_payment.secret_key.hex(),
|
||||
squeak_hash=sent_payment.squeak_hash,
|
||||
payment_hash=sent_payment.payment_hash,
|
||||
secret_key=sent_payment.secret_key,
|
||||
price_msat=sent_payment.price_msat,
|
||||
node_pubkey=sent_payment.node_pubkey,
|
||||
valid=sent_payment.valid,
|
||||
|
|
@ -906,10 +906,10 @@ class SqueakDb:
|
|||
def insert_sent_offer(self, sent_offer: SentOffer):
|
||||
""" Insert a new sent offer. """
|
||||
ins = self.sent_offers.insert().values(
|
||||
squeak_hash=sent_offer.squeak_hash.hex(),
|
||||
payment_hash=sent_offer.payment_hash.hex(),
|
||||
secret_key=sent_offer.secret_key.hex(),
|
||||
nonce=sent_offer.nonce.hex(),
|
||||
squeak_hash=sent_offer.squeak_hash,
|
||||
payment_hash=sent_offer.payment_hash,
|
||||
secret_key=sent_offer.secret_key,
|
||||
nonce=sent_offer.nonce,
|
||||
price_msat=sent_offer.price_msat,
|
||||
payment_request=sent_offer.payment_request,
|
||||
invoice_timestamp=sent_offer.invoice_time,
|
||||
|
|
@ -936,7 +936,7 @@ class SqueakDb:
|
|||
def get_sent_offer_by_payment_hash(self, payment_hash: bytes) -> Optional[SentOffer]:
|
||||
""" Get a sent offer by preimage hash. """
|
||||
s = select([self.sent_offers]).where(
|
||||
self.sent_offers.c.payment_hash == payment_hash.hex()
|
||||
self.sent_offers.c.payment_hash == payment_hash
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
result = connection.execute(s)
|
||||
|
|
@ -953,7 +953,7 @@ class SqueakDb:
|
|||
"""
|
||||
s = (
|
||||
select([self.sent_offers])
|
||||
.where(self.sent_offers.c.squeak_hash == squeak_hash.hex())
|
||||
.where(self.sent_offers.c.squeak_hash == squeak_hash)
|
||||
.where(self.sent_offers.c.peer_host == peer_address.host)
|
||||
.where(self.sent_offer_is_not_paid)
|
||||
.where(self.sent_offer_is_not_expired)
|
||||
|
|
@ -969,7 +969,7 @@ class SqueakDb:
|
|||
def delete_sent_offer(self, payment_hash: bytes):
|
||||
""" Delete a sent offer by payment hash. """
|
||||
s = self.sent_offers.delete().where(
|
||||
self.sent_offers.c.payment_hash == payment_hash.hex()
|
||||
self.sent_offers.c.payment_hash == payment_hash
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
connection.execute(s)
|
||||
|
|
@ -991,7 +991,7 @@ class SqueakDb:
|
|||
""" Set a sent offer is paid. """
|
||||
stmt = (
|
||||
self.sent_offers.update()
|
||||
.where(self.sent_offers.c.payment_hash == payment_hash.hex())
|
||||
.where(self.sent_offers.c.payment_hash == payment_hash)
|
||||
.values(paid=paid)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -1011,8 +1011,8 @@ class SqueakDb:
|
|||
def insert_received_payment(self, received_payment: ReceivedPayment):
|
||||
""" Insert a new received payment. """
|
||||
ins = self.received_payments.insert().values(
|
||||
squeak_hash=received_payment.squeak_hash.hex(),
|
||||
payment_hash=received_payment.payment_hash.hex(),
|
||||
squeak_hash=received_payment.squeak_hash,
|
||||
payment_hash=received_payment.payment_hash,
|
||||
price_msat=received_payment.price_msat,
|
||||
settle_index=received_payment.settle_index,
|
||||
peer_host=received_payment.peer_address.host,
|
||||
|
|
@ -1092,7 +1092,7 @@ class SqueakDb:
|
|||
def _parse_squeak(self, row) -> CSqueak:
|
||||
secret_key_column = row["secret_key"]
|
||||
secret_key = (
|
||||
bytes.fromhex(secret_key_column) if
|
||||
(secret_key_column) if
|
||||
secret_key_column else b""
|
||||
)
|
||||
squeak = CSqueak.deserialize(row["squeak"])
|
||||
|
|
@ -1103,15 +1103,15 @@ class SqueakDb:
|
|||
def _parse_squeak_entry(self, row) -> SqueakEntry:
|
||||
secret_key_column = row["secret_key"]
|
||||
is_locked = bool(secret_key_column)
|
||||
reply_to = bytes.fromhex(
|
||||
reply_to = (
|
||||
row["hash_reply_sqk"]) if row["hash_reply_sqk"] else None
|
||||
liked_time = row["liked_time"]
|
||||
liked_time_s = int(liked_time.timestamp()) if liked_time else None
|
||||
return SqueakEntry(
|
||||
squeak_hash=bytes.fromhex(row["hash"]),
|
||||
squeak_hash=(row["hash"]),
|
||||
address=row["author_address"],
|
||||
block_height=row["n_block_height"],
|
||||
block_hash=bytes.fromhex(row["hash_block"]),
|
||||
block_hash=(row["hash_block"]),
|
||||
block_time=row["block_time"],
|
||||
reply_to=reply_to,
|
||||
is_unlocked=is_locked,
|
||||
|
|
@ -1156,10 +1156,10 @@ class SqueakDb:
|
|||
def _parse_received_offer(self, row) -> ReceivedOffer:
|
||||
return ReceivedOffer(
|
||||
received_offer_id=row["received_offer_id"],
|
||||
squeak_hash=bytes.fromhex(row["squeak_hash"]),
|
||||
payment_hash=bytes.fromhex(row["payment_hash"]),
|
||||
nonce=bytes.fromhex(row["nonce"]),
|
||||
payment_point=bytes.fromhex(row["payment_point"]),
|
||||
squeak_hash=(row["squeak_hash"]),
|
||||
payment_hash=(row["payment_hash"]),
|
||||
nonce=(row["nonce"]),
|
||||
payment_point=(row["payment_point"]),
|
||||
invoice_timestamp=row["invoice_timestamp"],
|
||||
invoice_expiry=row["invoice_expiry"],
|
||||
price_msat=row["price_msat"],
|
||||
|
|
@ -1194,9 +1194,9 @@ class SqueakDb:
|
|||
host=row["peer_host"],
|
||||
port=row["peer_port"],
|
||||
),
|
||||
squeak_hash=bytes.fromhex(row["squeak_hash"]),
|
||||
payment_hash=bytes.fromhex(row["payment_hash"]),
|
||||
secret_key=bytes.fromhex(row["secret_key"]),
|
||||
squeak_hash=(row["squeak_hash"]),
|
||||
payment_hash=(row["payment_hash"]),
|
||||
secret_key=(row["secret_key"]),
|
||||
price_msat=row["price_msat"],
|
||||
node_pubkey=row["node_pubkey"],
|
||||
valid=row["valid"],
|
||||
|
|
@ -1216,10 +1216,10 @@ class SqueakDb:
|
|||
def _parse_sent_offer(self, row) -> SentOffer:
|
||||
return SentOffer(
|
||||
sent_offer_id=row["sent_offer_id"],
|
||||
squeak_hash=bytes.fromhex(row["squeak_hash"]),
|
||||
payment_hash=bytes.fromhex(row["payment_hash"]),
|
||||
secret_key=bytes.fromhex(row["secret_key"]),
|
||||
nonce=bytes.fromhex(row["nonce"]),
|
||||
squeak_hash=(row["squeak_hash"]),
|
||||
payment_hash=(row["payment_hash"]),
|
||||
secret_key=(row["secret_key"]),
|
||||
nonce=(row["nonce"]),
|
||||
price_msat=row["price_msat"],
|
||||
payment_request=row["payment_request"],
|
||||
invoice_time=row["invoice_timestamp"],
|
||||
|
|
@ -1234,8 +1234,8 @@ class SqueakDb:
|
|||
return ReceivedPayment(
|
||||
received_payment_id=row["received_payment_id"],
|
||||
created=row["created"],
|
||||
squeak_hash=bytes.fromhex(row["squeak_hash"]),
|
||||
payment_hash=bytes.fromhex(row["payment_hash"]),
|
||||
squeak_hash=(row["squeak_hash"]),
|
||||
payment_hash=(row["payment_hash"]),
|
||||
price_msat=row["price_msat"],
|
||||
settle_index=row["settle_index"],
|
||||
peer_address=PeerAddress(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue