CREATE TABLE IF NOT EXISTS users (
    id_user INT UNSIGNED NOT NULL AUTO_INCREMENT,
    name VARCHAR(190) NOT NULL,
    email VARCHAR(190) NOT NULL,
    pass_hash VARCHAR(255) NOT NULL,
    locale VARCHAR(5) NOT NULL DEFAULT 'es',
    is_admin TINYINT UNSIGNED NOT NULL DEFAULT 0,
    is_active TINYINT UNSIGNED NOT NULL DEFAULT 1,
    is_org TINYINT UNSIGNED NOT NULL DEFAULT 0,
    org_id INT UNSIGNED NULL,
    max_accounts INT UNSIGNED NOT NULL DEFAULT 0,
    id_plan INT UNSIGNED NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    last_login_at DATETIME NULL,
    PRIMARY KEY (id_user),
    UNIQUE KEY uniq_email (email),
    KEY idx_plan (id_plan)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
