-- LED Calculator Database Setup
-- Import this via phpMyAdmin into the 'printrama_led' database

CREATE TABLE IF NOT EXISTS `users` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `username` VARCHAR(100) NOT NULL UNIQUE,
  `password_hash` VARCHAR(255) NOT NULL,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `projects` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `name` VARCHAR(255) NOT NULL,
  `filename` VARCHAR(255),
  `params` JSON,
  `results` JSON,
  `totals` JSON,
  `real_mm` JSON,
  `svg_content` MEDIUMTEXT,
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Default user: RamaPrint / Rahoveci123.
INSERT INTO `users` (`username`, `password_hash`) VALUES
('RamaPrint', '$2b$10$qANRyPQgWhydG6.X896wTOSosxs/pxYvHNXT2VFg3IuvFPGwx8L3K');
