Skip to content

Commit

Permalink
enlarge message_id length (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
MeetWq authored Oct 11, 2024
1 parent a3428fb commit 5cc33d5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
stages: [Nonepre-commitNone]
stages: [commit]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [javascript, jsx, ts, tsx, markdown, yaml, json]
stages: [Nonepre-commitNone]
stages: [commit]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""message_id_length
迁移 ID: 0f0a7bc40f3c
父迁移: 46327b837dd8
创建时间: 2024-10-11 23:36:23.677012
"""

from __future__ import annotations

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "0f0a7bc40f3c"
down_revision: str | Sequence[str] | None = "46327b837dd8"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade(name: str = "") -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table(
"nonebot_plugin_chatrecorder_messagerecord", schema=None
) as batch_op:
batch_op.alter_column(
"message_id",
existing_type=sa.String(length=64),
type_=sa.String(length=255),
existing_nullable=False,
)

# ### end Alembic commands ###


def downgrade(name: str = "") -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table(
"nonebot_plugin_chatrecorder_messagerecord", schema=None
) as batch_op:
batch_op.alter_column(
"message_id",
existing_type=sa.String(length=255),
type_=sa.String(length=64),
existing_nullable=False,
)

# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion nonebot_plugin_chatrecorder/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MessageRecord(Model):
""" 消息时间\n\n存放 UTC 时间 """
type: Mapped[str] = mapped_column(String(32))
""" 消息类型\n\n此处主要包含 `message` 和 `message_sent` 两种\n\n`message_sent` 是 bot 发出的消息"""
message_id: Mapped[str] = mapped_column(String(64))
message_id: Mapped[str] = mapped_column(String(255))
""" 消息id """
message: Mapped[JsonMsg] = mapped_column(JSON)
""" 消息内容
Expand Down

0 comments on commit 5cc33d5

Please sign in to comment.