nis2-agile/docs/sql/013_license_ext.sql
DevEnv nis2-agile c906a6eff3 [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>
2026-03-07 16:48:53 +01:00

38 lines
1.7 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 ──────────────────────────────────
-- 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.
ALTER TABLE invites
ADD COLUMN max_users_per_org SMALLINT UNSIGNED NULL DEFAULT NULL AFTER max_uses;
ALTER TABLE invites
ADD COLUMN price_eur DECIMAL(8,2) NULL DEFAULT NULL AFTER max_users_per_org;
ALTER TABLE invites
ADD COLUMN reseller_name VARCHAR(128) NULL DEFAULT NULL AFTER price_eur;
-- ── organizations: limite utenti dalla licenza ─────────────────────────────
ALTER TABLE organizations
ADD COLUMN 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;