CREATE TABLE IF NOT EXISTS users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255) UNIQUE NOT NULL,
  pass_hash VARCHAR(255) NOT NULL,
  role ENUM('admin','editor','user') DEFAULT 'user',
  locale VARCHAR(8) DEFAULT 'de',
  user_group VARCHAR(50) DEFAULT 'demo',
  theme VARCHAR(50) DEFAULT 'pico-default',
  accessibility JSON DEFAULT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB;

INSERT INTO users (email, pass_hash, role, locale)
SELECT 'admin@crumb.local', '$2b$12$Xe7ETl.YKaFrc0q9NZDWB.S2Rp5kUUkXuS0Axlazk1jIAoQGgu1SK', 'admin', 'de' FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM users WHERE email='admin@crumb.local');

INSERT INTO users (email, pass_hash, role, locale)
SELECT 'demo@crumb.local', '$2b$12$lctCe5zTnjiIAJu2EMzqw.qcREKsEYZ7VESjphJI9cNQLCIrWd0xG', 'user', 'de' FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM users WHERE email='demo@crumb.local');
