"""Peewee migrations -- 181_MAIN.py.

Setup is now the single source of truth for the auto-print copy count.

* Add ``setup.repeated_print_count_pump`` (separate global default for pump
  orders, since their workflow may differ from delivery sheets).
* Drop ``order.repeated_print_count`` (was per-order frozen value;
  the printing code now reads ``setup.repeated_print_count`` live).
"""

import peewee as pw
from peewee_migrate import Migrator


def migrate(migrator: Migrator, database: pw.Database, *, fake: bool = False) -> None:
    migrator.add_fields("setup", repeated_print_count_pump=pw.IntegerField(constraints=[pw.SQL("DEFAULT 1")], default=1))

    migrator.remove_fields("order", "repeated_print_count")


def rollback(migrator: Migrator, database: pw.Database, *, fake: bool = False) -> None:
    migrator.add_fields("order", repeated_print_count=pw.IntegerField(constraints=[pw.SQL("DEFAULT 1")], default=1))

    migrator.remove_fields("setup", "repeated_print_count_pump")
