Enthält ~18 Commits vom Nextcloud-Mount (FUSE-Blocker verhinderte direkten Push): Excel-Export-Fix, IMAP-Verbesserungen, Scan-Fixes, UI-Updates. Aus Forgejo-Migration squashed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
104 lines
4.6 KiB
Python
104 lines
4.6 KiB
Python
"""initial schema
|
|
|
|
Revision ID: 5316895daf52
|
|
Revises:
|
|
Create Date: 2026-07-25 14:05:50.285281
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '5316895daf52'
|
|
down_revision: Union[str, None] = None
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# users table
|
|
op.create_table('users',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('username', sa.String(), nullable=False),
|
|
sa.Column('hashed_password', sa.String(), nullable=False),
|
|
sa.Column('is_active', sa.Boolean(), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('username')
|
|
)
|
|
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
|
|
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
|
|
|
|
# invoices table
|
|
op.create_table('invoices',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('email_id', sa.String(), nullable=True),
|
|
sa.Column('email_subject', sa.String(), nullable=True),
|
|
sa.Column('email_from', sa.String(), nullable=True),
|
|
sa.Column('email_date', sa.DateTime(), nullable=True),
|
|
sa.Column('invoice_number', sa.String(), nullable=True),
|
|
sa.Column('invoice_date', sa.DateTime(), nullable=True),
|
|
sa.Column('invoice_amount', sa.Float(), nullable=True),
|
|
sa.Column('invoice_tax_amount', sa.Float(), nullable=True),
|
|
sa.Column('invoice_tax_rate', sa.Float(), nullable=True),
|
|
sa.Column('invoice_tax_type', sa.String(), nullable=True),
|
|
sa.Column('issuer_name', sa.String(), nullable=True),
|
|
sa.Column('issuer_address', sa.Text(), nullable=True),
|
|
sa.Column('file_path', sa.String(), nullable=True),
|
|
sa.Column('file_name', sa.String(), nullable=True),
|
|
sa.Column('storage_year', sa.Integer(), nullable=True),
|
|
sa.Column('storage_path', sa.String(), nullable=True),
|
|
sa.Column('processed', sa.Boolean(), nullable=False),
|
|
sa.Column('processing_error', sa.Text(), nullable=True),
|
|
sa.Column('confidence_score', sa.Float(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_invoices_id'), 'invoices', ['id'], unique=False)
|
|
op.create_index(op.f('ix_invoices_email_id'), 'invoices', ['email_id'], unique=False)
|
|
op.create_index(op.f('ix_invoices_invoice_number'), 'invoices', ['invoice_number'], unique=False)
|
|
|
|
# email_logs table
|
|
op.create_table('email_logs',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('email_id', sa.String(), nullable=False),
|
|
sa.Column('email_subject', sa.String(), nullable=True),
|
|
sa.Column('email_from', sa.String(), nullable=True),
|
|
sa.Column('email_date', sa.DateTime(), nullable=True),
|
|
sa.Column('email_folder', sa.String(), nullable=True),
|
|
sa.Column('matched_keywords', sa.JSON(), nullable=True),
|
|
sa.Column('has_attachment', sa.Boolean(), nullable=False),
|
|
sa.Column('attachment_type', sa.String(), nullable=True),
|
|
sa.Column('processed', sa.Boolean(), nullable=False),
|
|
sa.Column('processing_result', sa.String(), nullable=True),
|
|
sa.Column('invoice_id', sa.Integer(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('email_id')
|
|
)
|
|
op.create_index(op.f('ix_email_logs_id'), 'email_logs', ['id'], unique=False)
|
|
|
|
# invoice_details table
|
|
op.create_table('invoice_details',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('invoice_id', sa.Integer(), nullable=False),
|
|
sa.Column('raw_text', sa.Text(), nullable=True),
|
|
sa.Column('parsed_data', sa.JSON(), nullable=True),
|
|
sa.Column('confidence_breakdown', sa.JSON(), nullable=True),
|
|
sa.Column('processing_notes', sa.Text(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_invoice_details_id'), 'invoice_details', ['id'], unique=False)
|
|
op.create_index(op.f('ix_invoice_details_invoice_id'), 'invoice_details', ['invoice_id'], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table('invoice_details')
|
|
op.drop_table('email_logs')
|
|
op.drop_table('invoices')
|
|
op.drop_table('users')
|