-- Add authentication fields to users and constraints (idempotent)
ALTER TABLE `users`
  ADD COLUMN IF NOT EXISTS `password_hash` varchar(255) NOT NULL AFTER `email`,
  ADD COLUMN IF NOT EXISTS `is_admin` TINYINT(1) NOT NULL DEFAULT 0 AFTER `password_hash`;

-- Ensure email has a unique index (note: allows multiple NULLs in MySQL/MariaDB)
ALTER TABLE `users`
  ADD UNIQUE KEY IF NOT EXISTS `uk_users_email` (`email`);
