-- Create uzivatele (users) table
CREATE TABLE IF NOT EXISTS `uzivatele` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `jmeno` VARCHAR(255) NOT NULL,
  `email` VARCHAR(255) NOT NULL UNIQUE,
  `heslo` VARCHAR(255) NOT NULL,
  `role` VARCHAR(50) DEFAULT 'user',
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create transakce (transactions) table
CREATE TABLE IF NOT EXISTS `transakce` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `popis` VARCHAR(500),
  `datum` DATE,
  `cena` DECIMAL(10,2),
  `typ` VARCHAR(100),
  `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Fix typ column if it's too small (for existing tables)
ALTER TABLE `transakce` MODIFY COLUMN `typ` VARCHAR(100);
