[DB] Fix migration 013: MySQL 8.0 compat + script deploy idempotente

- Rimosso ADD COLUMN IF NOT EXISTS (non supportato MySQL 8.0 standard)
- Aggiunto deploy_013.sh: script bash idempotente con check information_schema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile
2026-03-07 16:48:53 +01:00
co-authored by Claude Sonnet 4.6
parent f7347ccd8c
commit c906a6eff3
2 changed files with 54 additions and 8 deletions
+7 -8
View File
@@ -7,24 +7,23 @@
USE nis2_agile_db;
-- ── invites: campi commerciali aggiuntivi ──────────────────────────────────
-- NOTA: MySQL 8.0 non supporta ADD COLUMN IF NOT EXISTS (solo NDB).
-- Eseguire questo file con: mysql -e "source /path/013_license_ext.sql"
-- oppure usare lo script shell deploy_013.sh nella stessa cartella.
-- 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;
ADD COLUMN 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;
ADD COLUMN 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;
ADD COLUMN 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;
ADD COLUMN license_max_users SMALLINT UNSIGNED NULL DEFAULT NULL AFTER license_expires_at;
-- ── Verifica ──────────────────────────────────────────────────────────────
SELECT