diff --git a/include/upgrade.inc.php b/include/upgrade.inc.php
new file mode 100644
index 000000000..877a5f32d
--- /dev/null
+++ b/include/upgrade.inc.php
@@ -0,0 +1,107 @@
+
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief Upgrade all the database : the central repository , the templates and
+ * the folder
+ * @param $rep db connection to central repository
+ */
+?>
+
+
+exec_sql("select dos_id, dos_name from ac_dossier");
+ $MaxDossier=$rep->size($Resdossier);
+
+ //----------------------------------------------------------------------
+ // Upgrade the folders
+ //----------------------------------------------------------------------
+ for ($e=0; $e<$MaxDossier; $e++)
+ {
+ $db_row=Database::fetch_array($Resdossier, $e);
+ echo "Patching ".$db_row['dos_name'].'
';
+
+ $name=$rep->format_name($db_row['dos_id'], 'dos');
+
+ if ($rep->exist_database($name)>0)
+ {
+ $db=new Database($db_row['dos_id'], 'dos');
+ $db->apply_patch($db_row['dos_name']);
+ Dossier::synchro_admin($db_row['dos_id']);
+ }
+ else
+ {
+ echo_warning(_("Dossier inexistant")." $name");
+ }
+ }
+
+ //----------------------------------------------------------------------
+ // Upgrade the template
+ //----------------------------------------------------------------------
+ $Resdossier=$rep->exec_sql("select mod_id, mod_name from modeledef");
+ $MaxDossier=$rep->size();
+ echo ""._("Mise à modèle")."
";
+
+ for ($e=0; $e<$MaxDossier; $e++)
+ {
+ $db_row=Database::fetch_array($Resdossier, $e);
+ echo "Patching ".$db_row['mod_name']."
";
+ $name=$rep->format_name($db_row['mod_id'], 'mod');
+
+ if ($rep->exist_database($name)>0)
+ {
+ $db=new Database($db_row['mod_id'], 'mod');
+ $db->apply_patch($db_row['mod_name']);
+ }
+ else
+ {
+ echo_warning(_("Modèle inexistant")." $name");
+ }
+ }
+ //----------------------------------------------------------------------
+ // Upgrade the account_repository
+ //----------------------------------------------------------------------
+ echo ""._("Mise à jour de la base de données principale")."
";
+ $cn=new Database();
+ if (DEBUG==false)
+ ob_start();
+ $MaxVersion=DBVERSIONREPO-1;
+ for ($i=4; $i<=$MaxVersion; $i++)
+ {
+ if ($cn->get_version()<=$i)
+ {
+ $cn->execute_script('sql/patch/ac-upgrade'.$i.'.sql');
+ }
+ }
+}
+?>