41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""IMAP ids as 64-bit integers
|
|||
|
|
|
||
|
|
UIDVALIDITY and UIDs are unsigned 32-bit numbers (RFC 9051), MODSEQ up to 63
|
||
|
|
bits (RFC 7162); Postgres ``integer`` is signed 32-bit. Servers that hand out
|
||
|
|
values above 2^31 — the hosted mail server's UIDVALIDITY, for one — could not
|
||
|
|
be stored ("value out of int32 range") and their folders never synced.
|
||
|
|
|
||
|
|
Revision ID: 0026
|
||
|
|
Revises: 0025
|
||
|
|
Create Date: 2026-10-11
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from collections.abc import Sequence
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
|
||
|
|
revision: str = "0026"
|
||
|
|
down_revision: str | None = "0025"
|
||
|
|
branch_labels: str | Sequence[str] | None = None
|
||
|
|
depends_on: str | Sequence[str] | None = None
|
||
|
|
|
||
|
|
_COLUMNS = (
|
||
|
|
("mailboxes", "uidvalidity"),
|
||
|
|
("mailboxes", "highestmodseq"),
|
||
|
|
("mailboxes", "last_seen_uid"),
|
||
|
|
("messages", "uid"),
|
||
|
|
("drafts", "imap_uid"),
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
for table, column in _COLUMNS:
|
||
|
|
op.execute(f"ALTER TABLE {table} ALTER COLUMN {column} TYPE bigint")
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
for table, column in _COLUMNS:
|
||
|
|
op.execute(f"ALTER TABLE {table} ALTER COLUMN {column} TYPE integer")
|