Erste Produktivversion

This commit is contained in:
2026-08-08 20:31:58 +02:00
parent d8ded2816d
commit 7b21e2d1b4
110 changed files with 18170 additions and 644 deletions

View File

@@ -0,0 +1,62 @@
"""Phase 7b: Stückzahl und Gebinde trennen
Bis hierher steckten beide in `quantity`/`unit`. Bei "500 ml" zu 2,99 EUR
rechnete die Summenbildung 500 × 2,99 = 1495 EUR.
Die vorhandenen Werte werden als Gebinde übernommen (aus "500 ml" wird
pack_size=500, pack_unit=ml) und die Stückzahl auf 1 gesetzt. Das ist die
sichere Richtung: Wo bisher tatsächlich eine Stückzahl gemeint war,
stimmt die Summe danach - sie wird nur nicht mehr vervielfacht.
Revision ID: 0010
Revises: 0009
Create Date: 2026-08-08
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = "0010"
down_revision: str | None = "0009"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
op.add_column(
"list_item",
sa.Column("count", sa.Integer(), nullable=False, server_default=sa.text("1")),
)
op.alter_column("list_item", "quantity",
new_column_name="pack_size", existing_type=sa.Numeric(10, 3))
op.alter_column("list_item", "unit",
new_column_name="pack_unit", existing_type=sa.String(32))
op.alter_column("price_point", "quantity",
new_column_name="pack_size", existing_type=sa.Numeric(10, 3))
op.alter_column("price_point", "unit",
new_column_name="pack_unit", existing_type=sa.String(32))
op.add_column("product_cache", sa.Column("count", sa.Integer(), nullable=True))
op.alter_column("product_cache", "quantity",
new_column_name="pack_size", existing_type=sa.Numeric(10, 3))
op.alter_column("product_cache", "unit",
new_column_name="pack_unit", existing_type=sa.String(32))
def downgrade() -> None:
op.alter_column("product_cache", "pack_unit",
new_column_name="unit", existing_type=sa.String(32))
op.alter_column("product_cache", "pack_size",
new_column_name="quantity", existing_type=sa.Numeric(10, 3))
op.drop_column("product_cache", "count")
op.alter_column("price_point", "pack_unit",
new_column_name="unit", existing_type=sa.String(32))
op.alter_column("price_point", "pack_size",
new_column_name="quantity", existing_type=sa.Numeric(10, 3))
op.alter_column("list_item", "pack_unit",
new_column_name="unit", existing_type=sa.String(32))
op.alter_column("list_item", "pack_size",
new_column_name="quantity", existing_type=sa.Numeric(10, 3))
op.drop_column("list_item", "count")