reactions + the great merge
This commit is contained in:
parent
6871aa2449
commit
01dafa0d88
6 changed files with 144 additions and 4 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
config.py
|
config.py
|
||||||
keys/*
|
keys/*
|
||||||
**.pyc
|
**.pyc
|
||||||
|
venv/*
|
||||||
|
.idea/*
|
||||||
|
|
@ -5,7 +5,7 @@ prepend_sys_path = .
|
||||||
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
|
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
|
||||||
|
|
||||||
# Overwritten by env.py
|
# Overwritten by env.py
|
||||||
sqlalchemy.url = mysql+mysqldb://ergo:password@localhost/ergo_ext
|
sqlalchemy.url = mysql+mysqldb://ergo:password@localhost/ergo
|
||||||
|
|
||||||
|
|
||||||
[post_write_hooks]
|
[post_write_hooks]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
from cef_3M.sql_generated import *
|
||||||
|
|
||||||
from sqlalchemy import engine_from_config
|
from sqlalchemy import engine_from_config
|
||||||
from sqlalchemy import pool
|
from sqlalchemy import pool
|
||||||
|
|
@ -21,7 +22,7 @@ config.set_main_option("sqlalchemy.url", os.getenv("THREEM_DBURL"))
|
||||||
# for 'autogenerate' support
|
# for 'autogenerate' support
|
||||||
# from myapp import mymodel
|
# from myapp import mymodel
|
||||||
# target_metadata = mymodel.Base.metadata
|
# target_metadata = mymodel.Base.metadata
|
||||||
target_metadata = None
|
target_metadata = Base.metadata
|
||||||
|
|
||||||
# other values from the config, defined by the needs of env.py,
|
# other values from the config, defined by the needs of env.py,
|
||||||
# can be acquired:
|
# can be acquired:
|
||||||
|
|
|
||||||
61
alembic/versions/0b60fdc8c114_the_great_merge.py
Normal file
61
alembic/versions/0b60fdc8c114_the_great_merge.py
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
"""merge ergo and 3m
|
||||||
|
|
||||||
|
Revision ID: 0b60fdc8c114
|
||||||
|
Revises: aa17ed273170
|
||||||
|
Create Date: 2024-12-28 00:52:00.841444
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '0b60fdc8c114'
|
||||||
|
down_revision: Union[str, None] = 'aa17ed273170'
|
||||||
|
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('account_messages',
|
||||||
|
sa.Column('history_id', mysql.BIGINT(display_width=20, unsigned=True), nullable=False),
|
||||||
|
sa.Column('account', sa.VARBINARY(length=64), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('history_id')
|
||||||
|
)
|
||||||
|
op.create_index('account', 'account_messages', ['account', 'history_id'], unique=False)
|
||||||
|
op.create_table('forget',
|
||||||
|
sa.Column('id', mysql.BIGINT(display_width=20, unsigned=True), nullable=False),
|
||||||
|
sa.Column('account', sa.VARBINARY(length=64), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
op.create_table('history',
|
||||||
|
sa.Column('msgid', mysql.BIGINT(display_width=20, unsigned=True), nullable=False),
|
||||||
|
sa.Column('data', sa.LargeBinary(), nullable=False),
|
||||||
|
sa.Column('target', sa.VARBINARY(length=64), nullable=False),
|
||||||
|
sa.Column('sender', sa.VARBINARY(length=64), nullable=False),
|
||||||
|
sa.Column('nanotime', mysql.BIGINT(display_width=20), nullable=False),
|
||||||
|
sa.Column('pm', mysql.TINYINT(display_width=1),
|
||||||
|
sa.Computed("(substr(`target`,1,1) <> '#')", persisted=True), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint('msgid')
|
||||||
|
)
|
||||||
|
op.create_index('msgid', 'history', ['msgid'], unique=False)
|
||||||
|
op.create_table('metadata',
|
||||||
|
sa.Column('key_name', sa.String(length=32), nullable=False),
|
||||||
|
sa.Column('value', sa.String(length=32), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('key_name')
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('metadata')
|
||||||
|
op.drop_index('msgid', table_name='history')
|
||||||
|
op.drop_table('history')
|
||||||
|
op.drop_table('forget')
|
||||||
|
op.drop_index('account', table_name='account_messages')
|
||||||
|
op.drop_table('account_messages')
|
||||||
|
# ### end Alembic commands ###
|
||||||
38
alembic/versions/b8d3c85646c3_reactions.py
Normal file
38
alembic/versions/b8d3c85646c3_reactions.py
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
"""reactions
|
||||||
|
|
||||||
|
Revision ID: b8d3c85646c3
|
||||||
|
Revises: 0b60fdc8c114
|
||||||
|
Create Date: 2024-12-28 01:14:07.729096
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = 'b8d3c85646c3'
|
||||||
|
down_revision: Union[str, None] = '0b60fdc8c114'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
op.create_table(
|
||||||
|
"reactions",
|
||||||
|
sa.Column("msgid", mysql.BIGINT(display_width=20, unsigned=True), sa.ForeignKey("history.msgid", ondelete="CASCADE")),
|
||||||
|
sa.Column("user", sa.VARCHAR(64), sa.ForeignKey("users.username", ondelete="CASCADE"), index=True),
|
||||||
|
sa.Column("react", sa.VARCHAR(128)),
|
||||||
|
)
|
||||||
|
|
||||||
|
op.create_unique_constraint("idx_unique_reactions",
|
||||||
|
"reactions",
|
||||||
|
["msgid", "user", "react"])
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
op.drop_constraint("idx_unique_reactions", "reactions", "unique")
|
||||||
|
op.drop_table("reactions")
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from sqlalchemy import CHAR, ForeignKeyConstraint, Index, String, TIMESTAMP, text
|
from sqlalchemy import CHAR, Computed, ForeignKeyConstraint, Index, LargeBinary, String, TIMESTAMP, VARBINARY, text
|
||||||
from sqlalchemy.dialects.mysql import INTEGER, TINYINT
|
from sqlalchemy.dialects.mysql import BIGINT, INTEGER, TINYINT
|
||||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
@ -9,6 +9,16 @@ class Base(DeclarativeBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AccountMessages(Base):
|
||||||
|
__tablename__ = 'account_messages'
|
||||||
|
__table_args__ = (
|
||||||
|
Index('account', 'account', 'history_id'),
|
||||||
|
)
|
||||||
|
|
||||||
|
history_id: Mapped[int] = mapped_column(BIGINT(20), primary_key=True)
|
||||||
|
account: Mapped[bytes] = mapped_column(VARBINARY(64))
|
||||||
|
|
||||||
|
|
||||||
class AlertEndpoints(Base):
|
class AlertEndpoints(Base):
|
||||||
__tablename__ = 'alert_endpoints'
|
__tablename__ = 'alert_endpoints'
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
|
|
@ -24,6 +34,34 @@ class AlertEndpoints(Base):
|
||||||
created_at: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP, server_default=text('current_timestamp()'))
|
created_at: Mapped[Optional[datetime.datetime]] = mapped_column(TIMESTAMP, server_default=text('current_timestamp()'))
|
||||||
|
|
||||||
|
|
||||||
|
class Forget(Base):
|
||||||
|
__tablename__ = 'forget'
|
||||||
|
|
||||||
|
id: Mapped[int] = mapped_column(BIGINT(20), primary_key=True)
|
||||||
|
account: Mapped[bytes] = mapped_column(VARBINARY(64))
|
||||||
|
|
||||||
|
|
||||||
|
class History(Base):
|
||||||
|
__tablename__ = 'history'
|
||||||
|
__table_args__ = (
|
||||||
|
Index('msgid', 'msgid'),
|
||||||
|
)
|
||||||
|
|
||||||
|
msgid: Mapped[int] = mapped_column(BIGINT(20), primary_key=True)
|
||||||
|
data: Mapped[bytes] = mapped_column(LargeBinary)
|
||||||
|
target: Mapped[bytes] = mapped_column(VARBINARY(64))
|
||||||
|
sender: Mapped[bytes] = mapped_column(VARBINARY(64))
|
||||||
|
nanotime: Mapped[int] = mapped_column(BIGINT(20))
|
||||||
|
pm: Mapped[Optional[int]] = mapped_column(TINYINT(1), Computed("(substr(`target`,1,1) <> '#')", persisted=True))
|
||||||
|
|
||||||
|
|
||||||
|
class Metadata(Base):
|
||||||
|
__tablename__ = 'metadata'
|
||||||
|
|
||||||
|
key_name: Mapped[str] = mapped_column(String(32), primary_key=True)
|
||||||
|
value: Mapped[str] = mapped_column(String(32))
|
||||||
|
|
||||||
|
|
||||||
class Uploads(Base):
|
class Uploads(Base):
|
||||||
__tablename__ = 'uploads'
|
__tablename__ = 'uploads'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue