reactions + the great merge
This commit is contained in:
parent
6871aa2449
commit
01dafa0d88
6 changed files with 144 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from logging.config import fileConfig
|
||||
from cef_3M.sql_generated import *
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
|
@ -21,7 +22,7 @@ config.set_main_option("sqlalchemy.url", os.getenv("THREEM_DBURL"))
|
|||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
target_metadata = None
|
||||
target_metadata = Base.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# 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")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue