-- Migration 140: Server version history tracking
-- Chronicler #88 | April 14, 2026

-- Add current_version to server_config for quick display
ALTER TABLE server_config ADD COLUMN IF NOT EXISTS current_version VARCHAR(64);

-- Version history table
CREATE TABLE IF NOT EXISTS server_version_history (
  id SERIAL PRIMARY KEY,
  server_identifier VARCHAR(36) NOT NULL,
  version VARCHAR(64) NOT NULL,
  updated_by_id VARCHAR(32) NOT NULL,
  updated_by_username VARCHAR(64) NOT NULL,
  updated_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_svh_server ON server_version_history(server_identifier);
CREATE INDEX IF NOT EXISTS idx_svh_updated ON server_version_history(updated_at DESC);
