38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""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")
|
|
|