-- Generated by sz-rust-cli make:plugin --template {{ template_type }} --name {{ plugin_name }}
-- Generation time: {{ generated_at }}
-- DO NOT EDIT MANUALLY
-- Source table for report aggregation
CREATE TABLE IF NOT EXISTS `{{ table_name }}` (
{%- for field in fields %}
`{{ field.name }}` {{ field.sql_type }} {%- if field.nullable %} NULL{%- else %} NOT NULL{%- endif %}{%- if field.default %} DEFAULT {{ field.default }}{%- endif %},
{%- endfor %}
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`{{ primary_key_name }}`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Indexes for dimension columns (used in GROUP BY)
{%- for dim in dimensions %}
CREATE INDEX `idx_{{ table_name }}_{{ dim.field }}` ON `{{ table_name }}` (`{{ dim.field }}`);
{%- endfor %}
-- Index for date range filtering
CREATE INDEX `idx_{{ table_name }}_created_at` ON `{{ table_name }}` (`created_at`);