Add optional API upload alongside SMTP, Nextcloud/WebDAV as a document source with the same dedup/retry flow as IMAP, stricter invoice file checks for images, and admin UI for source and delivery modes.
65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
"""Add WebDAV/Nextcloud as document source
|
|
|
|
Revision ID: 004_webdav
|
|
Revises: 003_bizdocs_api
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "004_webdav"
|
|
down_revision: Union[str, None] = "003_bizdocs_api"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column(
|
|
"accounts",
|
|
sa.Column(
|
|
"source_type",
|
|
sa.Enum("imap", "webdav", name="sourcetype"),
|
|
nullable=False,
|
|
server_default="imap",
|
|
),
|
|
)
|
|
op.add_column("accounts", sa.Column("webdav_url", sa.String(length=512), nullable=True))
|
|
op.add_column("accounts", sa.Column("webdav_path", sa.String(length=512), nullable=True))
|
|
op.add_column("accounts", sa.Column("webdav_user", sa.String(length=255), nullable=True))
|
|
op.add_column("accounts", sa.Column("webdav_password_encrypted", sa.Text(), nullable=True))
|
|
op.add_column(
|
|
"accounts",
|
|
sa.Column(
|
|
"webdav_verify_ssl",
|
|
sa.Boolean(),
|
|
nullable=False,
|
|
server_default=sa.text("1"),
|
|
),
|
|
)
|
|
op.alter_column("accounts", "imap_host", existing_type=sa.String(length=255), nullable=True)
|
|
op.alter_column("accounts", "imap_user", existing_type=sa.String(length=255), nullable=True)
|
|
op.alter_column("accounts", "imap_password_encrypted", existing_type=sa.Text(), nullable=True)
|
|
op.execute(
|
|
"ALTER TABLE connection_tests MODIFY COLUMN test_type "
|
|
"ENUM('imap', 'smtp', 'send', 'webdav') NOT NULL"
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.execute(
|
|
"ALTER TABLE connection_tests MODIFY COLUMN test_type "
|
|
"ENUM('imap', 'smtp', 'send') NOT NULL"
|
|
)
|
|
op.alter_column("accounts", "imap_password_encrypted", existing_type=sa.Text(), nullable=False)
|
|
op.alter_column("accounts", "imap_user", existing_type=sa.String(length=255), nullable=False)
|
|
op.alter_column("accounts", "imap_host", existing_type=sa.String(length=255), nullable=False)
|
|
op.drop_column("accounts", "webdav_verify_ssl")
|
|
op.drop_column("accounts", "webdav_password_encrypted")
|
|
op.drop_column("accounts", "webdav_user")
|
|
op.drop_column("accounts", "webdav_path")
|
|
op.drop_column("accounts", "webdav_url")
|
|
op.drop_column("accounts", "source_type")
|
|
op.execute("DROP TYPE IF EXISTS sourcetype")
|