<?php

return [
    'key' => '2026_03_22_000004_add_print_list_tables',
    'title' => 'Drucklisten für PDF-Export und Papiererfassung anlegen',
    'description' => 'Ergänzt Snapshots für druckfertige Listen und die Nacherfassung von Vorder- und Rückseiten.',
    'statements' => [
        <<<'SQL'
CREATE TABLE IF NOT EXISTS print_lists (
    id CHAR(36) NOT NULL PRIMARY KEY,
    tenant_id CHAR(36) NOT NULL,
    title VARCHAR(255) NOT NULL,
    unit_price DECIMAL(10,2) NOT NULL DEFAULT 0.50,
    status VARCHAR(50) NOT NULL DEFAULT 'draft',
    created_by_user_id CHAR(36) NULL,
    notes TEXT NULL,
    imported_at DATETIME NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    CONSTRAINT print_lists_tenant_fk FOREIGN KEY (tenant_id) REFERENCES tenants(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL,
        <<<'SQL'
CREATE TABLE IF NOT EXISTS print_list_items (
    id CHAR(36) NOT NULL PRIMARY KEY,
    print_list_id CHAR(36) NOT NULL,
    member_id CHAR(36) NOT NULL,
    member_name VARCHAR(255) NOT NULL,
    list_position INT NOT NULL,
    front_strokes INT NOT NULL DEFAULT 0,
    back_strokes INT NOT NULL DEFAULT 0,
    total_strokes INT NOT NULL DEFAULT 0,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    UNIQUE KEY print_list_items_unique (print_list_id, member_id),
    CONSTRAINT print_list_items_list_fk FOREIGN KEY (print_list_id) REFERENCES print_lists(id),
    CONSTRAINT print_list_items_member_fk FOREIGN KEY (member_id) REFERENCES members(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL,
    ],
];
