-- MariaDB Initialization Script for Recticel Quality Application
-- This script creates the database and user if they don't exist

-- Create database if it doesn't exist
CREATE DATABASE IF NOT EXISTS trasabilitate CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- Create user if it doesn't exist (MariaDB 10.2+)
CREATE USER IF NOT EXISTS 'trasabilitate'@'%' IDENTIFIED BY 'Initial01!';

-- Grant all privileges on the database to the user
GRANT ALL PRIVILEGES ON trasabilitate.* TO 'trasabilitate'@'%';

-- Flush privileges to ensure they take effect
FLUSH PRIVILEGES;

-- Select the database
USE trasabilitate;

-- The actual table creation will be handled by the Python setup script
-- This ensures compatibility with the existing setup_complete_database.py
