-- https://www.phpmyadmin.net/
--
-- Creato il: Mar 29, 2026 alle 14:14
-- Versione del server: 10.6.22-MariaDB-0ubuntu0.22.04.1
-- Versione PHP: 8.1.2-1ubuntu2.23

START TRANSACTION;



--
-- Database: `b_main`
--

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__account`
--

CREATE TABLE `bm__account` (
  `id` int(11) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(1024) NOT NULL DEFAULT '',
  `id_ext` int(11) NOT NULL DEFAULT 0,
  `nome` varchar(255) NOT NULL,
  `tipo` varchar(24) NOT NULL DEFAULT '',
  `note` text DEFAULT NULL,
  `id_server` int(11) NOT NULL DEFAULT 0,
  `id_credential` int(11) DEFAULT NULL,
  `attivo` char(1) NOT NULL DEFAULT '1',
  `lastupdate` datetime DEFAULT NULL,
  `id_circuito` int(11) NOT NULL DEFAULT 13
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__applicazioni`
--

CREATE TABLE `bm__applicazioni` (
  `id` int(11) NOT NULL,
  `nome` varchar(255) NOT NULL,
  `codice` varchar(100) DEFAULT NULL,
  `database_` int(11) NOT NULL DEFAULT -1,
  `server_address` varchar(255) NOT NULL DEFAULT '',
  `db_name` varchar(255) DEFAULT NULL,
  `db_user` varchar(255) DEFAULT NULL,
  `db_password` varchar(255) DEFAULT NULL,
  `database2_` int(11) NOT NULL DEFAULT -1,
  `server_address_2` varchar(255) DEFAULT NULL,
  `db_name_2` varchar(255) DEFAULT NULL,
  `db_user_2` varchar(255) DEFAULT NULL,
  `db_password_2` varchar(255) DEFAULT NULL,
  `shortname` varchar(55) DEFAULT NULL,
  `dir` varchar(255) DEFAULT NULL,
  `repo_locale` varchar(255) DEFAULT NULL,
  `entrypoint_locale` varchar(255) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `url2` varchar(255) DEFAULT NULL,
  `attivo` char(1) NOT NULL DEFAULT '0',
  `online` char(1) NOT NULL DEFAULT '0' COMMENT '1: pubblicata',
  `gruppo` varchar(16) DEFAULT NULL,
  `dirtobackup` text DEFAULT NULL,
  `dbtobackup` text DEFAULT NULL,
  `tipo` int(11) DEFAULT NULL,
  `id_framework` int(11) DEFAULT NULL,
  `versione_app` varchar(50) DEFAULT NULL,
  `ambiente_predefinito` varchar(20) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `descrizione` text DEFAULT NULL,
  `id_server` int(11) NOT NULL DEFAULT 0,
  `ftpServer` varchar(255) DEFAULT NULL,
  `ftpUser` varchar(255) DEFAULT NULL,
  `ftpPass` varchar(255) DEFAULT NULL,
  `urlScriptBck` varchar(255) DEFAULT NULL,
  `frqBck` char(1) NOT NULL DEFAULT '0',
  `urlBck` varchar(255) DEFAULT NULL,
  `dayBck` varchar(16) DEFAULT NULL,
  `autobackup` char(1) NOT NULL DEFAULT '0',
  `ftpDir` varchar(255) DEFAULT NULL,
  `id_storage` int(11) NOT NULL DEFAULT 0,
  `delBck` char(1) NOT NULL DEFAULT '-',
  `lastDownloadBck` datetime DEFAULT NULL,
  `id_circuito` int(11) NOT NULL DEFAULT 13
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__app_env`
--

CREATE TABLE `bm__app_env` (
  `id` int(11) NOT NULL,
  `id_applicazione` int(11) NOT NULL,
  `nome` varchar(100) NOT NULL,
  `tipo` varchar(20) NOT NULL COMMENT 'local, dev, test, staging, prod',
  `id_server_web` int(11) DEFAULT NULL,
  `id_db_server` int(11) DEFAULT NULL,
  `path_remoto` varchar(255) DEFAULT NULL,
  `path_release` varchar(255) DEFAULT NULL,
  `url_principale` varchar(255) DEFAULT NULL,
  `url_secondaria` varchar(255) DEFAULT NULL,
  `db_name` varchar(255) DEFAULT NULL,
  `db_user` varchar(255) DEFAULT NULL,
  `id_credential_db` int(11) DEFAULT NULL,
  `id_credential_deploy` int(11) DEFAULT NULL,
  `id_framework` int(11) DEFAULT NULL,
  `versione_framework` varchar(50) DEFAULT NULL,
  `versione_app` varchar(50) DEFAULT NULL,
  `branch` varchar(100) DEFAULT NULL,
  `online` char(1) NOT NULL DEFAULT '0',
  `attivo` char(1) NOT NULL DEFAULT '1',
  `note` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__app_env_migration`
--

CREATE TABLE `bm__app_env_migration` (
  `id` int(11) NOT NULL,
  `id_app_env` int(11) NOT NULL,
  `id_migration` int(11) NOT NULL,
  `eseguita_il` datetime NOT NULL DEFAULT current_timestamp(),
  `esito` varchar(20) NOT NULL DEFAULT 'ok',
  `log_output` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__app_env_status`
--

CREATE TABLE `bm__app_env_status` (
  `id` int(11) NOT NULL,
  `id_app_env` int(11) NOT NULL,
  `last_code_version` varchar(50) DEFAULT NULL,
  `last_db_version` varchar(50) DEFAULT NULL,
  `last_framework_version` varchar(50) DEFAULT NULL,
  `last_deploy_at` datetime DEFAULT NULL,
  `last_db_sync_at` datetime DEFAULT NULL,
  `last_backup_at` datetime DEFAULT NULL,
  `last_check_at` datetime DEFAULT NULL,
  `last_result` varchar(20) DEFAULT NULL COMMENT 'ok, warning, error',
  `last_message` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__backup_job`
--

CREATE TABLE `bm__backup_job` (
  `id` int(11) NOT NULL,
  `id_app_env` int(11) NOT NULL,
  `tipo` varchar(20) NOT NULL COMMENT 'files, db, full',
  `frequenza` varchar(30) DEFAULT NULL,
  `path_destinazione` varchar(255) DEFAULT NULL,
  `keep_days` int(11) DEFAULT NULL,
  `attivo` char(1) NOT NULL DEFAULT '1',
  `note` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__backup_log`
--

CREATE TABLE `bm__backup_log` (
  `id` int(11) NOT NULL,
  `id_backup_job` int(11) NOT NULL,
  `started_at` datetime NOT NULL DEFAULT current_timestamp(),
  `ended_at` datetime DEFAULT NULL,
  `esito` varchar(20) NOT NULL DEFAULT 'running',
  `file_name` varchar(255) DEFAULT NULL,
  `dimensione` bigint(20) DEFAULT NULL,
  `output_log` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__circuitiall`
--

CREATE TABLE `bm__circuitiall` (
  `id_circuito` int(11) NOT NULL,
  `nome` varchar(255) NOT NULL,
  `server_address` varchar(255) NOT NULL,
  `db_name` varchar(255) NOT NULL,
  `db_user` varchar(255) NOT NULL,
  `db_password` varchar(255) NOT NULL,
  `shortname` varchar(55) NOT NULL,
  `dir` varchar(255) NOT NULL,
  `url` varchar(255) NOT NULL,
  `attivo` char(1) NOT NULL DEFAULT '0',
  `remoto` char(1) NOT NULL DEFAULT '0',
  `note` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__credential`
--

CREATE TABLE `bm__credential` (
  `id` int(11) NOT NULL,
  `nome` varchar(150) NOT NULL,
  `tipo` varchar(30) NOT NULL COMMENT 'ssh, sftp, ftp, db, api, generic',
  `username` varchar(255) DEFAULT NULL,
  `secret_encrypted` text NOT NULL,
  `iv_encrypted` varchar(255) DEFAULT NULL,
  `cipher` varchar(50) DEFAULT 'AES-256-CBC',
  `scope` varchar(30) DEFAULT 'project' COMMENT 'project, server, env, user',
  `note` text DEFAULT NULL,
  `attivo` char(1) NOT NULL DEFAULT '1',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__credential_link`
--

CREATE TABLE `bm__credential_link` (
  `id` int(11) NOT NULL,
  `id_credential` int(11) NOT NULL,
  `entity_type` varchar(30) NOT NULL COMMENT 'server, db_server, app, env, account',
  `entity_id` int(11) NOT NULL,
  `ruolo` varchar(30) DEFAULT NULL COMMENT 'primary, backup, deploy, readonly'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__db_server`
--

CREATE TABLE `bm__db_server` (
  `id` int(11) NOT NULL,
  `nome` varchar(100) NOT NULL,
  `host` varchar(255) NOT NULL,
  `porta` int(11) NOT NULL DEFAULT 3306,
  `engine` varchar(50) NOT NULL DEFAULT 'mysql',
  `versione` varchar(50) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `attivo` char(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__deploy_log`
--

CREATE TABLE `bm__deploy_log` (
  `id` int(11) NOT NULL,
  `id_app_env` int(11) NOT NULL,
  `operazione` varchar(30) NOT NULL COMMENT 'deploy, db_sync, backup, restore, check',
  `trigger_type` varchar(20) DEFAULT 'manual' COMMENT 'manual, cli, web, assistant, cron',
  `versione_codice` varchar(50) DEFAULT NULL,
  `versione_db` varchar(50) DEFAULT NULL,
  `started_at` datetime NOT NULL DEFAULT current_timestamp(),
  `ended_at` datetime DEFAULT NULL,
  `durata_secondi` int(11) DEFAULT NULL,
  `esito` varchar(20) NOT NULL DEFAULT 'running' COMMENT 'running, ok, warning, error',
  `output_log` mediumtext DEFAULT NULL,
  `note` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__framework`
--

CREATE TABLE `bm__framework` (
  `id` int(11) NOT NULL,
  `nome` varchar(100) DEFAULT NULL,
  `versione` varchar(10) NOT NULL,
  `branch` varchar(50) DEFAULT NULL,
  `dir` varchar(55) DEFAULT NULL,
  `attivo` char(1) NOT NULL DEFAULT '0',
  `lastupdate` datetime DEFAULT NULL,
  `note` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__migration`
--

CREATE TABLE `bm__migration` (
  `id` int(11) NOT NULL,
  `id_applicazione` int(11) NOT NULL,
  `codice` varchar(150) NOT NULL,
  `titolo` varchar(255) DEFAULT NULL,
  `versione_target` varchar(50) DEFAULT NULL,
  `file_name` varchar(255) DEFAULT NULL,
  `checksum` varchar(128) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__nota`
--

CREATE TABLE `bm__nota` (
  `id` int(11) NOT NULL,
  `entity_type` varchar(20) NOT NULL COMMENT 'app, env, server, db_server',
  `entity_id` int(11) NOT NULL,
  `titolo` varchar(255) DEFAULT NULL,
  `testo` mediumtext NOT NULL,
  `tipo` varchar(30) DEFAULT 'note' COMMENT 'note, todo, warning, changelog',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__server`
--

CREATE TABLE `bm__server` (
  `id` int(11) NOT NULL,
  `nome` varchar(55) NOT NULL,
  `hostname` varchar(255) DEFAULT NULL,
  `ip` varchar(55) DEFAULT NULL,
  `porta_ssh` int(11) NOT NULL DEFAULT 22,
  `root` varchar(255) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `tipo` varchar(255) DEFAULT NULL,
  `sistema_operativo` varchar(100) DEFAULT NULL,
  `provider` varchar(100) DEFAULT NULL,
  `is_storage` char(1) NOT NULL DEFAULT '0',
  `attivo` char(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Struttura della tabella `bm__setting`
--

CREATE TABLE `bm__setting` (
  `id` int(11) NOT NULL,
  `chiave` varchar(150) NOT NULL,
  `valore` text DEFAULT NULL,
  `note` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indici per le tabelle scaricate
--

--
-- Indici per le tabelle `bm__account`
--
ALTER TABLE `bm__account`
  ADD PRIMARY KEY (`id`);

--
-- Indici per le tabelle `bm__applicazioni`
--
ALTER TABLE `bm__applicazioni`
  ADD PRIMARY KEY (`id`);

--
-- Indici per le tabelle `bm__app_env`
--
ALTER TABLE `bm__app_env`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_bm_app_env` (`id_applicazione`,`tipo`,`nome`),
  ADD KEY `idx_app` (`id_applicazione`),
  ADD KEY `idx_tipo` (`tipo`),
  ADD KEY `idx_server_web` (`id_server_web`),
  ADD KEY `idx_db_server` (`id_db_server`),
  ADD KEY `idx_framework` (`id_framework`),
  ADD KEY `idx_cred_db` (`id_credential_db`),
  ADD KEY `idx_cred_deploy` (`id_credential_deploy`);

--
-- Indici per le tabelle `bm__app_env_migration`
--
ALTER TABLE `bm__app_env_migration`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_env_migration` (`id_app_env`,`id_migration`),
  ADD KEY `idx_migration` (`id_migration`);

--
-- Indici per le tabelle `bm__app_env_status`
--
ALTER TABLE `bm__app_env_status`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_env_status` (`id_app_env`);

--
-- Indici per le tabelle `bm__backup_job`
--
ALTER TABLE `bm__backup_job`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_env` (`id_app_env`);

--
-- Indici per le tabelle `bm__backup_log`
--
ALTER TABLE `bm__backup_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_job` (`id_backup_job`);

--
-- Indici per le tabelle `bm__circuitiall`
--
ALTER TABLE `bm__circuitiall`
  ADD PRIMARY KEY (`id_circuito`);

--
-- Indici per le tabelle `bm__credential`
--
ALTER TABLE `bm__credential`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_tipo` (`tipo`),
  ADD KEY `idx_scope` (`scope`);

--
-- Indici per le tabelle `bm__credential_link`
--
ALTER TABLE `bm__credential_link`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_entity` (`entity_type`,`entity_id`),
  ADD KEY `idx_credential` (`id_credential`);

--
-- Indici per le tabelle `bm__db_server`
--
ALTER TABLE `bm__db_server`
  ADD PRIMARY KEY (`id`);

--
-- Indici per le tabelle `bm__deploy_log`
--
ALTER TABLE `bm__deploy_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_env` (`id_app_env`),
  ADD KEY `idx_operazione` (`operazione`),
  ADD KEY `idx_esito` (`esito`),
  ADD KEY `idx_started_at` (`started_at`);

--
-- Indici per le tabelle `bm__framework`
--
ALTER TABLE `bm__framework`
  ADD PRIMARY KEY (`id`);

--
-- Indici per le tabelle `bm__migration`
--
ALTER TABLE `bm__migration`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_app_codice` (`id_applicazione`,`codice`),
  ADD KEY `idx_app` (`id_applicazione`);

--
-- Indici per le tabelle `bm__nota`
--
ALTER TABLE `bm__nota`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_entity` (`entity_type`,`entity_id`),
  ADD KEY `idx_tipo` (`tipo`);

--
-- Indici per le tabelle `bm__server`
--
ALTER TABLE `bm__server`
  ADD PRIMARY KEY (`id`);

--
-- Indici per le tabelle `bm__setting`
--
ALTER TABLE `bm__setting`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_chiave` (`chiave`);

--
-- AUTO_INCREMENT per le tabelle scaricate
--

--
-- AUTO_INCREMENT per la tabella `bm__account`
--
ALTER TABLE `bm__account`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__applicazioni`
--
ALTER TABLE `bm__applicazioni`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__app_env`
--
ALTER TABLE `bm__app_env`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__app_env_migration`
--
ALTER TABLE `bm__app_env_migration`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__app_env_status`
--
ALTER TABLE `bm__app_env_status`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__backup_job`
--
ALTER TABLE `bm__backup_job`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__backup_log`
--
ALTER TABLE `bm__backup_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__circuitiall`
--
ALTER TABLE `bm__circuitiall`
  MODIFY `id_circuito` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__credential`
--
ALTER TABLE `bm__credential`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__credential_link`
--
ALTER TABLE `bm__credential_link`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__db_server`
--
ALTER TABLE `bm__db_server`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__deploy_log`
--
ALTER TABLE `bm__deploy_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__framework`
--
ALTER TABLE `bm__framework`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__migration`
--
ALTER TABLE `bm__migration`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__nota`
--
ALTER TABLE `bm__nota`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__server`
--
ALTER TABLE `bm__server`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT per la tabella `bm__setting`
--
ALTER TABLE `bm__setting`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Limiti per le tabelle scaricate
--

--
-- Limiti per la tabella `bm__app_env`
--
ALTER TABLE `bm__app_env`
  ADD CONSTRAINT `fk_bm_app_env_app` FOREIGN KEY (`id_applicazione`) REFERENCES `bm__applicazioni` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_bm_app_env_cred_db` FOREIGN KEY (`id_credential_db`) REFERENCES `bm__credential` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_bm_app_env_cred_deploy` FOREIGN KEY (`id_credential_deploy`) REFERENCES `bm__credential` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_bm_app_env_db_server` FOREIGN KEY (`id_db_server`) REFERENCES `bm__db_server` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_bm_app_env_framework` FOREIGN KEY (`id_framework`) REFERENCES `bm__framework` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_bm_app_env_server_web` FOREIGN KEY (`id_server_web`) REFERENCES `bm__server` (`id`) ON DELETE SET NULL;

--
-- Limiti per la tabella `bm__app_env_migration`
--
ALTER TABLE `bm__app_env_migration`
  ADD CONSTRAINT `fk_bm_env_migration_env` FOREIGN KEY (`id_app_env`) REFERENCES `bm__app_env` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_bm_env_migration_migration` FOREIGN KEY (`id_migration`) REFERENCES `bm__migration` (`id`) ON DELETE CASCADE;

--
-- Limiti per la tabella `bm__app_env_status`
--
ALTER TABLE `bm__app_env_status`
  ADD CONSTRAINT `fk_bm_env_status_env` FOREIGN KEY (`id_app_env`) REFERENCES `bm__app_env` (`id`) ON DELETE CASCADE;

--
-- Limiti per la tabella `bm__backup_job`
--
ALTER TABLE `bm__backup_job`
  ADD CONSTRAINT `fk_bm_backup_job_env` FOREIGN KEY (`id_app_env`) REFERENCES `bm__app_env` (`id`) ON DELETE CASCADE;

--
-- Limiti per la tabella `bm__backup_log`
--
ALTER TABLE `bm__backup_log`
  ADD CONSTRAINT `fk_bm_backup_log_job` FOREIGN KEY (`id_backup_job`) REFERENCES `bm__backup_job` (`id`) ON DELETE CASCADE;

--
-- Limiti per la tabella `bm__credential_link`
--
ALTER TABLE `bm__credential_link`
  ADD CONSTRAINT `fk_bm_credential_link_credential` FOREIGN KEY (`id_credential`) REFERENCES `bm__credential` (`id`) ON DELETE CASCADE;

--
-- Limiti per la tabella `bm__deploy_log`
--
ALTER TABLE `bm__deploy_log`
  ADD CONSTRAINT `fk_bm_deploy_log_env` FOREIGN KEY (`id_app_env`) REFERENCES `bm__app_env` (`id`) ON DELETE CASCADE;

--
-- Limiti per la tabella `bm__migration`
--
ALTER TABLE `bm__migration`
  ADD CONSTRAINT `fk_bm_migration_app` FOREIGN KEY (`id_applicazione`) REFERENCES `bm__applicazioni` (`id`) ON DELETE CASCADE;
COMMIT;

