-- Migration 002 — Game saves with anti-cheat metadata
-- Safe: CREATE TABLE IF NOT EXISTS, no data loss
-- Run: mysql -u <user> -p clickerz < migrations/002_game_saves.sql

CREATE TABLE IF NOT EXISTS game_saves (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id INT NOT NULL UNIQUE,
  game_state JSON NOT NULL,
  last_save TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  lifetime_tadpoles BIGINT DEFAULT 0,
  prestige_count INT DEFAULT 0,
  play_time_seconds INT DEFAULT 0,
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
