-- PDF Reports Table
CREATE TABLE IF NOT EXISTS pdf_reports (
  id SERIAL PRIMARY KEY,
  resource_type VARCHAR(50) NOT NULL,
  resource_value VARCHAR(500) NOT NULL,
  format VARCHAR(50) NOT NULL,
  generated_at TIMESTAMP NOT NULL DEFAULT NOW(),
  expires_at TIMESTAMP NOT NULL,
  file_hash VARCHAR(64) NOT NULL,
  file_size_bytes INTEGER NOT NULL,
  metadata JSONB DEFAULT '{}',
  UNIQUE(resource_value, format, DATE(generated_at))
);

-- Indexes for performance
CREATE INDEX IF NOT EXISTS idx_pdf_expires ON pdf_reports(expires_at);
CREATE INDEX IF NOT EXISTS idx_pdf_hash ON pdf_reports(file_hash);
CREATE INDEX IF NOT EXISTS idx_pdf_resource ON pdf_reports(resource_value, format);
