nis2-agile/docs/sql/013_license_ext.sql
DevEnv nis2-agile cb0988da27 [LICENSE] Gestione licenze marketing + campi commerciali estesi
- licenseExt.html: dashboard marketing per generare/gestire licenze
  Login JWT super_admin, stats strip (totali/usate/orgs/utenti),
  form genera con label/piano/durata/max-aziende/max-utenti/prezzo/reseller,
  lista paginata con filtri stato+canale, dettaglio modale, revoca/rigenera,
  export CSV e copia token/URL
- Migration 013: invites +max_users_per_org, +price_eur, +reseller_name
  organizations +license_max_users (da provisioning)
- InviteController::create() gestisce nuovi campi, validate() espone max_users_per_org
- ServicesController::provision() salva license_max_users nell'org

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 15:34:38 +01:00

39 lines
1.8 KiB
SQL

-- ============================================================
-- NIS2 Agile — Migration 013: Licenze Estese (Marketing)
-- Aggiunge campi commerciali agli inviti e alle organizzazioni
-- per controllo numero aziende, utenti, prezzi e reseller.
-- ============================================================
USE nis2_agile_db;
-- ── invites: campi commerciali aggiuntivi ──────────────────────────────────
-- Numero massimo di utenti per organizzazione (NULL = illimitato)
ALTER TABLE invites
ADD COLUMN IF NOT EXISTS max_users_per_org SMALLINT UNSIGNED NULL DEFAULT NULL AFTER max_uses;
-- Prezzo di listino (solo riferimento, non enforced da NIS2)
ALTER TABLE invites
ADD COLUMN IF NOT EXISTS price_eur DECIMAL(8,2) NULL DEFAULT NULL AFTER max_users_per_org;
-- Nome reseller / partner che ha acquistato la licenza
ALTER TABLE invites
ADD COLUMN IF NOT EXISTS reseller_name VARCHAR(128) NULL DEFAULT NULL AFTER price_eur;
-- ── organizations: limite utenti dalla licenza ─────────────────────────────
-- Numero massimo utenti per org (valorizzato al provisioning)
ALTER TABLE organizations
ADD COLUMN IF NOT EXISTS license_max_users SMALLINT UNSIGNED NULL DEFAULT NULL AFTER license_expires_at;
-- ── Verifica ──────────────────────────────────────────────────────────────
SELECT
COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'nis2_agile_db'
AND TABLE_NAME = 'invites'
AND COLUMN_NAME IN ('max_users_per_org','price_eur','reseller_name')
ORDER BY ORDINAL_POSITION;
SELECT 'Migration 013 license_ext completata.' AS stato;