<?php

return <<<'SQL'
CREATE TABLE year_end_runs (
    id CHAR(36) NOT NULL PRIMARY KEY,
    tenant_id CHAR(36) NOT NULL,
    year INT NOT NULL,
    bonus_mode VARCHAR(30) NOT NULL DEFAULT 'proportional',
    bonus_pool_amount DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    bonus_per_member_amount DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    booked_at DATETIME NOT NULL,
    total_strokes INT NOT NULL DEFAULT 0,
    recipient_count INT NOT NULL DEFAULT 0,
    total_amount DECIMAL(10,2) NOT NULL DEFAULT 0.00,
    preview_json LONGTEXT NOT NULL,
    notes LONGTEXT NULL,
    status VARCHAR(30) NOT NULL DEFAULT 'executed',
    created_by_user_id CHAR(36) NOT NULL,
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    executed_at DATETIME NOT NULL,
    UNIQUE (tenant_id, year),
    FOREIGN KEY (tenant_id) REFERENCES tenants(id),
    FOREIGN KEY (created_by_user_id) REFERENCES users(id)
);
SQL;
