diff --git a/apps/maarch_entreprise/xml/config.json.default b/apps/maarch_entreprise/xml/config.json.default
index 94ca75bfc76a14bb4d29c2eb13d18d071aa4ffc5..ef69b76715aed068a7756b5bd1f7e007c3b05b2b 100644
--- a/apps/maarch_entreprise/xml/config.json.default
+++ b/apps/maarch_entreprise/xml/config.json.default
@@ -26,5 +26,37 @@
         "refusedStatus": "REJ_SIGN",
         "validatedStatusAnnot": "COU",
         "refusedStatusAnnot": "RET"
+    },
+    "exportSeda": {
+        "sae": "MaarchRM",
+        "token": "phdF9WkJuTKkDuPXoqDZuCFEQT7En7YqsVROsdD1HoPlOsmSRZeZKpl6weZd+/0momU9JodKUyZDzvLCWOZ1sw==",
+        "urlSAEService": "http://demo-ap.maarchrm.com:81",
+        "senderOrgRegNumber": "org_987654321_DGS_SA",
+        "accessRuleCode": "AR039",
+        "certificateSSL": "",
+        "userAgent": "service",
+        "externalSAE": {
+            "retentionRules": [
+                {
+                    "id": "id1",
+                    "label": "label1"
+                }
+            ],
+            "archiveEntities": [
+                {
+                    "id": "id1",
+                    "label": "label1"
+                }
+            ],
+            "archivalAgreements": [
+                {
+                    "id": "id1",
+                    "label": "label1"
+                }
+            ]
+        },
+        "M2M": {
+            "gec": "maarch_courrier"
+        }
     }
 }
diff --git a/bin/exportSeda/batch_tools.php b/bin/exportSeda/batch_tools.php
new file mode 100644
index 0000000000000000000000000000000000000000..a08645906e8d9fc45be8361d4e9bbbdcebca3e4e
--- /dev/null
+++ b/bin/exportSeda/batch_tools.php
@@ -0,0 +1,197 @@
+<?php
+
+/**
+* Copyright Maarch since 2008 under licence GPLv3.
+* See LICENCE.txt file at the root folder for more details.
+* This file is part of Maarch software.
+*
+*/
+
+/**
+ * @brief API to manage batchs
+ *
+ * @file
+ * @author <dev@maarch.org>
+ * @date $date$
+ * @version $Revision$
+ */
+
+/**
+ * Exit the batch with a return code, message in the log and
+ * in the database if necessary
+ *
+ * @param int $returnCode code to exit (if > O error)
+ * @param string $message message to the log and the DB
+ * @return nothing exit the program
+ */
+function Bt_exitBatch($returnCode, $message='')
+{
+    if (file_exists($GLOBALS['lckFile'])) {
+        unlink($GLOBALS['lckFile']);
+    }
+    if ($returnCode > 0) {
+        $GLOBALS['totalProcessedResources']--;
+        if ($GLOBALS['totalProcessedResources'] == -1) {
+            $GLOBALS['totalProcessedResources'] = 0;
+        }
+        if ($returnCode < 100) {
+            if (file_exists($GLOBALS['errorLckFile'])) {
+                unlink($GLOBALS['errorLckFile']);
+            }
+            $semaphore = fopen($GLOBALS['errorLckFile'], "a");
+            fwrite($semaphore, '1');
+            fclose($semaphore);
+        }
+        Bt_writeLog(['level' => 'ERROR', 'message' => $message]);
+        Bt_logInDataBase($GLOBALS['totalProcessedResources'], 1, $message.' (return code: '. $returnCode.')');
+    } elseif ($message <> '') {
+        Bt_writeLog(['level' => 'INFO', 'message' => $message]);
+        Bt_logInDataBase($GLOBALS['totalProcessedResources'], 0, $message.' (return code: '. $returnCode.')');
+    }
+    Bt_updateWorkBatch();
+    exit($returnCode);
+}
+
+/**
+* Insert in the database the report of the batch
+* @param long $totalProcessed total of resources processed in the batch
+* @param long $totalErrors total of errors in the batch
+* @param string $info message in db
+*/
+function Bt_logInDataBase($totalProcessed=0, $totalErrors=0, $info='')
+{
+    \History\models\BatchHistoryModel::create([
+        'module_name'     => $GLOBALS['batchName'],
+        'batch_id'        => $GLOBALS['wb'],
+        'info'            => substr(str_replace('\\', '\\\\', str_replace("'", "`", $info)), 0, 999),
+        'total_processed' => $totalProcessed,
+        'total_errors'    => $totalErrors
+    ]);
+}
+
+
+/**
+* Insert in the database a line for history
+*/
+function Bt_history($aArgs = [])
+{
+    $user = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ["user_id='superadmin' desc"], 'limit' => 1]);
+    \History\controllers\HistoryController::add([
+        'tableName'    => $aArgs['table_name'],
+        'recordId'     => $aArgs['record_id'],
+        'eventType'    => $aArgs['event_type'],
+        'eventId'      => $aArgs['event_id'],
+        'userId'       => $user[0]['id'],
+        'info'         => $aArgs['info']
+    ]);
+}
+
+/**
+ * Get the batch if of the batch
+ *
+ * @return nothing
+ */
+function Bt_getWorkBatch()
+{
+    $parameter = \Parameter\models\ParameterModel::getById(['select' => ['param_value_int'], 'id' => $GLOBALS['batchName']."_id"]);
+    if (!empty($parameter)) {
+        $GLOBALS['wb'] = $parameter['param_value_int'] + 1;
+    } else {
+        \Parameter\models\ParameterModel::create(['id' => $GLOBALS['batchName']."_id", 'param_value_int' => 1]);
+        $GLOBALS['wb'] = 1;
+    }
+}
+
+/**
+ * Update the database with the new batch id of the batch
+ *
+ * @return nothing
+ */
+function Bt_updateWorkBatch()
+{
+    \Parameter\models\ParameterModel::update(['id' => $GLOBALS['batchName']."_id", 'param_value_int' => $GLOBALS['wb']]);
+}
+
+/**
+ * Include the file requested if exists
+ *
+ * @param string $file path of the file to include
+ * @return nothing
+ */
+function Bt_myInclude($file)
+{
+    if (file_exists($file)) {
+        include_once($file);
+    } else {
+        throw new IncludeFileError($file);
+    }
+}
+
+function Bt_writeLog($args = [])
+{
+    \SrcCore\controllers\LogsController::add([
+        'isTech'    => true,
+        'moduleId'  => $GLOBALS['batchName'],
+        'level'     => $args['level'],
+        'tableName' => '',
+        'recordId'  => $GLOBALS['batchName'],
+        'eventType' => $GLOBALS['batchName'],
+        'eventId'   => $args['message']
+    ]);
+}
+
+function Bt_createAttachment($args = [])
+{
+    $opts = [
+        CURLOPT_URL => rtrim($GLOBALS['applicationUrl'], "/") . '/rest/attachments',
+        CURLOPT_HTTPHEADER => [
+            'accept:application/json',
+            'content-type:application/json',
+            'Authorization: Basic ' . base64_encode($GLOBALS['userWS']. ':' .$GLOBALS['passwordWS']),
+        ],
+        CURLOPT_RETURNTRANSFER => true,
+        CURLOPT_SSL_VERIFYPEER => false,
+        CURLOPT_POSTFIELDS => json_encode($args),
+        CURLOPT_POST => true
+    ];
+
+    $curl = curl_init();
+    curl_setopt_array($curl, $opts);
+    $rawResponse = curl_exec($curl);
+    $error       = curl_error($curl);
+    if (!empty($error)) {
+        Bt_writeLog(['level' => 'ERROR', 'message' => $error]);
+        exit;
+    }
+
+    $return = json_decode($rawResponse, true);
+    if (!empty($return['errors'])) {
+        Bt_writeLog(['level' => 'ERROR', 'message' => $return['errors']]);
+        exit;
+    }
+
+    return $return;
+}
+
+function Bt_getReply($args = [])
+{
+    $refEncode = str_replace('.', '%2E', urlencode($args['reference']));
+    $curlResponse = \SrcCore\models\CurlModel::execSimple([
+        'url'     => rtrim($GLOBALS['urlSAEService'], '/') . '/medona/message/reference?reference=' . $refEncode,
+        'method'  => 'GET',
+        'cookie'  => 'LAABS-AUTH=' . urlencode($GLOBALS['token']),
+        'headers' => [
+            'Accept: application/json',
+            'Content-Type: application/json',
+            'User-Agent: ' . $GLOBALS['userAgent']
+        ]
+    ]);
+
+    if (!empty($curlResponse['errors'])) {
+        return ['errors' => 'Error returned by the route /organization/organization/Search : ' . $curlResponse['errors']];
+    } elseif ($curlResponse['code'] != 200) {
+        return ['errors' => 'Error returned by the route /organization/organization/Search : ' . $curlResponse['response']['message']];
+    }
+
+    return ['response' => $curlResponse['response']];
+}
diff --git a/bin/exportSeda/checkAllReplies.php b/bin/exportSeda/checkAllReplies.php
new file mode 100755
index 0000000000000000000000000000000000000000..d445f23d99b21aa94297d391505f49ef64c64636
--- /dev/null
+++ b/bin/exportSeda/checkAllReplies.php
@@ -0,0 +1,177 @@
+<?php
+
+/**
+* Copyright Maarch since 2008 under licence GPLv3.
+* See LICENCE.txt file at the root folder for more details.
+* This file is part of Maarch software.
+*
+*/
+
+/**
+ * @brief Check all replies in record management system
+ * @author dev@maarch.org
+ */
+
+/**
+* @brief  Class to include the file error
+*
+*/
+class IncludeFileError extends Exception
+{
+    public function __construct($file)
+    {
+        $this->file = $file;
+        parent :: __construct('Include File \'$file\' is missing!', 1);
+    }
+}
+
+// Globals variables definition
+$GLOBALS['batchName']    = 'checkAllRepliesFromArchivingSystem';
+$GLOBALS['wb']           = '';
+$totalProcessedResources = 0;
+
+// Load tools
+include('batch_tools.php');
+
+$options = getopt("c:", ["config:"]);
+if (empty($options['c']) && empty($options['config'])) {
+    print("Configuration file missing\n");
+    exit(101);
+} elseif (!empty($options['c']) && empty($options['config'])) {
+    $options['config'] = $options['c'];
+    unset($options['c']);
+}
+
+$txt = '';
+foreach (array_keys($options) as $key) {
+    if (isset($options[$key]) && $options[$key] == false) {
+        $txt .= $key . '=false,';
+    } else {
+        $txt .= $key . '=' . $options[$key] . ',';
+    }
+}
+print($txt . "\n");
+$GLOBALS['configFile'] = $options['config'];
+
+print("Load json config file:" . $GLOBALS['configFile'] . "\n");
+// Tests existence of config file
+if (!file_exists($GLOBALS['configFile'])) {
+    print(
+        "Configuration file " . $GLOBALS['configFile']
+        . " does not exist\n"
+    );
+    exit(102);
+}
+
+$file = file_get_contents($GLOBALS['configFile']);
+$file = json_decode($file, true);
+
+if (empty($file)) {
+    print("Error on loading config file:" . $GLOBALS['configFile'] . "\n");
+    exit(103);
+}
+
+// Load config
+$config = $file['config'];
+$GLOBALS['MaarchDirectory'] = $config['maarchDirectory'];
+$GLOBALS['customId']        = $config['customID'];
+$GLOBALS['applicationUrl']  = $config['maarchUrl'];
+$GLOBALS['batchDirectory']  = $GLOBALS['MaarchDirectory'] . 'bin/exportSeda';
+
+$config = $file['exportSeda'];
+$GLOBALS['sae']                 = $config['sae'];
+$GLOBALS['token']               = $config['token'];
+$GLOBALS['userAgent']           = $config['userAgent'];
+$GLOBALS['urlSAEService']       = $config['urlSAEService'];
+$GLOBALS['certificateSSL']      = $config['certificateSSL'];
+$GLOBALS['statusReplyReceived'] = $config['statusReplyReceived'];
+
+chdir($GLOBALS['MaarchDirectory']);
+
+set_include_path(get_include_path() . PATH_SEPARATOR . $GLOBALS['MaarchDirectory']);
+
+try {
+    Bt_myInclude($GLOBALS['MaarchDirectory'] . 'vendor/autoload.php');
+} catch (IncludeFileError $e) {
+    Bt_writeLog(['level' => 'ERROR', 'message' => 'Problem with the php include path:' .$e .' '. get_include_path()]);
+    exit();
+}
+
+\SrcCore\models\DatabasePDO::reset();
+new \SrcCore\models\DatabasePDO(['customId' => $GLOBALS['customId']]);
+
+$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR . $GLOBALS['batchName'] .'_error.lck';
+$GLOBALS['lckFile']      = $GLOBALS['batchDirectory'] . DIRECTORY_SEPARATOR . $GLOBALS['batchName'] . '.lck';
+
+if (file_exists($GLOBALS['errorLckFile'])) {
+    Bt_writeLog(['level' => 'ERROR', 'message' => 'Error persists, please solve this before launching a new batch']);
+    exit(13);
+}
+
+Bt_getWorkBatch();
+
+Bt_writeLog(['level' => 'INFO', 'message' => 'Retrieve mail sent to archiving system']);
+
+$acknowledgements = \Attachment\models\AttachmentModel::get([
+    'select' => ['res_id_master'],
+    'where'  => ['attachment_type = ?'],
+    'data'   => ['acknowledgement_record_management']
+]);
+$acknowledgements = array_column($acknowledgements, 'res_id_master');
+
+$replies = \Attachment\models\AttachmentModel::get([
+    'select' => ['res_id_master'],
+    'where'  => ['attachment_type = ?'],
+    'data'   => ['reply_record_management']
+]);
+$replies = array_column($replies, 'res_id_master');
+$pendingResources = array_diff($acknowledgements, $replies);
+
+$unitIdentifiers = [];
+foreach ($pendingResources as $resId) {
+    $unitIdentifier = \MessageExchange\models\MessageExchangeModel::getUnitIdentifierByResId(['select' => ['message_id', 'res_id'], 'resId' => (string)$resId]);
+    if (empty($unitIdentifier[0]['message_id'])) {
+        continue;
+    }
+    $message = \MessageExchange\models\MessageExchangeModel::getMessageByIdentifier(['select' => ['reference'], 'messageId' => $unitIdentifier[0]['message_id']]);
+
+    if (array_key_exists($message['reference'], $unitIdentifiers)) {
+        $unitIdentifiers[$message['reference']] .= "," . $unitIdentifier[0]['res_id'];
+    } else {
+        $unitIdentifiers[$message['reference']] = $unitIdentifier[0]['res_id'];
+    }
+
+    foreach ($unitIdentifiers as $reference => $value) {
+        $messages = Bt_getReply(['reference' => $reference]);
+        if (!empty($messages['errors'])) {
+            Bt_writeLog(['level' => 'ERROR', 'message' => $messages['errors']]);
+        }
+
+        if (!isset($messages['response']['replyMessage'])) {
+            continue;
+        }
+
+        //créer message reply & sauvegarder xml
+        $resIds = explode(',', $value);
+        $data   = json_decode($messages->replyMessage->data);
+
+        // TODO save reply
+        // $archiveTransferReply = new ArchiveTransferReply();
+        // $archiveTransferReply->receive($data, $resIds);
+        foreach ($resIds as $resId) {
+            \Resource\models\ResModel::update([
+                'set'   => ['status' => $GLOBALS['statusReplyReceived']],
+                'where' => ['res_id = ?'],
+                'data'  => [$resId]
+            ]);
+        }
+    }
+}
+
+Bt_writeLog(['level' => 'INFO', 'message' => 'End of process']);
+Bt_writeLog(['level' => 'INFO', 'message' => $nbMailsRetrieved.' document(s) retrieved']);
+
+Bt_logInDataBase($nbMailsRetrieved, $err, $nbMailsRetrieved.' replie(s) retrieved from archiving system');
+Bt_updateWorkBatch();
+
+exit($GLOBALS['exitCode']);
diff --git a/bin/exportSeda/scripts/checkAllReplies.sh.default b/bin/exportSeda/scripts/checkAllReplies.sh.default
new file mode 100755
index 0000000000000000000000000000000000000000..43ff8f79a0b616e017ac941932503842991da950
--- /dev/null
+++ b/bin/exportSeda/scripts/checkAllReplies.sh.default
@@ -0,0 +1,4 @@
+#!/bin/sh
+cd /var/www/html/MaarchCourrier/bin/exportSeda/
+filePath='/var/www/html/MaarchCourrier/bin/exportSeda/checkAllReplies.php'
+php $filePath -c /var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/config.json
diff --git a/migration/18.04/1804.sql b/migration/18.04/1804.sql
deleted file mode 100644
index 8d4801b839c2bcb414cabefc0c1ee0d2cf1abba4..0000000000000000000000000000000000000000
--- a/migration/18.04/1804.sql
+++ /dev/null
@@ -1,802 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 17.06 to 18.04                                  --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
-DROP VIEW IF EXISTS view_postindexing;
-DROP VIEW IF EXISTS res_view_attachments;
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS view_contacts;
-DROP TABLE IF EXISTS ar_batch;
-
-DROP SEQUENCE IF EXISTS priorities_seq CASCADE;
-
-DROP TABLE IF EXISTS priorities;
-CREATE TABLE priorities
-(
-  id character varying(16) NOT NULL,
-  label character varying(128) NOT NULL,
-  color character varying(128) NOT NULL,
-  working_days boolean NOT NULL,
-  delays integer,
-  default_priority boolean NOT NULL DEFAULT FALSE,
-  "order" integer,
-  CONSTRAINT priorities_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-
-DROP TABLE IF EXISTS status_images;
-CREATE TABLE status_images
-(
-  id serial,
-  image_name character varying(128) NOT NULL,
-  CONSTRAINT status_images_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-new');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-inprogress');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-info');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-wait');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-validated');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-rejected');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-end');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-newmail');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-attr');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-arev');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aval');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aimp');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-imp');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aenv');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-acla');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-status-aarch');
-INSERT INTO status_images (image_name) VALUES ('fm-letter');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-add');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-search');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-del');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-incoming');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-outgoing');
-INSERT INTO status_images (image_name) VALUES ('fm-letter-internal');
-INSERT INTO status_images (image_name) VALUES ('fm-file-fingerprint');
-INSERT INTO status_images (image_name) VALUES ('fm-classification-plan-l1');
-
-
-ALTER TABLE status DROP COLUMN IF EXISTS identifier;
-ALTER TABLE status ADD COLUMN identifier serial;
-
-ALTER TABLE users DROP COLUMN IF EXISTS signature_path;
-ALTER TABLE users DROP COLUMN IF EXISTS signature_file_name;
-ALTER TABLE users DROP COLUMN IF EXISTS docserver_location_id;
-ALTER TABLE users DROP COLUMN IF EXISTS delay_number;
-ALTER TABLE users DROP COLUMN IF EXISTS department;
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'users') AND attname = 'id') = 0 THEN
-    ALTER TABLE users ADD COLUMN id serial;
-    ALTER TABLE users ADD UNIQUE (id);
-  END IF;
-END$$;
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'user_signatures') AND attname = 'user_id') THEN
-    ALTER TABLE user_signatures DROP COLUMN IF EXISTS user_serial_id;
-    ALTER TABLE user_signatures ADD COLUMN user_serial_id integer;
-    UPDATE user_signatures set user_serial_id = (select id FROM users where users.user_id = user_signatures.user_id);
-    DELETE from user_signatures where user_serial_id is NULL;
-    ALTER TABLE user_signatures ALTER COLUMN user_serial_id set not null;
-    ALTER TABLE user_signatures DROP COLUMN IF EXISTS user_id;
-  END IF;
-END$$;
-
-ALTER TABLE usergroups DROP COLUMN IF EXISTS administrator;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS custom_right1;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS custom_right2;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS custom_right3;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS custom_right4;
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'usergroups') AND attname = 'id') = 0 THEN
-    ALTER TABLE usergroups ADD COLUMN id serial NOT NULL;
-    ALTER TABLE usergroups ADD UNIQUE (id);
-  END IF;
-END$$;
-
-
-ALTER TABLE sendmail DROP COLUMN IF EXISTS res_version_att_id_list;
-ALTER TABLE sendmail ADD COLUMN res_version_att_id_list character varying(255);
-
-/*SALT*/
-UPDATE users set password = '$2y$10$C.QSslBKD3yNMfRPuZfcaubFwPKiCkqqOUyAdOr5FSGKPaePwuEjG', change_password = 'Y' WHERE user_id != 'superadmin';
-UPDATE users set password = '$2y$10$Vq244c5s2zmldjblmMXEN./Q2qZrqtGVgrbz/l1WfsUJbLco4E.e.' where user_id = 'superadmin';
-
-/*BASKETS COLOR*/
-ALTER TABLE baskets DROP COLUMN IF EXISTS color;
-ALTER TABLE baskets ADD color character varying(16);
-DROP TABLE IF EXISTS users_baskets;
-CREATE TABLE users_baskets
-(
-  id serial NOT NULL,
-  user_serial_id integer NOT NULL,
-  basket_id character varying(32) NOT NULL,
-  group_id character varying(32) NOT NULL,
-  color character varying(16),
-  CONSTRAINT users_baskets_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-/*ENTITIES FULL NAME*/
-ALTER TABLE entities DROP COLUMN IF EXISTS entity_full_name;
-ALTER TABLE entities ADD entity_full_name text;
-
-ALTER TABLE entities DROP COLUMN IF EXISTS archival_agency;
-ALTER TABLE entities ADD COLUMN archival_agency character varying(255) DEFAULT 'org_123456789_Archives';
-
-/*PERFS ON VIEW*/
-DROP VIEW IF EXISTS res_view_letterbox;
-
-/* Alter table here because view depends on it*/
-ALTER TABLE res_letterbox ALTER COLUMN priority TYPE character varying(16);
-ALTER TABLE res_attachments ALTER COLUMN priority TYPE character varying(16);
-ALTER TABLE res_x ALTER COLUMN priority TYPE character varying(16);
-ALTER TABLE res_version_attachments ALTER COLUMN priority TYPE character varying(16);
-ALTER TABLE res_version_letterbox ALTER COLUMN priority TYPE character varying(16);
-ALTER TABLE res_version_x ALTER COLUMN priority TYPE character varying(16);
-
---ALTER TABLE for external infos webservice
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_id;
-ALTER TABLE res_letterbox ADD COLUMN external_id character varying(255);
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_link;
-ALTER TABLE res_letterbox ADD COLUMN external_link character varying(255);
-
-CREATE OR REPLACE VIEW res_view_letterbox AS 
- SELECT r.tablename,
-    r.is_multi_docservers,
-    r.res_id,
-    r.type_id,
-    r.policy_id,
-    r.cycle_id,
-    d.description AS type_label,
-    d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label,
-    dfl.css_style AS doctype_first_level_style,
-    d.doctypes_second_level_id,
-    dsl.doctypes_second_level_label,
-    dsl.css_style AS doctype_second_level_style,
-    r.format,
-    r.typist,
-    r.creation_date,
-    r.modification_date,
-    r.relation,
-    r.docserver_id,
-    r.folders_system_id,
-    f.folder_id,
-    f.destination AS folder_destination,
-    f.is_frozen AS folder_is_frozen,
-    r.path,
-    r.filename,
-    r.fingerprint,
-    r.offset_doc,
-    r.filesize,
-    r.status,
-    r.work_batch,
-    r.arbatch_id,
-    r.arbox_id,
-    r.page_count,
-    r.is_paper,
-    r.doc_date,
-    r.scan_date,
-    r.scan_user,
-    r.scan_location,
-    r.scan_wkstation,
-    r.scan_batch,
-    r.doc_language,
-    r.description,
-    r.source,
-    r.author,
-    r.reference_number,
-    r.external_id,
-    r.external_link,
-    r.custom_t1 AS doc_custom_t1,
-    r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3,
-    r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5,
-    r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7,
-    r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9,
-    r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11,
-    r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13,
-    r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15,
-    r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2,
-    r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4,
-    r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6,
-    r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8,
-    r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10,
-    r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2,
-    r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4,
-    r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1,
-    r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3,
-    r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5,
-    f.foldertype_id,
-    ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1,
-    f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3,
-    f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5,
-    f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7,
-    f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9,
-    f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11,
-    f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13,
-    f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15,
-    f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2,
-    f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4,
-    f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6,
-    f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8,
-    f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10,
-    f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2,
-    f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4,
-    f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1,
-    f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3,
-    f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5,
-    f.is_complete AS fold_complete,
-    f.status AS fold_status,
-    f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id,
-    f.folder_level,
-    f.folder_name,
-    f.creation_date AS fold_creation_date,
-    r.initiator,
-    r.destination,
-    r.dest_user,
-    r.confidentiality,
-    mlb.category_id,
-    mlb.exp_contact_id,
-    mlb.exp_user_id,
-    mlb.dest_user_id,
-    mlb.dest_contact_id,
-    mlb.address_id,
-    mlb.nature_id,
-    mlb.alt_identifier,
-    mlb.admission_date,
-    mlb.answer_type_bitmask,
-    mlb.other_answer_desc,
-    mlb.sve_start_date,
-    mlb.sve_identifier,
-    mlb.process_limit_date,
-    mlb.recommendation_limit_date,
-    mlb.closing_date,
-    mlb.alarm1_date,
-    mlb.alarm2_date,
-    mlb.flag_notif,
-    mlb.flag_alarm1,
-    mlb.flag_alarm2,
-    mlb.is_multicontacts,
-    r.video_user,
-    r.video_time,
-    r.video_batch,
-    r.subject,
-    r.identifier,
-    r.title,
-    r.priority,
-    mlb.process_notes,
-    r.locker_user_id,
-    r.locker_time,
-    ca.case_id,
-    ca.case_label,
-    ca.case_description,
-    en.entity_label,
-    en.entity_type AS entitytype,
-    cont.contact_id,
-    cont.firstname AS contact_firstname,
-    cont.lastname AS contact_lastname,
-    cont.society AS contact_society,
-    u.lastname AS user_lastname,
-    u.firstname AS user_firstname,
-    r.is_frozen AS res_is_frozen
-   FROM doctypes d,
-    doctypes_first_level dfl,
-    doctypes_second_level dsl,
-    res_letterbox r
-     LEFT JOIN entities en ON r.destination::text = en.entity_id::text
-     LEFT JOIN folders f ON r.folders_system_id = f.folders_system_id
-     LEFT JOIN cases_res cr ON r.res_id = cr.res_id
-     LEFT JOIN mlb_coll_ext mlb ON mlb.res_id = r.res_id
-     LEFT JOIN foldertypes ft ON f.foldertype_id = ft.foldertype_id AND f.status::text <> 'DEL'::text
-     LEFT JOIN cases ca ON cr.case_id = ca.case_id
-     LEFT JOIN contacts_v2 cont ON mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id
-     LEFT JOIN users u ON mlb.exp_user_id::text = u.user_id::text OR mlb.dest_user_id::text = u.user_id::text
-  WHERE r.type_id = d.type_id AND d.doctypes_first_level_id = dfl.doctypes_first_level_id AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-ALTER TABLE baskets DROP COLUMN IF EXISTS color;
-ALTER TABLE baskets ADD color character varying(16);
-
-/*SIGNATURE BOOK*/
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS in_signature_book;
-ALTER TABLE res_attachments ADD in_signature_book boolean default false;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS in_signature_book;
-ALTER TABLE res_version_attachments ADD in_signature_book boolean default false;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS signatory_user_serial_id;
-ALTER TABLE res_attachments ADD signatory_user_serial_id int;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS signatory_user_serial_id;
-ALTER TABLE res_version_attachments ADD signatory_user_serial_id int;
-ALTER TABLE listinstance DROP COLUMN IF EXISTS signatory;
-ALTER TABLE listinstance ADD signatory boolean default false;
-ALTER TABLE listinstance DROP COLUMN IF EXISTS requested_signature;
-ALTER TABLE listinstance ADD requested_signature boolean default false;
-
-CREATE VIEW res_view_attachments AS
-  SELECT '0' as res_id, res_id as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-    creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-    doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-    filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-    scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-    envelop_id, status, destination, approver, validation_date, effective_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-    coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master, in_signature_book, signatory_user_serial_id
-  FROM res_version_attachments
-  UNION ALL
-  SELECT res_id, '0' as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-    creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-    doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-    filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-    scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-    envelop_id, status, destination, approver, validation_date, effective_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-    coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book, signatory_user_serial_id
-  FROM res_attachments;
-
-UPDATE res_attachments SET in_signature_book = TRUE;
-UPDATE res_version_attachments SET in_signature_book = TRUE;
-UPDATE listinstance SET requested_signature = TRUE WHERE item_mode = 'sign';
-UPDATE listinstance SET signatory = TRUE WHERE item_mode = 'sign' AND process_date is not null;
-UPDATE listinstance SET signatory = FALSE WHERE item_mode = 'sign' AND process_date is null;
-
-ALTER TABLE notif_event_stack ALTER COLUMN record_id TYPE character varying(128);
-
-/*BASKETS*/
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS sequence;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS redirect_basketlist;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS redirect_grouplist;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS can_redirect;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS can_delete;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS can_insert;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS list_lock_clause;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS sublist_lock_clause;
-DROP TABLE IF EXISTS groupbasket_difflist_types;
-DROP TABLE IF EXISTS groupbasket_difflist_roles;
-
-UPDATE actions_groupbaskets SET used_in_action_page = 'Y', used_in_basketlist = 'Y' WHERE used_in_action_page = 'N' and used_in_basketlist = 'N' and default_action_list = 'Y';
-UPDATE actions_groupbaskets SET used_in_action_page = 'Y' WHERE used_in_action_page = 'N' and used_in_basketlist = 'N' and default_action_list = 'N';
-
-/*LISTMODELS*/
-ALTER TABLE listmodels DROP COLUMN IF EXISTS listmodel_type;
-ALTER TABLE listmodels DROP COLUMN IF EXISTS coll_id;
-
-ALTER TABLE listmodels DROP COLUMN IF EXISTS id;
-ALTER TABLE listmodels ADD id serial NOT NULL;
-
-UPDATE listmodels SET title = description WHERE title = '' OR title ISNULL;
-
-
-DROP TABLE IF EXISTS indexingmodels;
-CREATE TABLE indexingmodels
-(
-  id serial NOT NULL,
-  label character varying(255) NOT NULL,
-  fields_content text NOT NULL,
-  CONSTRAINT indexingmodels_pkey PRIMARY KEY (id)
-)
-WITH (
-  OIDS=FALSE
-);
-
--- ************************************************************************* --
---                               CONVERT                             --
--- ************************************************************************* --
-
-
-ALTER TABLE adr_x DROP COLUMN IF EXISTS adr_type;
-ALTER TABLE adr_x ADD COLUMN adr_type character varying(32) NOT NULL DEFAULT 'DOC';
-ALTER TABLE adr_attachments DROP COLUMN IF EXISTS adr_type;
-ALTER TABLE adr_attachments ADD COLUMN adr_type character varying(32) NOT NULL DEFAULT 'DOC';
-
-
---convert result
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS convert_result;
-ALTER TABLE res_attachments ADD COLUMN convert_result character varying(10) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS convert_result;
-ALTER TABLE res_letterbox ADD COLUMN convert_result character varying(10) DEFAULT NULL::character varying;
-ALTER TABLE res_x DROP COLUMN IF EXISTS convert_result;
-ALTER TABLE res_x ADD COLUMN convert_result character varying(10) DEFAULT NULL::character varying;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS convert_result;
-ALTER TABLE res_version_attachments ADD COLUMN convert_result character varying(10) DEFAULT NULL::character varying;
-
-
---convert attempts
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS convert_attempts;
-ALTER TABLE res_attachments ADD COLUMN convert_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS convert_attempts;
-ALTER TABLE res_letterbox ADD COLUMN convert_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_x DROP COLUMN IF EXISTS convert_attempts;
-ALTER TABLE res_x ADD COLUMN convert_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS convert_attempts;
-ALTER TABLE res_version_attachments ADD COLUMN convert_attempts integer DEFAULT NULL::integer;
-
---fulltext attempts
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS fulltext_attempts;
-ALTER TABLE res_attachments ADD COLUMN fulltext_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS fulltext_attempts;
-ALTER TABLE res_letterbox ADD COLUMN fulltext_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_x DROP COLUMN IF EXISTS fulltext_attempts;
-ALTER TABLE res_x ADD COLUMN fulltext_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS fulltext_attempts;
-ALTER TABLE res_version_attachments ADD COLUMN fulltext_attempts integer DEFAULT NULL::integer;
-
---tnl attempts
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_attempts;
-ALTER TABLE res_attachments ADD COLUMN tnl_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_attempts;
-ALTER TABLE res_letterbox ADD COLUMN tnl_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_x DROP COLUMN IF EXISTS tnl_attempts;
-ALTER TABLE res_x ADD COLUMN tnl_attempts integer DEFAULT NULL::integer;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS tnl_attempts;
-ALTER TABLE res_version_attachments ADD COLUMN tnl_attempts integer DEFAULT NULL::integer;
-
-
-
---thumbnails result
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_result;
-ALTER TABLE res_attachments ADD COLUMN tnl_result character varying(10) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_result;
-ALTER TABLE res_letterbox ADD COLUMN tnl_result character varying(10) DEFAULT NULL::character varying;
-ALTER TABLE res_x DROP COLUMN IF EXISTS tnl_result;
-ALTER TABLE res_x ADD COLUMN tnl_result character varying(10) DEFAULT NULL::character varying;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS tnl_result;
-ALTER TABLE res_version_attachments ADD COLUMN tnl_result character varying(10) DEFAULT NULL::character varying;
-
--- adr_letterbox
-DROP TABLE IF EXISTS adr_letterbox;
-CREATE TABLE adr_letterbox
-(
-  res_id bigint NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) DEFAULT NULL::character varying,
-  filename character varying(255) DEFAULT NULL::character varying,
-  offset_doc character varying(255) DEFAULT NULL::character varying,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  adr_priority integer NOT NULL,
-  adr_type character varying(32) NOT NULL DEFAULT 'DOC'::character varying,
-  CONSTRAINT adr_letterbox_pkey PRIMARY KEY (res_id, docserver_id)
-)
-WITH (OIDS=FALSE);
-
--- adr_attachments
-DROP TABLE IF EXISTS adr_attachments;
-CREATE TABLE adr_attachments
-(
-  res_id bigint NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) DEFAULT NULL::character varying,
-  filename character varying(255) DEFAULT NULL::character varying,
-  offset_doc character varying(255) DEFAULT NULL::character varying,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  adr_priority integer NOT NULL,
-  adr_type character varying(32) NOT NULL DEFAULT 'DOC'::character varying,
-  CONSTRAINT adr_attachments_pkey PRIMARY KEY (res_id, docserver_id)
-)
-WITH (OIDS=FALSE);
-
--- adr_attachments_version
-DROP TABLE IF EXISTS adr_attachments_version;
-CREATE TABLE adr_attachments_version
-(
-  res_id bigint NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) DEFAULT NULL::character varying,
-  filename character varying(255) DEFAULT NULL::character varying,
-  offset_doc character varying(255) DEFAULT NULL::character varying,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  adr_priority integer NOT NULL,
-  adr_type character varying(32) NOT NULL DEFAULT 'DOC'::character varying,
-  CONSTRAINT adr_attachments_version_pkey PRIMARY KEY (res_id, docserver_id)
-)
-WITH (OIDS=FALSE);
-
--- convert working table
-DROP TABLE IF EXISTS convert_stack;
-CREATE TABLE convert_stack
-(
-  coll_id character varying(32) NOT NULL,
-  res_id bigint NOT NULL,
-  convert_format character varying(32) NOT NULL DEFAULT 'pdf'::character varying,
-  cnt_retry integer,
-  status character(1) NOT NULL,
-  work_batch bigint,
-  regex character varying(32),
-  CONSTRAINT convert_stack_pkey PRIMARY KEY (coll_id, res_id, convert_format)
-)
-WITH (OIDS=FALSE);
-
--- docservers
-UPDATE docservers set docserver_type_id = 'DOC' where docserver_type_id <> 'TEMPLATES' and docserver_type_id <> 'TNL';
-
-
-DELETE FROM docserver_types where docserver_type_id = 'DOC';
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled, is_container, container_max_number, is_compressed, compression_mode, is_meta, meta_template, is_logged, log_template, is_signed, fingerprint_mode) 
-VALUES ('DOC', 'Documents', 'Y', 'N', 0, 'N', 'NONE', 'N', 'NONE', 'N', 'NONE', 'Y', 'SHA512');
-
-DELETE FROM docserver_types where docserver_type_id = 'CONVERT';
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled, is_container, container_max_number, is_compressed, compression_mode, is_meta, meta_template, is_logged, log_template, is_signed, fingerprint_mode) 
-VALUES ('CONVERT', 'Conversions', 'Y', 'N', 0, 'N', 'NONE', 'N', 'NONE', 'N', 'NONE', 'Y', 'SHA256');
-
-DELETE FROM docservers where docserver_id = 'CONVERT_MLB';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('CONVERT_MLB', 'CONVERT', 'Server for mlb documents conversion', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/convert_mlb/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'letterbox_coll', 13, 'NANTERRE', 4);
-
-DELETE FROM docservers where docserver_id = 'FASTHD_ATTACH';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('FASTHD_ATTACH', 'FASTHD', 'Fast internal disc bay for attachments', 'N', 'Y', 50000000000, 1, '/opt/maarch/docservers/manual_attachments/', NULL, NULL, NULL, '2011-01-13 14:47:49.197164', NULL, 'attachments_coll', 2, 'NANTERRE', 3);
-
-DELETE FROM docservers where docserver_id = 'FASTHD_ATTACH_VERSION';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('FASTHD_ATTACH_VERSION', 'FASTHD', 'Fast internal disc bay for attachments version', 'N', 'Y', 50000000000, 1, '/opt/maarch/docservers/manual_attachments_version/', NULL, NULL, NULL, '2011-01-13 14:47:49.197164', NULL, 'attachments_version_coll', 100, 'NANTERRE', 100);
-
-DELETE FROM docservers where docserver_id = 'CONVERT_ATTACH';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('CONVERT_ATTACH', 'CONVERT', 'Server for attachments documents conversion', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/convert_attachments/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'attachments_coll', 14, 'NANTERRE', 5);
-
-DELETE FROM docservers where docserver_id = 'CONVERT_ATTACH_VERSION';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('CONVERT_ATTACH_VERSION', 'CONVERT', 'Server for attachments version documents conversion', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/convert_attachments_version/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'attachments_version_coll', 101, 'NANTERRE', 101);
-
--- for thumbnails, attachments and fulltext :
-DELETE FROM docservers where docserver_id = 'TNL_ATTACH';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('TNL_ATTACH', 'TNL', 'Server for thumbnails of attachments', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/thumbnails_attachments/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'attachments_coll', 15, 'NANTERRE', 6);
-
-DELETE FROM docservers where docserver_id = 'TNL_ATTACH_VERSION';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('TNL_ATTACH_VERSION', 'TNL', 'Server for thumbnails of attachments version', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/thumbnails_attachments_version/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'attachments_version_coll', 102, 'NANTERRE', 102);
-
-update docservers set docserver_id = 'TNL_MLB', priority_number = 12 where docserver_id = 'TNL';
-
-DELETE FROM docserver_types where docserver_type_id = 'FULLTEXT';
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled, is_container, container_max_number, is_compressed, compression_mode, is_meta, meta_template, is_logged, log_template, is_signed, fingerprint_mode) 
-VALUES ('FULLTEXT', 'FULLTEXT', 'Y', 'N', 0, 'N', 'NONE', 'N', 'NONE', 'N', 'NONE', 'Y', 'SHA256');
-
-DELETE FROM docservers where docserver_id = 'FULLTEXT_MLB';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('FULLTEXT_MLB', 'FULLTEXT', 'Server for mlb documents fulltext', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/fulltext_mlb/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'letterbox_coll', 16, 'NANTERRE', 7);
-
-DELETE FROM docservers where docserver_id = 'FULLTEXT_ATTACH';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('FULLTEXT_ATTACH', 'FULLTEXT', 'Server for attachments documents fulltext', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/fulltext_attachments/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'attachments_coll', 17, 'NANTERRE', 8);
-
-DELETE FROM docservers where docserver_id = 'FULLTEXT_ATTACH_VERSION';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('FULLTEXT_ATTACH_VERSION', 'FULLTEXT', 'Server for attachments version documents fulltext', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/fulltext_attachments_version/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'attachments_version_coll', 103, 'NANTERRE', 103);
-
-ALTER TABLE doctypes DROP COLUMN IF EXISTS primary_retention;
-ALTER TABLE doctypes DROP COLUMN IF EXISTS secondary_retention;
-ALTER TABLE doctypes DROP COLUMN IF EXISTS retention_final_disposition;
-ALTER TABLE doctypes ADD COLUMN retention_final_disposition character varying(255) DEFAULT NULL;
-ALTER TABLE doctypes DROP COLUMN IF EXISTS retention_rule;
-ALTER TABLE doctypes ADD COLUMN retention_rule character varying(15) DEFAULT NULL;
-ALTER TABLE doctypes DROP COLUMN IF EXISTS duration_current_use;
-ALTER TABLE doctypes ADD COLUMN duration_current_use integer DEFAULT NULL;
-ALTER TABLE entities DROP COLUMN IF EXISTS archival_agency;
-ALTER TABLE entities ADD COLUMN archival_agency character varying(255) DEFAULT 'org_123456789_Archives';
-ALTER TABLE entities DROP COLUMN IF EXISTS archival_agreement;
-ALTER TABLE entities ADD COLUMN archival_agreement character varying(255) DEFAULT 'MAARCH_LES_BAINS_ACTES';
-
-UPDATE listmodels SET title = description WHERE title = '' OR title ISNULL;
-
-UPDATE doctypes_first_level SET css_style = '#D2B48C' WHERE css_style = 'beige';
-UPDATE doctypes_first_level SET css_style = '#0000FF' WHERE css_style = 'blue_style';
-UPDATE doctypes_first_level SET css_style = '#0000FF' WHERE css_style = 'blue_style_big';
-UPDATE doctypes_first_level SET css_style = '#808080' WHERE css_style = 'grey_style';
-UPDATE doctypes_first_level SET css_style = '#FFFF00' WHERE css_style = 'yellow_style';
-UPDATE doctypes_first_level SET css_style = '#800000' WHERE css_style = 'brown_style';
-UPDATE doctypes_first_level SET css_style = '#000000' WHERE css_style = 'black_style';
-UPDATE doctypes_first_level SET css_style = '#000000' WHERE css_style = 'black_style_big';
-UPDATE doctypes_first_level SET css_style = '#FF4500' WHERE css_style = 'orange_style';
-UPDATE doctypes_first_level SET css_style = '#FF4500' WHERE css_style = 'orange_style_big';
-UPDATE doctypes_first_level SET css_style = '#FF00FF' WHERE css_style = 'pink_style';
-UPDATE doctypes_first_level SET css_style = '#FF0000' WHERE css_style = 'red_style';
-UPDATE doctypes_first_level SET css_style = '#008000' WHERE css_style = 'green_style';
-UPDATE doctypes_first_level SET css_style = '#800080' WHERE css_style = 'violet_style';
-UPDATE doctypes_first_level SET css_style = '#000000' WHERE css_style = 'default_style';
-
-UPDATE doctypes_second_level SET css_style = '#D2B48C' WHERE css_style = 'beige';
-UPDATE doctypes_second_level SET css_style = '#0000FF' WHERE css_style = 'blue_style';
-UPDATE doctypes_second_level SET css_style = '#0000FF' WHERE css_style = 'blue_style_big';
-UPDATE doctypes_second_level SET css_style = '#808080' WHERE css_style = 'grey_style';
-UPDATE doctypes_second_level SET css_style = '#FFFF00' WHERE css_style = 'yellow_style';
-UPDATE doctypes_second_level SET css_style = '#800000' WHERE css_style = 'brown_style';
-UPDATE doctypes_second_level SET css_style = '#000000' WHERE css_style = 'black_style';
-UPDATE doctypes_second_level SET css_style = '#000000' WHERE css_style = 'black_style_big';
-UPDATE doctypes_second_level SET css_style = '#FF4500' WHERE css_style = 'orange_style';
-UPDATE doctypes_second_level SET css_style = '#FF4500' WHERE css_style = 'orange_style_big';
-UPDATE doctypes_second_level SET css_style = '#FF00FF' WHERE css_style = 'pink_style';
-UPDATE doctypes_second_level SET css_style = '#FF0000' WHERE css_style = 'red_style';
-UPDATE doctypes_second_level SET css_style = '#008000' WHERE css_style = 'green_style';
-UPDATE doctypes_second_level SET css_style = '#800080' WHERE css_style = 'violet_style';
-UPDATE doctypes_second_level SET css_style = '#000000' WHERE css_style = 'default_style';
-
-DO $$ BEGIN
-  IF (SELECT count(TABLE_NAME)  FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'user_baskets_secondary') = 1 THEN
-    DROP TABLE IF EXISTS users_baskets_preferences;
-    CREATE TABLE users_baskets_preferences
-    (
-      id serial NOT NULL,
-      user_serial_id integer NOT NULL,
-      group_serial_id integer NOT NULL,
-      basket_id character varying(32) NOT NULL,
-      display boolean NOT NULL,
-      color character varying(16),
-      CONSTRAINT users_baskets_preferences_pkey PRIMARY KEY (id),
-      CONSTRAINT users_baskets_preferences_key UNIQUE (user_serial_id, group_serial_id, basket_id)
-    )
-    WITH (OIDS=FALSE);
-    INSERT INTO users_baskets_preferences (user_serial_id, group_serial_id, basket_id, display)
-    SELECT users.id, usergroups.id, groupbasket.basket_id, TRUE FROM users, usergroups, groupbasket, usergroup_content
-    WHERE usergroup_content.primary_group = 'Y' AND groupbasket.group_id = usergroup_content.group_id AND users.user_id = usergroup_content.user_id AND usergroups.group_id = usergroup_content.group_id
-    ORDER BY users.id;
-
-    BEGIN
-      INSERT INTO users_baskets_preferences (user_serial_id, group_serial_id, basket_id, display)
-      SELECT users.id, usergroups.id, user_baskets_secondary.basket_id, TRUE from users, usergroups, user_baskets_secondary
-      WHERE users.user_id = user_baskets_secondary.user_id and usergroups.group_id = user_baskets_secondary.group_id
-      ORDER BY users.id;
-    EXCEPTION WHEN unique_violation THEN
-    END;
-
-    BEGIN
-      INSERT INTO users_baskets_preferences (user_serial_id, group_serial_id, basket_id, display) 
-      SELECT u.id, g.id, 'IndexingBasket', TRUE FROM users as u INNER JOIN usergroup_content AS c ON u.user_id=c.user_id INNER JOIN usergroups AS g ON g.group_id=c.group_id 
-      WHERE (u.user_id,g.group_id) IN (SELECT user_id, group_id FROM usergroup_content WHERE primary_group = 'N');
-    EXCEPTION WHEN unique_violation THEN
-    END;
-    
-  END IF;
-END$$;
-
-
-
-/****** M2M *******/
-ALTER TABLE unit_identifier DROP COLUMN IF EXISTS disposition;
-ALTER TABLE unit_identifier ADD disposition text default NULL;
-
-ALTER TABLE sendmail DROP COLUMN IF EXISTS message_exchange_id;
-ALTER TABLE sendmail ADD message_exchange_id text default NULL;
-
-ALTER TABLE IF EXISTS seda RENAME TO message_exchange;
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS file_path;
-ALTER TABLE message_exchange ADD file_path text default NULL;
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS res_id_master;
-ALTER TABLE message_exchange ADD res_id_master numeric default NULL;
-
-/** ADD NEW COLUMN IS TRANSFERABLE **/
-ALTER TABLE contact_addresses DROP COLUMN  IF EXISTS  external_contact_id;
-ALTER TABLE contact_addresses ADD COLUMN external_contact_id character varying(128);
-
-ALTER TABLE contact_addresses DROP COLUMN  IF EXISTS ban_id;
-ALTER TABLE contact_addresses ADD COLUMN ban_id character varying(128);
-
-/** ADD NEW COLUMN IS CONTACTS_V2 **/
-ALTER TABLE contacts_v2 DROP COLUMN IF EXISTS is_external_contact;
-ALTER TABLE contacts_v2 ADD COLUMN is_external_contact character(1) DEFAULT 'N';
-
-DROP SEQUENCE IF EXISTS contact_communication_id_seq CASCADE;
-CREATE SEQUENCE contact_communication_id_seq
-INCREMENT 1
-MINVALUE 1
-MAXVALUE 9223372036854775807
-START 1
-CACHE 1;
-
-DROP TABLE IF EXISTS contact_communication;
-CREATE TABLE contact_communication
-(
-  id bigint NOT NULL DEFAULT nextval('contact_communication_id_seq'::regclass),
-  contact_id bigint NOT NULL,
-  type character varying(255) NOT NULL,
-  value character varying(255) NOT NULL,
-  CONSTRAINT contact_communication_pkey PRIMARY KEY (id)
-) WITH (OIDS=FALSE);
-
-DROP VIEW IF EXISTS view_contacts;
-CREATE OR REPLACE VIEW view_contacts AS 
- SELECT c.contact_id, c.contact_type, c.is_corporate_person, c.society, c.society_short, c.firstname AS contact_firstname
-, c.lastname AS contact_lastname, c.title AS contact_title, c.function AS contact_function, c.other_data AS contact_other_data
-, c.user_id AS contact_user_id, c.entity_id AS contact_entity_id, c.creation_date, c.update_date, c.enabled AS contact_enabled, ca.id AS ca_id
-, ca.contact_purpose_id, ca.departement, ca.firstname, ca.lastname, ca.title, ca.function, ca.occupancy
-, ca.address_num, ca.address_street, ca.address_complement, ca.address_town, ca.address_postal_code, ca.address_country
-, ca.phone, ca.email, ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private, ca.enabled, ca.external_contact_id
-, ca.ban_id, cp.label as contact_purpose_label, ct.label as contact_type_label
-   FROM contacts_v2 c
-   RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id
-   LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id
-   LEFT JOIN contact_types ct ON c.contact_type = ct.id;
- 
-ALTER TABLE sendmail DROP COLUMN IF EXISTS res_version_att_id_list; 
-ALTER TABLE sendmail ADD COLUMN res_version_att_id_list character varying(255); 
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS docserver_id;
-ALTER TABLE message_exchange ADD docserver_id character varying(32) DEFAULT NULL;
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS path;
-ALTER TABLE message_exchange ADD path character varying(255) DEFAULT NULL;
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS filename;
-ALTER TABLE message_exchange ADD filename character varying(255) DEFAULT NULL;
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS fingerprint;
-ALTER TABLE message_exchange ADD fingerprint character varying(255) DEFAULT NULL;
-
-ALTER TABLE message_exchange DROP COLUMN IF EXISTS filesize;
-ALTER TABLE message_exchange ADD filesize bigint;
-
-DELETE FROM docservers WHERE docserver_id = 'ARCHIVETRANSFER';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('ARCHIVETRANSFER', 'ARCHIVETRANSFER', 'Fast internal disc bay for archive transfer', 'N', 'Y', 50000000000, 1, '/opt/maarch/docservers/archive_transfer/', NULL, NULL, NULL, '2017-01-13 14:47:49.197164', NULL, 'archive_transfer_coll', 10, 'NANTERRE', 2);
-
-DELETE FROM docserver_types WHERE docserver_type_id = 'ARCHIVETRANSFER';
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled, is_container, container_max_number, is_compressed, compression_mode, is_meta, meta_template, is_logged, log_template, is_signed, fingerprint_mode) 
-VALUES ('ARCHIVETRANSFER', 'Archive Transfer', 'Y', 'N', 0, 'N', 'NONE', 'N', 'NONE', 'N', 'NONE', 'Y', 'SHA256');
-
-ALTER TABLE sendmail ALTER COLUMN res_id DROP NOT NULL;
-
-ALTER TABLE notifications DROP COLUMN IF EXISTS rss_url_template;
-UPDATE notifications SET event_id = 'baskets' WHERE notification_id = 'BASKETS';
-
-DELETE FROM parameters where id = 'user_quota';
-INSERT INTO parameters (id, param_value_string, param_value_int, param_value_date) VALUES ('user_quota', '', 0, NULL);
-DELETE FROM parameters where id = 'database_version';
-INSERT INTO parameters (id, param_value_string, param_value_int, param_value_date) VALUES ('database_version', '18.04.10', NULL, NULL);
-
-INSERT INTO templates_doctype_ext SELECT null, d.type_id, 'N' FROM doctypes d LEFT JOIN templates_doctype_ext tde ON d.type_id = tde.type_id WHERE tde.type_id IS NULL;
-
-UPDATE status set img_filename = 'fm-letter' where img_filename is null or img_filename = '';
-
-DELETE FROM usergroups_services WHERE service_id in ('delete_document_in_detail', 'edit_document_in_detail');
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT group_id, 'delete_document_in_detail' FROM security WHERE rights_bitmask IN (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT group_id, 'edit_document_in_detail' FROM security WHERE rights_bitmask IN (8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31);
diff --git a/migration/18.04/migrate.sh b/migration/18.04/migrate.sh
deleted file mode 100755
index 02da4b77b9596464d7e2a21306bc531f8b85a65a..0000000000000000000000000000000000000000
--- a/migration/18.04/migrate.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-php ./migratePriorities.php
-
diff --git a/migration/18.04/migratePriorities.php b/migration/18.04/migratePriorities.php
deleted file mode 100755
index 1dfc90774f2c44595cff7f30acfea353240eb4b4..0000000000000000000000000000000000000000
--- a/migration/18.04/migratePriorities.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $priorities = [];
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/entreprise.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        if ($loadedXml) {
-            $i = 0;
-            foreach ($loadedXml->priorities->priority as $value) {
-                if (isset($loadedXml->priorities->default_priority) && $loadedXml->priorities->default_priority == $i) {
-                    $priorities[] = [
-                        'id' => $i,
-                        'label' => (string)$value,
-                        'color' => (string)$value['color'],
-                        'working_days' => (string)$value['working_days'],
-                        'delays' => (string)$value['with_delay'] == 'false' ? null : (int)$value['with_delay'],
-                        'default_priority' => 'true'
-                    ];
-                } else {
-                    $priorities[] = [
-                        'id' => $i,
-                        'label' => (string)$value,
-                        'color' => (string)$value['color'],
-                        'working_days' => (string)$value['working_days'],
-                        'delays' => (string)$value['with_delay'] == 'false' ? null : (int)$value['with_delay'],
-                        'default_priority' => 'false'
-                    ];
-                }
-                ++$i;
-            }
-        }
-
-        \SrcCore\models\DatabasePDO::reset();
-
-        $db = new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-        foreach ($priorities as $key => $priority) {
-            if ($priority['default_priority'] == 'true') {
-                $query = "UPDATE priorities SET default_priority = false WHERE default_priority = true";
-                $db->query($query, []);
-            }
-
-            $id = \SrcCore\models\CoreConfigModel::uniqueId();
-            $query = "INSERT INTO priorities (id, label, color, working_days, delays, default_priority, \"order\") VALUES (?, ?, ?, ?, ?, ?, ?)";
-            $db->query($query, [
-                $id,
-                $priority['label'],
-                $priority['color'],
-                $priority['working_days'],
-                $priority['delays'],
-                $priority['default_priority'],
-                $key
-            ]);
-
-            $query = "UPDATE res_letterbox SET priority = ? WHERE priority = ?";
-            $db->query($query, [$id, $priority['id']]);
-
-            $priorities[$key]['priorityId'] = $id;
-        }
-
-        $i = 0;
-        foreach ($loadedXml->process_modes->process_mode as $processMode) {
-            foreach ($priorities as $priority) {
-                if ($priority['id'] == $processMode->process_mode_priority) {
-                    $loadedXml->process_modes->process_mode[$i]->process_mode_priority = $priority['priorityId'];
-                }
-            }
-            ++$i;
-        }
-
-        $res = $loadedXml->asXML();
-        $fp = fopen($path, "w+");
-        if ($fp) {
-            fwrite($fp, $res);
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
diff --git a/migration/18.10/1810.sql b/migration/18.10/1810.sql
deleted file mode 100644
index efe9bd9af5b3a5cb9cae09e7a7d477dc7daa70dd..0000000000000000000000000000000000000000
--- a/migration/18.10/1810.sql
+++ /dev/null
@@ -1,588 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 18.04 to 18.10                                  --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
-DELETE FROM parameters where id = 'database_version';
-INSERT INTO parameters (id, param_value_string, param_value_int, param_value_date) VALUES ('database_version', '18.10.1', NULL, NULL);
-
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS res_view_attachments;
-
-UPDATE actions_groupbaskets SET used_in_basketlist = 'Y', used_in_action_page = 'Y' WHERE default_action_list = 'Y';
-UPDATE actions_groupbaskets SET used_in_action_page = 'Y' WHERE used_in_basketlist = 'N' AND used_in_action_page = 'N';
-DELETE FROM usergroups_services WHERE service_id = 'view_baskets';
-ALTER TABLE groupbasket_status DROP COLUMN IF EXISTS "order";
-ALTER TABLE groupbasket_status ADD COLUMN "order" integer;
-UPDATE groupbasket_status SET "order" = 0 WHERE status_id = 'NEW';
-UPDATE groupbasket_status SET "order" = 1 WHERE status_id != 'NEW';
-UPDATE baskets SET basket_res_order = 'res_id desc' WHERE basket_res_order IS NULL;
-ALTER TABLE baskets ALTER COLUMN basket_res_order SET NOT NULL;
-ALTER TABLE baskets ALTER COLUMN basket_res_order SET DEFAULT 'res_id desc';
-ALTER TABLE groupbasket_status ALTER COLUMN "order" SET NOT NULL;
-DO $$ BEGIN
-  IF (SELECT count(TABLE_NAME)  FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'users_baskets') = 1 THEN
-    UPDATE users_baskets_preferences set color =
-    (
-      SELECT color FROM users_baskets
-      WHERE users_baskets_preferences.user_serial_id = users_baskets.user_serial_id
-      AND users_baskets_preferences.basket_id = users_baskets.basket_id
-      AND users_baskets.group_id = (select group_id from usergroups where users_baskets_preferences.group_serial_id = usergroups.id)
-    );
-    DROP TABLE IF EXISTS users_baskets;
-  END IF;
-END$$;
-
-/* Custom To Standard*/
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS departure_date;
-ALTER TABLE res_letterbox ADD COLUMN departure_date timestamp without time zone;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS department_number_id;
-ALTER TABLE res_letterbox ADD COLUMN department_number_id text;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS barcode;
-ALTER TABLE res_letterbox ADD COLUMN barcode text;
-
-/* Contact Groups*/
-DROP TABLE IF EXISTS contacts_groups;
-CREATE TABLE contacts_groups
-(
-  id serial,
-  label character varying(32) NOT NULL,
-  description character varying(255) NOT NULL,
-  public boolean NOT NULL,
-  owner integer NOT NULL,
-  entity_owner character varying(32) NOT NULL,
-  CONSTRAINT contacts_groups_pkey PRIMARY KEY (id),
-  CONSTRAINT contacts_groups_key UNIQUE (label, owner)
-)
-WITH (OIDS=FALSE);
-DROP TABLE IF EXISTS contacts_groups_lists;
-CREATE TABLE contacts_groups_lists
-(
-  id serial,
-  contacts_groups_id integer NOT NULL,
-  contact_addresses_id integer NOT NULL,
-  CONSTRAINT contacts_groups_lists_pkey PRIMARY KEY (id),
-  CONSTRAINT contacts_groups_lists_key UNIQUE (contacts_groups_id, contact_addresses_id)
-)
-WITH (OIDS=FALSE);
-
-/* Docservers */
-ALTER TABLE docservers DROP COLUMN IF EXISTS docserver_location_id;
-ALTER TABLE docservers DROP COLUMN IF EXISTS ext_docserver_info;
-ALTER TABLE docservers DROP COLUMN IF EXISTS chain_before;
-ALTER TABLE docservers DROP COLUMN IF EXISTS chain_after;
-ALTER TABLE docservers DROP COLUMN IF EXISTS closing_date;
-ALTER TABLE docservers DROP COLUMN IF EXISTS enabled;
-ALTER TABLE docservers DROP COLUMN IF EXISTS adr_priority_number;
-ALTER TABLE docservers DROP COLUMN IF EXISTS priority_number;
-ALTER TABLE docservers DROP COLUMN IF EXISTS id;
-ALTER TABLE docservers ADD COLUMN id serial;
-ALTER TABLE docservers ADD UNIQUE (id);
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS is_container;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS container_max_number;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS is_compressed;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS compression_mode;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS is_meta;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS meta_template;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS is_logged;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS log_template;
-ALTER TABLE docserver_types DROP COLUMN IF EXISTS is_signed;
-DROP TABLE IF EXISTS docserver_locations;
-UPDATE docservers set is_readonly = 'Y' WHERE docserver_id = 'FASTHD_AI';
-
-/* Templates */
-ALTER TABLE templates_association DROP COLUMN IF EXISTS system_id;
-ALTER TABLE templates_association DROP COLUMN IF EXISTS what;
-ALTER TABLE templates_association DROP COLUMN IF EXISTS maarch_module;
-ALTER TABLE templates_association DROP COLUMN IF EXISTS id;
-ALTER TABLE templates_association ADD COLUMN id serial;
-ALTER TABLE templates_association ADD UNIQUE (id);
-UPDATE templates SET template_content = REPLACE(template_content, '###', ';');
-UPDATE templates SET template_content = REPLACE(template_content, '___', '--');
-
-/* Password Management */
-DROP TABLE IF EXISTS password_rules;
-CREATE TABLE password_rules
-(
-  id serial,
-  label character varying(64) NOT NULL,
-  "value" INTEGER NOT NULL,
-  enabled boolean DEFAULT FALSE NOT NULL,
-  CONSTRAINT password_rules_pkey PRIMARY KEY (id),
-  CONSTRAINT password_rules_label_key UNIQUE (label)
-)
-WITH (OIDS=FALSE);
-DROP TABLE IF EXISTS password_history;
-CREATE TABLE password_history
-(
-  id serial,
-  user_serial_id INTEGER NOT NULL,
-  password character varying(255) NOT NULL,
-  CONSTRAINT password_history_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-INSERT INTO password_rules (label, "value", enabled) VALUES ('minLength', 6, true);
-INSERT INTO password_rules (label, "value") VALUES ('complexityUpper', 0);
-INSERT INTO password_rules (label, "value") VALUES ('complexityNumber', 0);
-INSERT INTO password_rules (label, "value") VALUES ('complexitySpecial', 0);
-INSERT INTO password_rules (label, "value") VALUES ('lockAttempts', 3);
-INSERT INTO password_rules (label, "value") VALUES ('lockTime', 5);
-INSERT INTO password_rules (label, "value") VALUES ('historyLastUse', 2);
-INSERT INTO password_rules (label, "value") VALUES ('renewal', 90);
-ALTER TABLE users DROP COLUMN IF EXISTS password_modification_date;
-ALTER TABLE users ADD COLUMN password_modification_date timestamp without time zone DEFAULT CURRENT_TIMESTAMP;
-ALTER TABLE users DROP COLUMN IF EXISTS failed_authentication;
-ALTER TABLE users ADD COLUMN failed_authentication INTEGER DEFAULT 0;
-ALTER TABLE users DROP COLUMN IF EXISTS locked_until;
-ALTER TABLE users ADD COLUMN locked_until TIMESTAMP without time zone;
-
-/* Signature Books*/
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS external_id;
-ALTER TABLE res_attachments ADD COLUMN external_id character varying(255) DEFAULT NULL::character varying;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS external_id;
-ALTER TABLE res_version_attachments ADD COLUMN external_id character varying(255) DEFAULT NULL::character varying;
-
-/* Convert */
-DROP TABLE IF EXISTS adr_letterbox;
-CREATE TABLE adr_letterbox
-(
-  id serial NOT NULL,
-  res_id bigint NOT NULL,
-  type character varying(32) NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) NOT NULL,
-  filename character varying(255) NOT NULL,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  CONSTRAINT adr_letterbox_pkey PRIMARY KEY (id),
-  CONSTRAINT adr_letterbox_unique_key UNIQUE (res_id, type)
-)
-WITH (OIDS=FALSE);
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_letterbox') AND attname = 'tnl_path') = 1 THEN
-    INSERT INTO adr_letterbox (res_id, type, docserver_id, path, filename) SELECT res_id, 'TNL', 'TNL_MLB', tnl_path, tnl_filename FROM res_letterbox WHERE tnl_path IS NOT NULL AND tnl_path != 'ERR';
-    ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_path;
-    ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_filename;
-  END IF;
-END$$;
-DELETE FROM parameters WHERE id = 'thumbnailsSize';
-INSERT INTO parameters (id, description, param_value_string) VALUES ('thumbnailsSize', 'Taille des imagettes', '750x900');
-
-DROP TABLE IF EXISTS adr_attachments;
-CREATE TABLE adr_attachments
-(
-  id serial NOT NULL,
-  res_id bigint NOT NULL,
-  type character varying(32) NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) NOT NULL,
-  filename character varying(255) NOT NULL,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  CONSTRAINT adr_attachments_pkey PRIMARY KEY (id),
-  CONSTRAINT adr_attachments_unique_key UNIQUE (res_id, type)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS adr_attachments_version;
-CREATE TABLE adr_attachments_version
-(
-  id serial NOT NULL,
-  res_id bigint NOT NULL,
-  type character varying(32) NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) NOT NULL,
-  filename character varying(255) NOT NULL,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  CONSTRAINT adr_attachments_version_pkey PRIMARY KEY (id),
-  CONSTRAINT adr_attachments_version_unique_key UNIQUE (res_id, type)
-)
-WITH (OIDS=FALSE);
-
-/* Refactoring */
-DROP VIEW IF EXISTS af_view_customer_target_view;
-DROP VIEW IF EXISTS af_view_customer_view;
-DROP VIEW IF EXISTS af_view_year_target_view;
-DROP VIEW IF EXISTS af_view_year_view;
-DROP TABLE IF EXISTS allowed_ip;
-DROP TABLE IF EXISTS af_security;
-DROP TABLE IF EXISTS af_view_customer_target;
-DROP TABLE IF EXISTS af_view_year_target;
-DROP VIEW IF EXISTS res_view;
-DROP TABLE IF EXISTS res_x;
-DROP TABLE IF EXISTS res_version_x;
-DROP TABLE IF EXISTS adr_x;
-DROP TABLE IF EXISTS res_version_letterbox;
-ALTER TABLE baskets DROP COLUMN IF EXISTS is_generic;
-ALTER TABLE baskets DROP COLUMN IF EXISTS except_notif;
-ALTER TABLE baskets DROP COLUMN IF EXISTS is_folder_basket;
-ALTER TABLE actions DROP COLUMN IF EXISTS is_folder_action;
-ALTER TABLE status DROP COLUMN IF EXISTS is_folder_status;
-ALTER TABLE security DROP COLUMN IF EXISTS can_insert;
-ALTER TABLE security DROP COLUMN IF EXISTS can_update;
-ALTER TABLE security DROP COLUMN IF EXISTS can_delete;
-ALTER TABLE security DROP COLUMN IF EXISTS rights_bitmask;
-ALTER TABLE security DROP COLUMN IF EXISTS mr_start_date;
-ALTER TABLE security DROP COLUMN IF EXISTS mr_stop_date;
-ALTER TABLE security DROP COLUMN IF EXISTS where_target;
-ALTER TABLE users DROP COLUMN IF EXISTS ra_code;
-ALTER TABLE users DROP COLUMN IF EXISTS ra_expiration_date;
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS answer_type_bitmask;
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS other_answer_desc;
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS process_notes;
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS sve_identifier;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS publisher;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS publisher;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS publisher;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS contributor;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS contributor;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS contributor;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS author_name;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS author_name;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS author_name;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS doc_language;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS doc_language;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS doc_language;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS arbox_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS arbox_id;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS arbox_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS logical_adr;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS logical_adr;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS logical_adr;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS is_paper;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_paper;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS is_paper;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS page_count;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS page_count;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS page_count;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_date;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS scan_date;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS scan_date;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_user;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS scan_user;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS scan_user;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_location;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS scan_location;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS scan_location;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_wkstation;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS scan_wkstation;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS scan_wkstation;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_batch;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS scan_batch;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS scan_batch;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS burn_batch;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS burn_batch;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS burn_batch;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_postmark;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS scan_postmark;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS scan_postmark;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS envelop_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS envelop_id;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS envelop_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS approver;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS approver;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS approver;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS is_ingoing;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_ingoing;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS is_ingoing;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS arbatch_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS arbatch_id;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS arbatch_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS cycle_date;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS cycle_date;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS cycle_date;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS is_frozen;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_frozen;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS is_frozen;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS video_batch;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS video_batch;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS video_batch;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS video_time;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS video_time;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS video_time;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS video_user;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS video_user;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS video_user;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS video_date;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS video_date;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS video_date;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS ocr_result;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS ocr_result;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS ocr_result;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS coverage;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS coverage;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS coverage;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS esign_proof_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS esign_proof_content;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS esign_content;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS esign_date;
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mlb_coll_ext') AND attname = 'sve_start_date') = 1 THEN
-    ALTER TABLE res_letterbox ADD COLUMN sve_start_date TIMESTAMP without time zone;
-    UPDATE res_letterbox set sve_start_date =
-    (
-      SELECT sve_start_date FROM mlb_coll_ext
-      WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND sve_start_date is not null
-    );
-    ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS sve_start_date;
-  END IF;
-END$$;
-
-
-CREATE OR REPLACE VIEW res_view_letterbox AS
- SELECT r.tablename,
-    r.is_multi_docservers,
-    r.res_id,
-    r.type_id,
-    r.policy_id,
-    r.cycle_id,
-    d.description AS type_label,
-    d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label,
-    dfl.css_style AS doctype_first_level_style,
-    d.doctypes_second_level_id,
-    dsl.doctypes_second_level_label,
-    dsl.css_style AS doctype_second_level_style,
-    r.format,
-    r.typist,
-    r.creation_date,
-    r.modification_date,
-    r.relation,
-    r.docserver_id,
-    r.folders_system_id,
-    f.folder_id,
-    f.destination AS folder_destination,
-    f.is_frozen AS folder_is_frozen,
-    r.path,
-    r.filename,
-    r.fingerprint,
-    r.offset_doc,
-    r.filesize,
-    r.status,
-    r.work_batch,
-    r.doc_date,
-    r.description,
-    r.source,
-    r.author,
-    r.reference_number,
-    r.external_id,
-    r.external_link,
-    r.departure_date,
-    r.department_number_id,
-    r.barcode,
-    r.custom_t1 AS doc_custom_t1,
-    r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3,
-    r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5,
-    r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7,
-    r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9,
-    r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11,
-    r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13,
-    r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15,
-    r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2,
-    r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4,
-    r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6,
-    r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8,
-    r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10,
-    r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2,
-    r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4,
-    r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1,
-    r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3,
-    r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5,
-    f.foldertype_id,
-    ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1,
-    f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3,
-    f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5,
-    f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7,
-    f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9,
-    f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11,
-    f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13,
-    f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15,
-    f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2,
-    f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4,
-    f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6,
-    f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8,
-    f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10,
-    f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2,
-    f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4,
-    f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1,
-    f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3,
-    f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5,
-    f.is_complete AS fold_complete,
-    f.status AS fold_status,
-    f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id,
-    f.folder_level,
-    f.folder_name,
-    f.creation_date AS fold_creation_date,
-    r.initiator,
-    r.destination,
-    r.dest_user,
-    r.confidentiality,
-    mlb.category_id,
-    mlb.exp_contact_id,
-    mlb.exp_user_id,
-    mlb.dest_user_id,
-    mlb.dest_contact_id,
-    mlb.address_id,
-    mlb.nature_id,
-    mlb.alt_identifier,
-    mlb.admission_date,
-    mlb.process_limit_date,
-    mlb.recommendation_limit_date,
-    mlb.closing_date,
-    mlb.alarm1_date,
-    mlb.alarm2_date,
-    mlb.flag_notif,
-    mlb.flag_alarm1,
-    mlb.flag_alarm2,
-    mlb.is_multicontacts,
-    r.sve_start_date,
-    r.subject,
-    r.identifier,
-    r.title,
-    r.priority,
-    r.locker_user_id,
-    r.locker_time,
-    ca.case_id,
-    ca.case_label,
-    ca.case_description,
-    en.entity_label,
-    en.entity_type AS entitytype,
-    cont.contact_id,
-    cont.firstname AS contact_firstname,
-    cont.lastname AS contact_lastname,
-    cont.society AS contact_society,
-    u.lastname AS user_lastname,
-    u.firstname AS user_firstname
-   FROM doctypes d,
-    doctypes_first_level dfl,
-    doctypes_second_level dsl,
-    res_letterbox r
-     LEFT JOIN entities en ON r.destination::text = en.entity_id::text
-     LEFT JOIN folders f ON r.folders_system_id = f.folders_system_id
-     LEFT JOIN cases_res cr ON r.res_id = cr.res_id
-     LEFT JOIN mlb_coll_ext mlb ON mlb.res_id = r.res_id
-     LEFT JOIN foldertypes ft ON f.foldertype_id = ft.foldertype_id AND f.status::text <> 'DEL'::text
-     LEFT JOIN cases ca ON cr.case_id = ca.case_id
-     LEFT JOIN contacts_v2 cont ON mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id
-     LEFT JOIN users u ON mlb.exp_user_id::text = u.user_id::text OR mlb.dest_user_id::text = u.user_id::text
-  WHERE r.type_id = d.type_id AND d.doctypes_first_level_id = dfl.doctypes_first_level_id AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-CREATE VIEW res_view_attachments AS
-  SELECT '0' as res_id, res_id as res_id_version, title, subject, description, type_id, format, typist,
-  creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path,
-  filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master, in_signature_book, signatory_user_serial_id
-  FROM res_version_attachments
-  UNION ALL
-  SELECT res_id, '0' as res_id_version, title, subject, description, type_id, format, typist,
-  creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path,
-  filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book, signatory_user_serial_id
-  FROM res_attachments;
-
-DELETE FROM status WHERE id = 'A_TRA';
-INSERT INTO status (id, label_status, is_system, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES ('A_TRA', 'PJ à traiter', 'Y', 'fa-question', 'apps', 'Y', 'Y');
-
-DELETE FROM status_images WHERE image_name = 'fa-question';
-INSERT INTO status_images (image_name) VALUES ('fa-question');
-
-DELETE FROM status WHERE id = 'TRA';
-INSERT INTO status (id, label_status, is_system, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES ('TRA', 'PJ traitée', 'Y', 'fa-check', 'apps', 'Y', 'Y');
-
-DELETE FROM status_images WHERE image_name = 'fa-check';
-INSERT INTO status_images (image_name) VALUES ('fa-check');
-
-DELETE FROM status WHERE id = 'FRZ';
-INSERT INTO status (id, label_status, is_system, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES ('FRZ', 'PJ gelée', 'Y', 'fa-pause', 'apps', 'Y', 'Y');
-
-DELETE FROM status_images WHERE image_name = 'fa-pause';
-INSERT INTO status_images (image_name) VALUES ('fa-pause');
-
-DELETE FROM status WHERE id = 'SEND_MASS';
-INSERT INTO status (id, label_status, is_system, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES ('SEND_MASS', 'Pour publipostage', 'Y', 'fa-mail-bulk', 'apps', 'Y', 'Y');
-
-DELETE FROM status_images WHERE image_name = 'fa-mail-bulk';
-INSERT INTO status_images (image_name) VALUES ('fa-mail-bulk');
-
-DELETE FROM status WHERE id = 'SIGN';
-INSERT INTO status (id, label_status, is_system, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES ('SIGN', 'PJ signée', 'Y', 'fa-check', 'apps', 'Y', 'Y');
-
-DELETE FROM parameters WHERE id = 'homepage_message';
-INSERT INTO parameters (id, description, param_value_string) VALUES ('homepage_message', 'Texte apparaissant dans la bannière sur la page d''accueil, mettre un espace pour supprimer la bannière.', 'Bienvenue dans votre <b>G</b>estion <b>E</b>lectronique du <b>C</b>ourrier.');
-
-ALTER TABLE parameters ALTER COLUMN param_value_string TYPE TEXT;
-
-DROP TABLE IF EXISTS contacts_filling;
-CREATE TABLE contacts_filling
-(
-  id serial NOT NULL,
-  enable boolean NOT NULL,
-  rating_columns text NOT NULL,
-  first_threshold int NOT NULL,
-  second_threshold int NOT NULL,
-  CONSTRAINT contacts_filling_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-INSERT INTO contacts_filling (enable, rating_columns, first_threshold, second_threshold) VALUES (FALSE, '{}', 33, 66);
-
-ALTER TABLE entities DROP COLUMN IF EXISTS folder_import;
-ALTER TABLE entities ADD COLUMN folder_import character varying(64);
-ALTER TABLE entities ADD UNIQUE (folder_import);
-ALTER TABLE user_abs DROP COLUMN IF EXISTS group_id;
-ALTER TABLE user_abs ADD COLUMN group_id int;
-
-/* Sender/Recipient */
-DROP TABLE IF EXISTS resource_contacts;
-CREATE TABLE resource_contacts
-(
-  id serial NOT NULL,
-  res_id int NOT NULL,
-  item_id int NOT NULL,
-  type character varying(32) NOT NULL,
-  mode character varying(32) NOT NULL,
-  CONSTRAINT resource_contacts_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-ALTER TABLE entities DROP COLUMN IF EXISTS id;
-ALTER TABLE entities ADD COLUMN id serial;
-ALTER TABLE entities ADD UNIQUE (id);
-
-UPDATE notifications set event_id = 'userModification' where event_id = 'usersup';
-UPDATE notifications set event_id = 'user%' where event_id = 'users%';
diff --git a/migration/18.10/migrate.sh b/migration/18.10/migrate.sh
deleted file mode 100755
index 58b68ffe255b1bd45c74d9ab42652b60342cd139..0000000000000000000000000000000000000000
--- a/migration/18.10/migrate.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-php ./migrateLdap.php
-php ./migrateConvertedPdf.php
-
-
diff --git a/migration/18.10/migrateConvertedPdf.php b/migration/18.10/migrateConvertedPdf.php
deleted file mode 100755
index a3dec97f30acf73858b0db51bf8cfbf3186c64fc..0000000000000000000000000000000000000000
--- a/migration/18.10/migrateConvertedPdf.php
+++ /dev/null
@@ -1,156 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-$currentDir = getcwd();
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    $resOK = [];
-    $resKO = [];
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-
-    $db = new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $query = "SELECT r2.res_id as convert_res_id from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id <> 0";
-    $stmt = $db->query($query, []);
-    echo "Suppression de {$stmt->rowCount()} PJ de type 'converted_pdf' des PJ en status 'TMP', 'OBS', 'DEL'...\n";
-    if ($stmt->rowCount() > 0) {
-        $convertedAttachTodel = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
-    
-        $query = "SELECT r2.res_id as convert_res_id from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id_version <> 0";
-        $stmt = $db->query($query, []);
-        $convertedAttachVersionTodel = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
-        $convertedAttachTodelFull = array_merge($convertedAttachTodel, $convertedAttachVersionTodel);
-        $convertedAttachTodelList = "'".implode("','", $convertedAttachTodelFull)."'";
-        $query = "Delete FROM res_attachments WHERE res_id IN ({$convertedAttachTodelList})";
-        $db->query($query, []);
-    }
-    $output[] = "{$stmt->rowCount()} PJ de type 'converted_pdf' des PJ en status 'TMP', 'OBS', 'DEL' supprimé\n";
-
-    $query = "SELECT path_template FROM docservers WHERE docserver_id = 'CONVERT_ATTACH'";
-    $stmt = $db->query($query, []);
-    $docserverAttach = $stmt->fetchObject();
-    $docserverAttachPath = str_replace('#', '/', $docserverAttach->path_template);
-    if (empty($docserverAttach)) {
-        echo "Le docserver CONVERT_ATTACH n'existe pas ! \n";
-        exit();
-    } else {
-        echo "Nouveau répertoire pièces jointes converties : {$docserverAttachPath}\n\n";
-    }
-
-    $query = "SELECT r.res_id as real_res_id, r2.res_id as convert_res_id, d.path_template as convert_path_template, r2.path as convert_path, r2.filename as convert_filename, r2.fingerprint as convert_fingerprint from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status not in ('DEL', 'OBS', 'TMP') AND r2.status not in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id <> 0";
-    $stmt = $db->query($query, []);
-    echo "{$stmt->rowCount()} Pièce(s) jointe(s) de type 'converted_pdf' trouvée :\n\n";
-    if ($stmt->rowCount() > 0) {
-        while ($convertedAttachment = $stmt->fetchObject()) {
-            $pathFile = str_replace('#', '/', $docserverAttachPath.$convertedAttachment->convert_path);
-            $fullFilename = str_replace('#', '/', $convertedAttachment->convert_path_template.$convertedAttachment->convert_path.$convertedAttachment->convert_filename);
-            $newFullFilename = str_replace('#', '/', $pathFile.$convertedAttachment->convert_filename);
-            if (file_exists($fullFilename)) {
-                if (!is_dir($pathFile)) {
-                    echo "Création du dossier {$pathFile}...\n";
-                    if (!mkdir($pathFile, 0777, true)) {
-                        die('Echec lors de la création des répertoires...');
-                    }
-                }
-                echo "Copie du document : {$fullFilename} => {$newFullFilename}...\n";
-                if (!copy($fullFilename, $newFullFilename)) {
-                    echo "ECHOUÉE!\n";
-                    $resKO[] = "RES_ID : ".$convertedAttachment->convert_res_id . " (Copie du document : {$fullFilename} => {$newFullFilename} FAILED)";
-                } else {
-                    echo "OK!\n";
-                    echo "Insertion dans la table adr_attachments...\n";
-              
-                    $query = "DELETE FROM adr_attachments WHERE res_id = ? and type = 'PDF'";
-                    $db->query($query, [$convertedAttachment->real_res_id]);
-                    $query = "INSERT INTO adr_attachments(res_id, type, docserver_id, path, filename, fingerprint) VALUES (?, ?, ?, ?, ?, ?)";
-                    $tmp = $db->query($query, [$convertedAttachment->real_res_id, 'PDF', 'CONVERT_ATTACH', $convertedAttachment->convert_path, $convertedAttachment->convert_filename, $convertedAttachment->convert_fingerprint]);
-                    if ($tmp) {
-                        $resOK[] = $convertedAttachment->convert_res_id;
-                    }
-                }
-            } else {
-                $resKO[] = "RES_ID : ".$convertedAttachment->convert_res_id . " ({$fullFilename} non trouvé)";
-                echo "Document : {$fullFilename} non trouvé\n";
-            }
-        }
-    }
-    
-    //PJ VERSIONS
-    $query = "SELECT path_template FROM docservers WHERE docserver_id = 'CONVERT_ATTACH_VERSION'";
-    $stmt = $db->query($query, []);
-    $docserverAttach = $stmt->fetchObject();
-    $docserverAttachPath = str_replace('#', '/', $docserverAttach->path_template);
-    if (empty($docserverAttach)) {
-        echo "Le docserver CONVERT_ATTACH_VERSION n'existe pas !\n";
-        exit();
-    } else {
-        echo "Nouveau répertoire pièces jointes versionnées converties : {$docserverAttachPath}\n\n";
-    }
-
-    $query = "SELECT r.res_id_version as real_res_id, r2.res_id as convert_res_id, d.path_template as convert_path_template, r2.path as convert_path, r2.filename as convert_filename, r2.fingerprint as convert_fingerprint from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status not in ('DEL', 'OBS', 'TMP') AND r2.status not in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id_version <> 0";
-    $stmt = $db->query($query, []);
-    echo "{$stmt->rowCount()} Pièce(s) jointe(s) versionnée(s) de type 'converted_pdf' trouvée :\n\n";
-    if ($stmt->rowCount() > 0) {
-        while ($convertedAttachment = $stmt->fetchObject()) {
-            $pathFile = str_replace('#', '/', $docserverAttachPath.$convertedAttachment->convert_path);
-            $fullFilename = str_replace('#', '/', $convertedAttachment->convert_path_template.$convertedAttachment->convert_path.$convertedAttachment->convert_filename);
-            $newFullFilename = str_replace('#', '/', $pathFile.$convertedAttachment->convert_filename);
-            if (file_exists($fullFilename)) {
-                if (!is_dir($pathFile)) {
-                    echo "Création du dossier {$pathFile}...\n";
-                    if (!mkdir($pathFile, 0777, true)) {
-                        die('Echec lors de la création des répertoires...');
-                    }
-                }
-                echo "Copie du document : {$fullFilename} => {$newFullFilename}...\n";
-                if (!copy($fullFilename, $newFullFilename)) {
-                    echo "ECHOUÉE!\n";
-                    $resKO[] = "RES_ID : ".$convertedAttachment->convert_res_id . " (Copie du document : {$fullFilename} => {$newFullFilename} FAILED)";
-                } else {
-                    echo "OK!\n";
-                    echo "Insertion dans la table adr_attachments_version...\n";
-              
-                    $query = "DELETE FROM adr_attachments_version WHERE res_id = ? and type = 'PDF'";
-                    $db->query($query, [$convertedAttachment->real_res_id]);
-                    $query = "INSERT INTO adr_attachments_version(res_id, type, docserver_id, path, filename, fingerprint) VALUES (?, ?, ?, ?, ?, ?)";
-                    $tmp = $db->query($query, [$convertedAttachment->real_res_id, 'PDF', 'CONVERT_ATTACH_VERSION', $convertedAttachment->convert_path, $convertedAttachment->convert_filename, $convertedAttachment->convert_fingerprint]);
-                    if ($tmp) {
-                        $resOK[] = $convertedAttachment->convert_res_id;
-                    }
-                }
-            } else {
-                $resKO[] = "RES_ID : ".$convertedAttachment->convert_res_id . " ({$fullFilename} non trouvé)";
-                echo "Document : {$fullFilename} non trouvé\n";
-            }
-        }
-    }
-
-    if (!empty($resOK)) {
-        $resOKList = "'".implode("','", $resOK)."'";
-        echo "Suppression des PJ {$resOKList} de type 'converted_pdf'...\n";
-        $query = "Delete FROM res_attachments WHERE res_id IN ({$resOKList})";
-        $db->query($query, []);
-    }
-    $nbresOK = count($resOK);
-    $output[] = "{$nbresOK} PJ de type 'converted_pdf' migré.\n";
-
-    $resKOList = implode("\n", $resKO);
-    $nbResKO = count($resKO);
-    $output[] = "{$nbResKO} PJ de type 'converted_pdf' NON migré :\n";
-    $output[] = "$resKOList\n\n";
-    echo "\n\nLog {$currentDir}/result.log généré\n";
-    file_put_contents($currentDir.'/result.log', implode('', $output));
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
diff --git a/migration/18.10/migrateLdap.php b/migration/18.10/migrateLdap.php
deleted file mode 100755
index 097ba42933f877474d6d4a714a4ca15410c1d585..0000000000000000000000000000000000000000
--- a/migration/18.10/migrateLdap.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/config.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-    }
-
-    if ($xmlfile && (string)$xmlfile->CONFIG->ldap == 'true') {
-        $loginMethodPath = "custom/{$custom}/apps/maarch_entreprise/xml/login_method.xml";
-
-        if (!file_exists($loginMethodPath)) {
-            copy('apps/maarch_entreprise/xml/login_method.xml', "custom/{$custom}/apps/maarch_entreprise/xml/login_method.xml");
-        }
-        $loginXmlfile = simplexml_load_file($loginMethodPath);
-
-        foreach ($loginXmlfile->METHOD as $method) {
-            $method->ENABLED = 'false';
-            if ($method->ID == 'ldap') {
-                $method->ENABLED = 'true';
-            }
-        }
-
-        $res = $loginXmlfile->asXML();
-        $fp = @fopen($loginMethodPath, "w+");
-        if ($fp) {
-            fwrite($fp, $res);
-        }
-
-        if (file_exists("custom/{$custom}/modules/ldap/xml/config.xml")) {
-            $dom = new DOMDocument();
-            $dom->formatOutput = true;
-
-            $dom->load("custom/{$custom}/modules/ldap/xml/config.xml");
-
-            $config = $dom->getElementsByTagName('config')[0];
-            $saveNodes = [];
-            foreach ($config->childNodes as $node) {
-                $saveNodes[] = $node;
-            }
-
-            while ($config->hasChildNodes()) {
-                $config->removeChild($config->firstChild);
-            }
-
-            $ldap = $dom->createElement('ldap');
-            foreach ($saveNodes as $node) {
-                $ldap->appendChild($node);
-            }
-            $ldap->appendChild($dom->createElement('standardConnect', 'false'));
-            $config->appendChild($ldap);
-            $res = $dom->saveXML($dom, LIBXML_NOEMPTYTAG);
-            $fp = @fopen("custom/{$custom}/modules/ldap/xml/config.xml", "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-        }
-
-        $migrated++;
-    }
-}
-
-printf($migrated . " custom(s) utilisant la connexion LDAP trouvé(s) et migré(s).\n");
diff --git a/migration/19.04/1904.sql b/migration/19.04/1904.sql
deleted file mode 100644
index c0e10adb4b4b74f3b6b7971cc1ce1f077fd777ef..0000000000000000000000000000000000000000
--- a/migration/19.04/1904.sql
+++ /dev/null
@@ -1,547 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 18.10 to 19.04                               --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-UPDATE parameters SET param_value_string = '19.04.17' WHERE id = 'database_version';
-
-DELETE FROM parameters WHERE id = 'QrCodePrefix';
-INSERT INTO parameters (id, description, param_value_int) VALUES ('QrCodePrefix', 'Si activé (1), ajoute "Maarch_" dans le contenu des QrCode générés. (Utilisable avec MaarchCapture >= 1.4)', 0);
-
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS view_contacts;
-DROP VIEW IF EXISTS res_view_attachments;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_signatory_book_id;
-ALTER TABLE res_letterbox ADD COLUMN external_signatory_book_id integer;
-
-ALTER TABLE users DROP COLUMN IF EXISTS external_id;
-ALTER TABLE users ADD COLUMN external_id jsonb DEFAULT '{}';
-
-/* Redirected Baskets */
-DO $$ BEGIN
-  IF (SELECT count(TABLE_NAME)  FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'user_abs') = 1 THEN
-    DROP TABLE IF EXISTS redirected_baskets;
-    CREATE TABLE redirected_baskets
-    (
-    id serial NOT NULL,
-    actual_user_id INTEGER NOT NULL,
-    owner_user_id INTEGER NOT NULL,
-    basket_id character varying(255) NOT NULL,
-    group_id INTEGER NOT NULL,
-    CONSTRAINT redirected_baskets_pkey PRIMARY KEY (id),
-    CONSTRAINT redirected_baskets_unique_key UNIQUE (owner_user_id, basket_id, group_id)
-    )
-    WITH (OIDS=FALSE);
-
-	  INSERT INTO redirected_baskets (owner_user_id, actual_user_id, basket_id, group_id)
-      SELECT users.id, us.id, user_abs.basket_id, usergroups.id FROM usergroups, usergroup_content, user_abs, groupbasket, users, users us
-      WHERE usergroup_content.group_id = usergroups.group_id 
-        and usergroup_content.user_id = user_abs.basket_owner
-        and users.user_id = user_abs.basket_owner
-        and us.user_id = user_abs.new_user
-        and groupbasket.group_id = usergroup_content.group_id
-        and groupbasket.basket_id = user_abs.basket_id
-      ON CONFLICT DO NOTHING;
-
-    DROP TABLE IF EXISTS user_abs;
-  END IF;
-END$$;
-
-UPDATE history SET table_name = 'redirected_baskets' WHERE table_name = 'user_abs';
-
-/* CONFIGURATIONS */
-DROP TABLE IF EXISTS configurations;
-CREATE TABLE configurations
-(
-id serial NOT NULL,
-service character varying(64) NOT NULL,
-value json DEFAULT '{}' NOT NULL,
-CONSTRAINT configuration_pkey PRIMARY KEY (id),
-CONSTRAINT configuration_unique_key UNIQUE (service)
-)
-WITH (OIDS=FALSE);
-INSERT INTO configurations (service, value) VALUES ('admin_email_server', '{"type" : "smtp", "host" : "smtp.gmail.com", "port" : 465, "user" : "", "password" : "", "auth" : true, "secure" : "ssl", "from" : "notifications@maarch.org", "charset" : "utf-8"}');
-
-/* EMAILS */
-DROP TABLE IF EXISTS emails;
-CREATE TABLE emails
-(
-id serial NOT NULL,
-user_id INTEGER NOT NULL,
-sender json DEFAULT '{}' NOT NULL,
-recipients json DEFAULT '[]' NOT NULL,
-cc json DEFAULT '[]' NOT NULL,
-cci json DEFAULT '[]' NOT NULL,
-object character varying(256),
-body text,
-document json,
-is_html boolean NOT NULL DEFAULT TRUE,
-status character varying(16) NOT NULL,
-message_exchange_id text,
-creation_date timestamp without time zone NOT NULL,
-send_date timestamp without time zone,
-CONSTRAINT emails_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-/* SHIPPING TEMPLATES */
-DROP TABLE IF EXISTS shipping_templates;
-CREATE TABLE shipping_templates
-(
-id serial NOT NULL,
-label character varying(64) NOT NULL,
-description character varying(255) NOT NULL,
-options json DEFAULT '{}',
-fee json DEFAULT '{}',
-entities jsonb DEFAULT '{}',
-account json DEFAULT '{}',
-CONSTRAINT shipping_templates_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-DROP TABLE IF EXISTS shippings;
-CREATE TABLE shippings
-(
-id serial NOT NULL,
-user_id INTEGER NOT NULL,
-attachment_id INTEGER NOT NULL,
-is_version boolean NOT NULL,
-options json DEFAULT '{}',
-fee FLOAT NOT NULL,
-recipient_entity_id INTEGER NOT NULL,
-account_id character varying(64) NOT NULL,
-creation_date timestamp without time zone NOT NULL,
-CONSTRAINT shippings_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-/* SERVICES */
-DO $$ BEGIN
-  IF (SELECT count(group_id) FROM usergroups_services WHERE service_id IN ('edit_recipient_in_process', 'edit_recipient_outside_process')) = 0 THEN
-    INSERT INTO usergroups_services (group_id, service_id) 
-    SELECT usergroups.group_id, 'edit_recipient_in_process' FROM usergroups
-    LEFT JOIN usergroups_services ON usergroups.group_id = usergroups_services.group_id AND usergroups_services.service_id = 'add_copy_in_process'
-    WHERE service_id is null;
-
-    INSERT INTO usergroups_services (group_id, service_id)
-    SELECT usergroups.group_id, 'edit_recipient_outside_process' FROM usergroups
-    LEFT JOIN usergroups_services ON usergroups.group_id = usergroups_services.group_id AND usergroups_services.service_id = 'add_copy_in_indexing_validation'
-    WHERE service_id is null;
-
-    DELETE FROM usergroups_services WHERE service_id in ('add_copy_in_process', 'add_copy_in_indexing_validation');
-  END IF;
-END$$;
-
-DROP TABLE IF EXISTS exports_templates;
-CREATE TABLE exports_templates
-(
-id serial NOT NULL,
-user_id INTEGER NOT NULL,
-format character varying(3) NOT NULL,
-delimiter character varying(3),
-data json DEFAULT '[]' NOT NULL,
-CONSTRAINT exports_templates_pkey PRIMARY KEY (id),
-CONSTRAINT exports_templates_unique_key UNIQUE (user_id, format)
-)
-WITH (OIDS=FALSE);
-
-ALTER TABLE baskets DROP COLUMN IF EXISTS id;
-ALTER TABLE baskets ADD COLUMN id serial;
-ALTER TABLE baskets ADD UNIQUE (id);
-
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS id;
-ALTER TABLE groupbasket ADD COLUMN id serial;
-ALTER TABLE groupbasket ADD UNIQUE (id);
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS list_display;
-ALTER TABLE groupbasket ADD COLUMN list_display json DEFAULT '[]';
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mlb_coll_ext') AND attname = 'recommendation_limit_date') = 1 THEN
-    ALTER TABLE res_letterbox ADD COLUMN opinion_limit_date TIMESTAMP without TIME ZONE DEFAULT NULL;
-    UPDATE res_letterbox SET opinion_limit_date = mlb_coll_ext.recommendation_limit_date 
-    FROM mlb_coll_ext
-    WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND recommendation_limit_date IS NOT NULL;
-    ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS recommendation_limit_date;
-  END IF;
-END$$;
-
-/* Replace occurence in basket_clause */
-UPDATE baskets SET basket_clause = regexp_replace(basket_clause,'recommendation_limit_date','opinion_limit_date','g');
-UPDATE baskets SET basket_res_order = regexp_replace(basket_res_order,'recommendation_limit_date','opinion_limit_date','g');
-
-/* PARAM LIST DISPLAY */
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'groupbasket') AND attname = 'result_page') THEN
-    UPDATE groupbasket SET list_display = '[{"value":"getPriority","cssClasses":[],"icon":"fa-traffic-light"},{"value":"getCategory","cssClasses":[],"icon":"fa-exchange-alt"},{"value":"getDoctype","cssClasses":[],"icon":"fa-suitcase"},{"value":"getAssignee","cssClasses":[],"icon":"fa-sitemap"},{"value":"getRecipients","cssClasses":[],"icon":"fa-user"},{"value":"getSenders","cssClasses":[],"icon":"fa-book"},{"value":"getCreationAndProcessLimitDates","cssClasses":["align_rightData"],"icon":"fa-calendar"}]' WHERE result_page = 'list_with_attachments' OR result_page = 'list_copies';
-    UPDATE groupbasket SET list_display = '[{"value":"getPriority","cssClasses":[],"icon":"fa-traffic-light"},{"value":"getCategory","cssClasses":[],"icon":"fa-exchange-alt"},{"value":"getDoctype","cssClasses":[],"icon":"fa-suitcase"},{"value":"getParallelOpinionsNumber","cssClasses":["align_rightData"],"icon":"fa-comment-alt"},{"value":"getOpinionLimitDate","cssClasses":["align_rightData"],"icon":"fa-stopwatch"}]' WHERE result_page = 'list_with_avis';
-    UPDATE groupbasket SET list_display = '[{"value":"getPriority","cssClasses":[],"icon":"fa-traffic-light"},{"value":"getDoctype","cssClasses":[],"icon":"fa-suitcase"},{"value":"getVisaWorkflow","cssClasses":[],"icon":"fa-list-ol"},{"value":"getCreationAndProcessLimitDates","cssClasses":["align_rightData"],"icon":"fa-calendar"}]' WHERE result_page = 'list_with_signatory';
-
-    ALTER TABLE groupbasket DROP COLUMN IF EXISTS result_page;
-  END IF;
-END $$;
-
-/* ACTIONS */
-ALTER TABLE actions DROP COLUMN IF EXISTS component;
-ALTER TABLE actions ADD COLUMN component CHARACTER VARYING (128);
-UPDATE actions SET component = 'v1Action' WHERE action_page IN ('put_in_copy', 'process', 'index_mlb', 'validate_mail', 'sendFileWS', 'sendDataWS', 'close_mail_and_index', 'close_mail_with_attachment', 'send_attachments_to_contact', 'send_to_contact_with_mandatory_attachment', 'visa_workflow', 'interrupt_visa', 'rejection_visa_redactor', 'rejection_visa_previous', 'redirect_visa_entity', 'send_to_visa', 'send_signed_docs', 'send_docs_to_recommendation', 'validate_recommendation', 'send_to_avis', 'avis_workflow', 'avis_workflow_simple', 'export_seda', 'check_acknowledgement', 'check_reply', 'purge_letter', 'reset_letter');
-UPDATE actions SET component = 'confirmAction' WHERE action_page = 'confirm_status' OR action_page is null OR action_page = '';
-UPDATE actions SET component = 'updateDepartureDateAction' WHERE action_page = 'confirm_status_with_update_date';
-UPDATE actions SET component = 'viewDoc' WHERE action_page = 'view';
-UPDATE actions SET component = 'closeMailAction' WHERE action_page = 'close_mail';
-UPDATE actions SET component = 'enabledBasketPersistenceAction' WHERE action_page = 'set_persistent_mode_on';
-UPDATE actions SET component = 'disabledBasketPersistenceAction' WHERE action_page = 'set_persistent_mode_off';
-UPDATE actions SET component = 'resMarkAsReadAction' WHERE action_page = 'mark_as_read';
-UPDATE actions SET component = 'signatureBookAction' WHERE action_page = 'visa_mail';
-UPDATE actions SET component = 'redirectAction' WHERE action_page = 'redirect';
-UPDATE actions SET component = 'sendExternalSignatoryBookAction' WHERE action_page = 'sendToExternalSignatureBook';
-
-/*SHIPPING*/
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS in_send_attach;
-ALTER TABLE res_attachments ADD COLUMN in_send_attach boolean NOT NULL DEFAULT false;
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS in_send_attach;
-ALTER TABLE res_version_attachments ADD COLUMN in_send_attach boolean NOT NULL DEFAULT false;
-
-/* Acknowledgement Receipts */
-DROP TABLE IF EXISTS acknowledgement_receipts;
-CREATE TABLE acknowledgement_receipts
-(
-id serial NOT NULL,
-res_id INTEGER NOT NULL,
-type CHARACTER VARYING(16) NOT NULL,
-format CHARACTER VARYING(8) NOT NULL,
-user_id INTEGER NOT NULL,
-contact_address_id INTEGER NOT NULL,
-creation_date timestamp without time zone NOT NULL,
-send_date timestamp without time zone,
-docserver_id CHARACTER VARYING(128) NOT NULL,
-path CHARACTER VARYING(256) NOT NULL,
-filename CHARACTER VARYING(256) NOT NULL,
-fingerprint CHARACTER VARYING(256) NOT NULL,
-CONSTRAINT acknowledgement_receipts_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-DELETE FROM docserver_types WHERE docserver_type_id = 'ACKNOWLEDGEMENT_RECEIPTS';
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled) VALUES ('ACKNOWLEDGEMENT_RECEIPTS', 'Accusés de réception', 'Y');
-DELETE FROM docservers WHERE docserver_id = 'ACKNOWLEDGEMENT_RECEIPTS';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, size_limit_number, actual_size_number, path_template, creation_date, coll_id)
-VALUES ('ACKNOWLEDGEMENT_RECEIPTS', 'ACKNOWLEDGEMENT_RECEIPTS', 'Dépôt des AR', 'N', 50000000000, 0, '/opt/maarch/docservers/acknowledgment_receipts/', '2019-04-19 22:22:22.201904', 'letterbox_coll');
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_letterbox') AND attname = 'sve_start_date') = 1 THEN
-    INSERT INTO acknowledgement_receipts (res_id, type, format, user_id, contact_address_id, creation_date, send_date, docserver_id, path, filename, fingerprint) 
-    SELECT res_id, 'simple', 'html', 0, 0, sve_start_date, sve_start_date, 0, 0, 0, 0 FROM res_letterbox WHERE sve_start_date is not null;
-    ALTER TABLE res_letterbox DROP COLUMN IF EXISTS sve_start_date;
-  END IF;
-END$$;
-
-/* Foldertypes */
-UPDATE foldertypes SET coll_id = 'letterbox_coll' WHERE coll_id <> 'letterbox_coll';
-
-/* REFACTORING */
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS flag_notif;
-UPDATE res_letterbox SET locker_user_id = NULL;
-ALTER TABLE res_letterbox ALTER COLUMN locker_user_id DROP DEFAULT;
-ALTER TABLE res_letterbox ALTER COLUMN locker_user_id TYPE INTEGER USING locker_user_id::integer;
-ALTER TABLE res_letterbox ALTER COLUMN locker_user_id SET DEFAULT NULL;
-ALTER TABLE notes DROP COLUMN IF EXISTS tablename;
-ALTER TABLE notes DROP COLUMN IF EXISTS coll_id;
-ALTER TABLE notes DROP COLUMN IF EXISTS type;
-ALTER TABLE notes ADD COLUMN type CHARACTER VARYING (32) DEFAULT 'resource' NOT NULL;
-ALTER TABLE users DROP COLUMN IF EXISTS thumbprint;
-ALTER TABLE entities DROP COLUMN IF EXISTS entity_path;
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'notes') AND attname = 'date_note') = 1 THEN
-	  ALTER TABLE notes RENAME COLUMN date_note TO creation_date;
-	  ALTER sequence notes_seq RENAME TO notes_id_seq;
-  END IF;
-END$$;
-ALTER TABLE res_mark_as_read DROP COLUMN IF EXISTS coll_id;
-
-UPDATE listinstance SET added_by_entity = 'superadmin' WHERE added_by_user = 'superadmin';
-UPDATE listinstance SET added_by_entity = 'superadmin' WHERE listinstance_id IN 
-	(SELECT listinstance_id FROM listinstance LEFT JOIN entities ON listinstance.added_by_entity = entities.entity_id WHERE entities.entity_id IS null);
-
-UPDATE listinstance SET added_by_entity = 'superadmin' WHERE listinstance_id IN 
-	(SELECT listinstance_id 
-	 FROM listinstance 
-	 LEFT JOIN users_entities ON listinstance.added_by_user = users_entities.user_id 
-	 LEFT JOIN entities ON users_entities.entity_id = entities.entity_id 
-	 WHERE primary_entity = 'Y' AND entities.entity_id IS NULL);
-
-UPDATE listinstance SET added_by_entity =
-    (SELECT entity_id FROM users_entities WHERE users_entities.user_id = listinstance.added_by_user AND primary_entity = 'Y')
-WHERE added_by_entity IS NULL OR added_by_entity = '';
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'listinstance_history') AND attname = 'updated_by_user') THEN
-    ALTER TABLE listinstance_history DROP COLUMN IF EXISTS user_id;
-    ALTER TABLE listinstance_history ADD COLUMN user_id integer;
-    UPDATE listinstance_history set user_id = (select id FROM users where users.user_id = listinstance_history.updated_by_user);
-    UPDATE listinstance_history set user_id = 0 WHERE user_id IS NULL;
-    ALTER TABLE listinstance_history ALTER COLUMN user_id set not null;
-    ALTER TABLE listinstance_history DROP COLUMN IF EXISTS updated_by_user;
-  END IF;
-END$$;
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'contact_addresses') AND attname = 'external_contact_id') THEN
-    ALTER TABLE contact_addresses DROP COLUMN IF EXISTS external_id;
-    ALTER TABLE contact_addresses ADD COLUMN external_id jsonb DEFAULT '{}';
-    UPDATE contact_addresses SET external_id = json_build_object('m2m', external_contact_id);
-    ALTER TABLE contact_addresses DROP COLUMN IF EXISTS external_contact_id;
-  END IF;
-END$$;
-DO $$ BEGIN
-  IF (SELECT count(column_name) from information_schema.columns where table_name = 'res_attachments' and column_name = 'external_id' and data_type != 'jsonb') THEN
-    ALTER TABLE res_attachments DROP COLUMN IF EXISTS external_id_tmp;
-    ALTER TABLE res_attachments ADD COLUMN external_id_tmp jsonb DEFAULT '{}';
-    UPDATE res_attachments SET external_id_tmp = json_build_object('signatureBookId', external_id);
-    ALTER TABLE res_attachments DROP COLUMN IF EXISTS external_id;
-	  ALTER TABLE res_attachments RENAME COLUMN external_id_tmp TO external_id;
-  END IF;
-END$$;
-DO $$ BEGIN
-  IF (SELECT count(column_name) from information_schema.columns where table_name = 'res_version_attachments' and column_name = 'external_id' and data_type != 'jsonb') THEN
-    ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS external_id_tmp;
-    ALTER TABLE res_version_attachments ADD COLUMN external_id_tmp jsonb DEFAULT '{}';
-    UPDATE res_version_attachments SET external_id_tmp = json_build_object('signatureBookId', external_id);
-    ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS external_id;
-	  ALTER TABLE res_version_attachments RENAME COLUMN external_id_tmp TO external_id;
-  END IF;
-END$$;
-DO $$ BEGIN
-  IF (SELECT count(column_name) from information_schema.columns where table_name = 'res_letterbox' and column_name = 'external_id' and data_type != 'jsonb') THEN
-	  ALTER TABLE res_letterbox RENAME COLUMN external_id TO external_reference;
-    ALTER TABLE res_letterbox ADD COLUMN external_id jsonb DEFAULT '{}';
-    UPDATE res_letterbox SET external_id = json_build_object('publikId', external_reference) WHERE external_link is not NULL;
-    UPDATE res_letterbox SET external_reference = NULL WHERE external_link is not NULL;
-  END IF;
-END$$;
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_letterbox') AND attname = 'scan_date') = 0 THEN
-    ALTER TABLE res_letterbox ADD COLUMN scan_date timestamp without time zone;
-    ALTER TABLE res_letterbox ADD COLUMN scan_user CHARACTER VARYING (50) DEFAULT NULL::character varying;
-    ALTER TABLE res_letterbox ADD COLUMN scan_location CHARACTER VARYING (255) DEFAULT NULL::character varying;
-    ALTER TABLE res_letterbox ADD COLUMN scan_wkstation CHARACTER VARYING (255) DEFAULT NULL::character varying;
-    ALTER TABLE res_letterbox ADD COLUMN scan_batch CHARACTER VARYING (50) DEFAULT NULL::character varying;
-    ALTER TABLE res_letterbox ADD COLUMN scan_postmark CHARACTER VARYING (50) DEFAULT NULL::character varying;
-  END IF;
-END$$;
-
-DELETE FROM groupbasket where group_id in (select group_id from usergroups where enabled = 'N');
-DELETE FROM groupbasket_redirect where group_id in (select group_id from usergroups where enabled = 'N');
-DELETE FROM usergroup_content where group_id in (select group_id from usergroups where enabled = 'N');
-DELETE FROM usergroups_reports where group_id in (select group_id from usergroups where enabled = 'N');
-DELETE FROM usergroups_services where group_id in (select group_id from usergroups where enabled = 'N');
-DELETE FROM usergroups WHERE enabled = 'N';
-
-/* RE-CREATE VIEW*/
-CREATE OR REPLACE VIEW res_view_letterbox AS
- SELECT r.tablename,
-    r.is_multi_docservers,
-    r.res_id,
-    r.type_id,
-    r.policy_id,
-    r.cycle_id,
-    d.description AS type_label,
-    d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label,
-    dfl.css_style AS doctype_first_level_style,
-    d.doctypes_second_level_id,
-    dsl.doctypes_second_level_label,
-    dsl.css_style AS doctype_second_level_style,
-    r.format,
-    r.typist,
-    r.creation_date,
-    r.modification_date,
-    r.relation,
-    r.docserver_id,
-    r.folders_system_id,
-    f.folder_id,
-    f.destination AS folder_destination,
-    f.is_frozen AS folder_is_frozen,
-    r.path,
-    r.filename,
-    r.fingerprint,
-    r.offset_doc,
-    r.filesize,
-    r.status,
-    r.work_batch,
-    r.doc_date,
-    r.description,
-    r.source,
-    r.author,
-    r.reference_number,
-    r.external_reference,
-    r.external_id,
-    r.external_link,
-    r.departure_date,
-    r.opinion_limit_date,
-    r.department_number_id,
-    r.barcode,
-    r.external_signatory_book_id,
-    r.custom_t1 AS doc_custom_t1,
-    r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3,
-    r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5,
-    r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7,
-    r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9,
-    r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11,
-    r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13,
-    r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15,
-    r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2,
-    r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4,
-    r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6,
-    r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8,
-    r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10,
-    r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2,
-    r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4,
-    r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1,
-    r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3,
-    r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5,
-    r.scan_date,
-    r.scan_user,
-    r.scan_location,
-    r.scan_wkstation,
-    r.scan_batch,
-    r.scan_postmark,
-    f.foldertype_id,
-    ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1,
-    f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3,
-    f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5,
-    f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7,
-    f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9,
-    f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11,
-    f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13,
-    f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15,
-    f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2,
-    f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4,
-    f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6,
-    f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8,
-    f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10,
-    f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2,
-    f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4,
-    f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1,
-    f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3,
-    f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5,
-    f.is_complete AS fold_complete,
-    f.status AS fold_status,
-    f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id,
-    f.folder_level,
-    f.folder_name,
-    f.creation_date AS fold_creation_date,
-    r.initiator,
-    r.destination,
-    r.dest_user,
-    r.confidentiality,
-    mlb.category_id,
-    mlb.exp_contact_id,
-    mlb.exp_user_id,
-    mlb.dest_user_id,
-    mlb.dest_contact_id,
-    mlb.address_id,
-    mlb.nature_id,
-    mlb.alt_identifier,
-    mlb.admission_date,
-    mlb.process_limit_date,
-    mlb.closing_date,
-    mlb.alarm1_date,
-    mlb.alarm2_date,
-    mlb.flag_alarm1,
-    mlb.flag_alarm2,
-    mlb.is_multicontacts,
-    r.subject,
-    r.identifier,
-    r.title,
-    r.priority,
-    r.locker_user_id,
-    r.locker_time,
-    ca.case_id,
-    ca.case_label,
-    ca.case_description,
-    en.entity_label,
-    en.entity_type AS entitytype,
-    cont.contact_id,
-    cont.firstname AS contact_firstname,
-    cont.lastname AS contact_lastname,
-    cont.society AS contact_society,
-    u.lastname AS user_lastname,
-    u.firstname AS user_firstname
-   FROM doctypes d,
-    doctypes_first_level dfl,
-    doctypes_second_level dsl,
-    res_letterbox r
-     LEFT JOIN entities en ON r.destination::text = en.entity_id::text
-     LEFT JOIN folders f ON r.folders_system_id = f.folders_system_id
-     LEFT JOIN cases_res cr ON r.res_id = cr.res_id
-     LEFT JOIN mlb_coll_ext mlb ON mlb.res_id = r.res_id
-     LEFT JOIN foldertypes ft ON f.foldertype_id = ft.foldertype_id AND f.status::text <> 'DEL'::text
-     LEFT JOIN cases ca ON cr.case_id = ca.case_id
-     LEFT JOIN contacts_v2 cont ON mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id
-     LEFT JOIN users u ON mlb.exp_user_id::text = u.user_id::text OR mlb.dest_user_id::text = u.user_id::text
-  WHERE r.type_id = d.type_id AND d.doctypes_first_level_id = dfl.doctypes_first_level_id AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-DROP VIEW IF EXISTS view_contacts;
-CREATE OR REPLACE VIEW view_contacts AS
- SELECT c.contact_id, c.contact_type, c.is_corporate_person, c.society, c.society_short, c.firstname AS contact_firstname
-, c.lastname AS contact_lastname, c.title AS contact_title, c.function AS contact_function, c.other_data AS contact_other_data
-, c.user_id AS contact_user_id, c.entity_id AS contact_entity_id, c.creation_date, c.update_date, c.enabled AS contact_enabled, ca.id AS ca_id
-, ca.contact_purpose_id, ca.departement, ca.firstname, ca.lastname, ca.title, ca.function, ca.occupancy
-, ca.address_num, ca.address_street, ca.address_complement, ca.address_town, ca.address_postal_code, ca.address_country
-, ca.phone, ca.email, ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private, ca.enabled, ca.external_id
-, cp.label as contact_purpose_label, ct.label as contact_type_label
-   FROM contacts_v2 c
-   RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id
-   LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id
-   LEFT JOIN contact_types ct ON c.contact_type = ct.id;
-
-DROP VIEW IF EXISTS res_view_attachments;
-CREATE OR REPLACE VIEW res_view_attachments AS
-  SELECT '0' as res_id, res_id as res_id_version, title, subject, description, type_id, format, typist,
-  creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path,
-  filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master, in_signature_book, in_send_attach, signatory_user_serial_id
-  FROM res_version_attachments
-  UNION ALL
-  SELECT res_id, '0' as res_id_version, title, subject, description, type_id, format, typist,
-  creation_date, fulltext_result, author, identifier, source, relation, doc_date, docserver_id, folders_system_id, path,
-  filename, offset_doc, fingerprint, filesize, status, destination, validation_date, effective_date, origin, priority, initiator, dest_user, external_id,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0', in_signature_book, in_send_attach, signatory_user_serial_id
-  FROM res_attachments;
diff --git a/migration/19.04/migrate.sh b/migration/19.04/migrate.sh
deleted file mode 100755
index 427f37a3ac14e9b36ac833e473e3085442bad190..0000000000000000000000000000000000000000
--- a/migration/19.04/migrate.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-php ./migrateSendmail.php
-php ./migrateSendmail_2.php
-php ./migrateExport.php
-php ./migrateFeature.php
-php ./migrateNewNature.php
-php ./refactorPriorities.php
-php ./refactorRemoteSignatoryBooks.php
diff --git a/migration/19.04/migrateExport.php b/migration/19.04/migrateExport.php
deleted file mode 100755
index 5d15107187a8058d0c89e9417935ddfc1ee31dbd..0000000000000000000000000000000000000000
--- a/migration/19.04/migrateExport.php
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/export.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-    } else {
-        $xmlfile = simplexml_load_file("apps/maarch_entreprise/xml/export.xml");
-    }
-
-    if ($xmlfile) {
-        $delimiter = (string)$xmlfile->CSVOPTIONS->DELIMITER;
-
-        $aData = [];
-        if (!empty($xmlfile->letterbox_coll->FIELD)) {
-            foreach ($xmlfile->letterbox_coll->FIELD as $value) {
-                $field = (string)$value->DATABASE_FIELD;
-                if (strpos($field, ".") !== false) {
-                    $aField = explode(".", $field);
-                    $field  = $aField[1];
-                }
-                if ($field == 'typist') {
-                    printf("La valeur typist a été remplacé par la fonction getTypist\n");
-                    $function  = $xmlfile->letterbox_coll->FUNCTIONS->addChild('FUNCTION');
-                    $function->addChild('CALL', 'getTypist');
-                    $function->addChild('LIBELLE', 'Rédacteur');
-                    continue;
-                } elseif ($field == 'dest_user') {
-                    printf("La valeur dest_user a été remplacé par la fonction getAssignee\n");
-                    $function  = $xmlfile->letterbox_coll->FUNCTIONS->addChild('FUNCTION');
-                    $function->addChild('CALL', 'getAssignee');
-                    $function->addChild('LIBELLE', 'Attributaire');
-                    continue;
-                } elseif ($field == 'destination') {
-                    printf("La valeur destination a été remplacé par la fonction getDestinationEntity\n");
-                    $function  = $xmlfile->letterbox_coll->FUNCTIONS->addChild('FUNCTION');
-                    $function->addChild('CALL', 'getDestinationEntity');
-                    $function->addChild('LIBELLE', 'Libellé de l\'entité traitante');
-                    continue;
-                } elseif ($field == 'entitytype') {
-                    printf("La valeur entitytype a été remplacé par la fonction getDestinationEntityType\n");
-                    $function  = $xmlfile->letterbox_coll->FUNCTIONS->addChild('FUNCTION');
-                    $function->addChild('CALL', 'getDestinationEntityType');
-                    $function->addChild('LIBELLE', 'Type de l\'entité traitante');
-                    continue;
-                } elseif (in_array($field, ['contact_firstname', 'contact_lastname', 'contact_society'])) {
-                    printf("La valeur ".$field." a été remplacé par la fonction getSender\n");
-                    continue;
-                }
-
-                if (!in_array($field, [
-                    'res_id',
-                    'type_label',
-                    'doctypes_first_level_label',
-                    'doctypes_second_level_label',
-                    'format',
-                    'doc_date',
-                    'reference_number',
-                    'departure_date',
-                    'department_number_id',
-                    'barcode',
-                    'fold_status',
-                    'folder_name',
-                    'confidentiality',
-                    'nature_id',
-                    'alt_identifier',
-                    'admission_date',
-                    'process_limit_date',
-                    'recommendation_limit_date',
-                    'closing_date',
-                    'sve_start_date',
-                    'subject',
-                    'case_label'])) {
-                    printf("Le champ " . $field . " a été trouvé mais non migré car non maintenue\n");
-                    continue;
-                }
-                $oData             = new stdClass();
-                $oData->value      = $field;
-                $oData->label      = (string)$value->LIBELLE;
-                $oData->isFunction = false;
-                $aData[] = $oData;
-            }
-        }
-
-        if (!empty($xmlfile->letterbox_coll->FUNCTIONS->FUNCTION)) {
-            $sender  = $xmlfile->letterbox_coll->FUNCTIONS->addChild('FUNCTION');
-            $sender->addChild('CALL', 'getSender');
-            $sender->addChild('LIBELLE', 'Expéditeur');
-            $recipient  = $xmlfile->letterbox_coll->FUNCTIONS->addChild('FUNCTION');
-            $recipient->addChild('CALL', 'getRecipient');
-            $recipient->addChild('LIBELLE', 'Destinataire');
-
-            foreach ($xmlfile->letterbox_coll->FUNCTIONS->FUNCTION as $value) {
-                $functionName = (string)$value->CALL;
-                if ($functionName == 'get_status') {
-                    $functionName = 'getStatus';
-                } elseif ($functionName == 'get_priority') {
-                    $functionName = 'getPriority';
-                } elseif ($functionName == 'retrieve_copies') {
-                    $functionName = 'getCopies';
-                } elseif ($functionName == 'makeLink_detail') {
-                    $functionName = 'getDetailLink';
-                } elseif ($functionName == 'get_parent_folder') {
-                    $functionName = 'getParentFolder';
-                } elseif ($functionName == 'get_category_label') {
-                    $functionName = 'getCategory';
-                } elseif ($functionName == 'get_entity_initiator_short_label') {
-                    $functionName = 'getInitiatorEntity';
-                } elseif ($functionName == 'get_entity_dest_short_label') {
-                    printf("La fonction get_entity_dest_short_label a été remplacé par la fonction getDestinationEntity\n");
-                    continue;
-                } elseif ($functionName == 'get_contact_type') {
-                    printf("La fonction get_contact_type a été remplacé par la fonction getSender\n");
-                    continue;
-                } elseif ($functionName == 'get_contact_civility') {
-                    printf("La fonction get_contact_civility a été remplacé par la fonction getSender\n");
-                    continue;
-                } elseif ($functionName == 'get_contact_function') {
-                    printf("La fonction get_contact_function a été remplacé par la fonction getSender\n");
-                    continue;
-                } elseif ($functionName == 'get_tags') {
-                    $functionName = 'getTags';
-                } elseif ($functionName == 'get_signatory_name') {
-                    $functionName = 'getSignatories';
-                } elseif ($functionName == 'get_signatory_date') {
-                    $functionName = 'getSignatureDates';
-                } elseif (!in_array($functionName, ['getTypist', 'getAssignee', 'getDestinationEntity', 'getDestinationEntityType', 'getSender', 'getRecipient'])) {
-                    printf("La fonction " . $functionName . " a été trouvé mais non migré car non maintenue.\n");
-                    continue;
-                }
-                $oData             = new stdClass();
-                $oData->value      = $functionName;
-                $oData->label      = (string)$value->LIBELLE;
-                $oData->isFunction = true;
-                $aData[] = $oData;
-            }
-        }
-
-        if (!empty($xmlfile->letterbox_coll->EMPTYS->EMPTY)) {
-            $oData             = new stdClass();
-            $oData->value      = '';
-            $oData->label      = 'Commentaire';
-            $oData->isFunction = true;
-            $aData[] = $oData;
-        }
-
-        $users = \User\models\UserModel::get([
-            'select' => ['id'],
-            'where'  => ['status != ?'],
-            'data'   => ['DEL']
-            ]);
-
-        $aValues = [];
-        foreach ($users as $user) {
-            $aValues[] = [$user['id'], 'csv', $delimiter, json_encode($aData)];
-        }
-
-        \SrcCore\models\DatabaseModel::insertMultiple([
-            'table'     => 'exports_templates',
-            'columns'   => ['user_id', 'format', 'delimiter', 'data'],
-            'values'    => $aValues
-        ]);
-
-        $migrated++;
-    }
-}
-
-printf($migrated . " custom(s) avec une configuration export trouvé(s) et migré(s).\n");
diff --git a/migration/19.04/migrateFeature.php b/migration/19.04/migrateFeature.php
deleted file mode 100644
index a2ebe5d4cd7d1d9c568ef9902962011cec33fd09..0000000000000000000000000000000000000000
--- a/migration/19.04/migrateFeature.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/features.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-    } else {
-        $xmlfile = simplexml_load_file("apps/maarch_entreprise/xml/features.xml");
-    }
-
-    if ($xmlfile) {
-        $keepDest = (string)$xmlfile->FEATURES->dest_to_copy_during_redirection;
-
-        if (!empty($keepDest) && $keepDest == 'true') {
-            \Parameter\models\ParameterModel::create([
-                'id'                => 'keepDestForRedirection',
-                'description'       => 'Si activé (1), mets le destinataire en copie de la liste de diffusion lors d\'une action de redirection',
-                'param_value_int'   => 1
-            ]);
-        } else {
-            \Parameter\models\ParameterModel::create([
-                'id'                => 'keepDestForRedirection',
-                'description'       => 'Si activé (1), mets le destinataire en copie de la liste de diffusion lors d\'une action de redirection',
-                'param_value_int'   => 0
-            ]);
-        }
-
-        $migrated++;
-    }
-}
-
-printf($migrated . " custom(s) avec un fichier features.xml trouvé(s) et migré(s).\n");
diff --git a/migration/19.04/migrateNewNature.php b/migration/19.04/migrateNewNature.php
deleted file mode 100644
index fc2a4fa6d780a4ddb6f89b3c0d93ea0e6f01f234..0000000000000000000000000000000000000000
--- a/migration/19.04/migrateNewNature.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$migrated = 0;
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $natures = [];
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/entreprise.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        
-        if ($loadedXml) {
-            $default_nature = (string)$loadedXml->mail_natures->default_nature;
-            unset($loadedXml->mail_natures->default_nature);
-            $newNature = $loadedXml->mail_natures->addChild('nature');
-            $newNature->addAttribute('with_reference', 'true');
-            $newNature->addChild('id', 'message_exchange');
-            $newNature->addChild('label', '_NUMERIC_PACKAGE');
-
-            $loadedXml->mail_natures->addChild('default_nature', $default_nature);
-            $res = formatXml($loadedXml);
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-            $migrated++;
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
-
-printf($migrated . " custom(s) avec entreprise.xml (natures) trouvé(s) et migré(s).\n");
-
-function formatXml($simpleXMLElement)
-{
-    $xmlDocument = new DOMDocument('1.0');
-    $xmlDocument->preserveWhiteSpace = false;
-    $xmlDocument->formatOutput = true;
-    $xmlDocument->loadXML($simpleXMLElement->asXML());
-
-    return $xmlDocument->saveXML();
-}
diff --git a/migration/19.04/migrateSendmail.php b/migration/19.04/migrateSendmail.php
deleted file mode 100644
index e61f50068b1792b590358dff3a36e731a60fcb99..0000000000000000000000000000000000000000
--- a/migration/19.04/migrateSendmail.php
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/modules/sendmail/batch/config/config.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-    }
-
-    if ($xmlfile) {
-        $pass = '';
-        if (!empty((string)$xmlfile->MAILER->smtp_password)) {
-            $pass = \SrcCore\models\PasswordModel::encrypt(['password' => (string)$xmlfile->MAILER->smtp_password]);
-        }
-
-        $data = [
-            'type'     => (string)$xmlfile->MAILER->type,
-            'host'     => (string)$xmlfile->MAILER->smtp_host,
-            'port'     => (int)$xmlfile->MAILER->smtp_port,
-            'user'     => (string)$xmlfile->MAILER->smtp_user,
-            'password' => $pass,
-            'auth'     => (string)$xmlfile->MAILER->smtp_auth == 'true' ? true : false,
-            'from'     => (string)$xmlfile->MAILER->mailfrom,
-            'secure'   => 'ssl',
-            'charset'  => 'utf-8'
-        ];
-        $data = json_encode($data);
-        \Configuration\models\ConfigurationModel::update(['set' => ['value' => $data], 'where' => ['service = ?'], 'data' => ['admin_email_server']]);
-
-        $migrated++;
-    }
-
-    $sendmails = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['*'],
-        'table'     => ['sendmail'],
-        'order_by'  => ['creation_date']
-    ]);
-
-    $aValues = [];
-    $countMail = 0;
-    foreach ($sendmails as $sendmail) {
-        if (empty($sendmail['user_id'])) {
-            continue;
-        }
-        $user = \User\models\UserModel::getByLogin(['login' => $sendmail['user_id'], 'select' => ['id']]);
-        $sender = explode(',', $sendmail['sender_email']);
-        if (empty($sender[1])) {
-            $sender = ['email' => $sender[0]];
-        } else {
-            $entity = \Entity\models\EntityModel::getByEntityId(['entityId' => $sender[0], 'select' => ['id']]);
-            $sender = ['email' => $sender[1], 'entityId' => $entity['id']];
-        }
-        $recipients = explode(',', $sendmail['to_list']);
-        $cc = explode(',', $sendmail['cc_list']);
-        $cc = empty($cc[0]) ? [] : $cc;
-        $cci = explode(',', $sendmail['cci_list']);
-        $cci = empty($cci[0]) ? [] : $cci;
-
-        $document = [
-            'id'        => $sendmail['res_id'],
-            'isLinked'  => $sendmail['is_res_master_attached'] == 'Y',
-            'original'  => false,
-        ];
-
-        $attachments = [];
-
-        $rawAttachments = explode(',', $sendmail['res_attachment_id_list']);
-        if (!empty($rawAttachments[0])) {
-            foreach ($rawAttachments as $rawAttachment) {
-                $id = $rawAttachment;
-                $original = true;
-                if (strpos($rawAttachment, '#') !== false) {
-                    $id = substr($rawAttachment, 0, strpos($rawAttachment, '#'));
-                    $original = false;
-                }
-                $attachments[] = [
-                    'id'        => (int)$id,
-                    'isVersion' => false,
-                    'original'  => $original,
-                ];
-            }
-        }
-
-        $rawVersionAttachments = explode(',', $sendmail['res_version_att_id_list']);
-        if (!empty($rawVersionAttachments[0])) {
-            foreach ($rawVersionAttachments as $rawAttachment) {
-                $id = $rawAttachment;
-                $original = true;
-                if (strpos($rawAttachment, '#') !== false) {
-                    $id = substr($rawAttachment, 0, strpos($rawAttachment, '#'));
-                    $original = false;
-                }
-                $attachments[] = [
-                    'id'        => (int)$id,
-                    'isVersion' => true,
-                    'original'  => $original,
-                ];
-            }
-        }
-        if (!empty($attachments)) {
-            $document['attachments'] = $attachments;
-        }
-        $notes = explode(',', $sendmail['note_id_list']);
-        if (!empty($notes[0])) {
-            $document['notes'] = [];
-            foreach ($notes as $note) {
-                $document['notes'][] = (int)$note;
-            }
-        }
-
-        if ($sendmail['email_status'] == 'S') {
-            $status = 'SENT';
-        } elseif ($sendmail['email_status'] == 'D') {
-            $status = 'DRAFT';
-        } elseif ($sendmail['email_status'] == 'W') {
-            $status = 'WAITING';
-        } else {
-            $status = 'ERROR';
-        }
-
-        $aValues[] = [
-            $user['id'],
-            json_encode($sender),
-            json_encode($recipients),
-            empty($cc) ? '[]' : json_encode($cc),
-            empty($cci) ? '[]' : json_encode($cci),
-            empty($sendmail['email_object']) ? null : $sendmail['email_object'],
-            empty($sendmail['email_body']) ? null : $sendmail['email_body'],
-            empty($document) ? null : json_encode($document),
-            $sendmail['is_html'] == 'Y' ? 'true' : 'false',
-            $status,
-            empty($sendmail['message_exchange_id']) ? null : $sendmail['message_exchange_id'],
-            $sendmail['creation_date'],
-            empty($sendmail['send_date']) ? null : $sendmail['send_date']
-        ];
-
-        $countMail++;
-
-        if ($countMail % 50 == 0) {
-            \SrcCore\models\DatabaseModel::insertMultiple([
-                'table'         => 'emails',
-                'columns'       => ['user_id', 'sender', 'recipients', 'cc', 'cci', 'object', 'body', 'document', 'is_html', 'status', 'message_exchange_id', 'creation_date', 'send_date'],
-                'values'        => $aValues
-            ]);
-            $aValues = [];
-        }
-    }
-
-    if (!empty($aValues)) {
-        \SrcCore\models\DatabaseModel::insertMultiple([
-            'table'         => 'emails',
-            'columns'       => ['user_id', 'sender', 'recipients', 'cc', 'cci', 'object', 'body', 'document', 'is_html', 'status', 'message_exchange_id', 'creation_date', 'send_date'],
-            'values'        => $aValues
-        ]);
-    }
-
-    printf($countMail . " email(s) migré(s) du custom {$custom} vers la nouvelle table.\n");
-}
-
-printf($migrated . " custom(s) avec une configuration sendmail trouvé(s) et migré(s).\n");
diff --git a/migration/19.04/migrateSendmail_2.php b/migration/19.04/migrateSendmail_2.php
deleted file mode 100644
index 1e188b2586ff136095bfdd1948b5089dde08076d..0000000000000000000000000000000000000000
--- a/migration/19.04/migrateSendmail_2.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/modules/sendmail/batch/config/externalMailsEntities.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-    }
-
-    if ($xmlfile) {
-        if (!is_dir("custom/{$custom}/modules/sendmail/xml")) {
-            echo "Création du dossier custom/{$custom}/modules/sendmail/xml...\n";
-            if (!mkdir("custom/{$custom}/modules/sendmail/xml", 0777, true)) {
-                die('Echec lors de la création des répertoires...');
-            }
-        }
-
-        rename("custom/{$custom}/modules/sendmail/batch/config/externalMailsEntities.xml", "custom/{$custom}/modules/sendmail/xml/externalMailsEntities.xml");
-
-        $migrated++;
-    }
-}
-
-printf($migrated . " custom(s) avec externalMailsEntities.xml trouvé(s) et déplacé(s).\n");
diff --git a/migration/19.04/refactorPriorities.php b/migration/19.04/refactorPriorities.php
deleted file mode 100644
index 7424152249133b1356687bacc29f6acc9aa19a53..0000000000000000000000000000000000000000
--- a/migration/19.04/refactorPriorities.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$migrated = 0;
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $priorities = [];
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/entreprise.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        if ($loadedXml) {
-            unset($loadedXml->priorities);
-            $res = $loadedXml->asXML();
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-            $migrated++;
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
-
-printf($migrated . " custom(s) avec entreprise.xml (priorities) trouvé(s) et migré(s).\n");
diff --git a/migration/19.04/refactorRemoteSignatoryBooks.php b/migration/19.04/refactorRemoteSignatoryBooks.php
deleted file mode 100644
index 5f7a34f9683bf2a20721352e68cfe9d0f80aa50b..0000000000000000000000000000000000000000
--- a/migration/19.04/refactorRemoteSignatoryBooks.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-chdir('../..');
-
-$migrated = 0;
-$nonReadableFiles = [];
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $priorities = [];
-    $path = "custom/{$custom}/modules/visa/xml/remoteSignatoryBooks.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        if ($loadedXml) {
-            $newSignatoryBook = $loadedXml->addChild('signatoryBook');
-            $newSignatoryBook->addChild('id', 'maarchParapheur');
-            $newSignatoryBook->addChild('userId', ' ');
-            $newSignatoryBook->addChild('password', ' ');
-            $newSignatoryBook->addChild('url', ' ');
-            $newSignatoryBook->addChild('signature', 'SIGN');
-            $newSignatoryBook->addChild('annotation', 'NOTE');
-            $newSignatoryBook->addChild('externalValidated', 'VAL');
-            $newSignatoryBook->addChild('externalRefused', 'REF');
-
-            $res = formatXml($loadedXml);
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-            ++$migrated;
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
-
-printf($migrated . " custom(s) avec un fichier remoteSignatoryBooks.xml trouvé(s) et refactoré(s).\n");
-
-function formatXml($simpleXMLElement)
-{
-    $xmlDocument = new DOMDocument('1.0');
-    $xmlDocument->preserveWhiteSpace = false;
-    $xmlDocument->formatOutput = true;
-    $xmlDocument->loadXML($simpleXMLElement->asXML());
-
-    return $xmlDocument->saveXML();
-}
diff --git a/migration/20.03/2003-postScript.sql b/migration/20.03/2003-postScript.sql
deleted file mode 100644
index 90bcd0a0b43a9e0d04d301578ba260284a60b93a..0000000000000000000000000000000000000000
--- a/migration/20.03/2003-postScript.sql
+++ /dev/null
@@ -1,196 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 19.04 to 20.03 (Run this file after migrate.sh) --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS view_contacts;
-
-DROP TABLE IF EXISTS cases;
-DROP TABLE IF EXISTS cases_res;
-
-DELETE FROM contacts_groups_lists WHERE contact_id IS NULL;
-
-DELETE FROM resources_folders WHERE res_id NOT IN (SELECT res_id FROM res_letterbox);
-
-DELETE FROM res_attachments WHERE attachment_type in ('converted_pdf', 'print_folder');
-
-DROP TABLE IF EXISTS contacts_res;
-DROP TABLE IF EXISTS contact_addresses;
-DROP TABLE IF EXISTS contact_communication;
-DROP TABLE IF EXISTS contact_purposes;
-DROP TABLE IF EXISTS contact_types;
-DROP TABLE IF EXISTS contacts_v2;
-
-UPDATE CONTACTS SET civility = null WHERE civility = '';
-UPDATE CONTACTS SET firstname = null WHERE firstname = '';
-UPDATE CONTACTS SET lastname = null WHERE lastname = '';
-UPDATE CONTACTS SET company = null WHERE company = '';
-UPDATE CONTACTS SET department = null WHERE department = '';
-UPDATE CONTACTS SET function = null WHERE function = '';
-UPDATE CONTACTS SET address_number = null WHERE address_number = '';
-UPDATE CONTACTS SET address_street = null WHERE address_street = '';
-UPDATE CONTACTS SET address_additional1 = null WHERE address_additional1 = '';
-UPDATE CONTACTS SET address_additional2 = null WHERE address_additional2 = '';
-UPDATE CONTACTS SET address_postcode = null WHERE address_postcode = '';
-UPDATE CONTACTS SET address_town = null WHERE address_town = '';
-UPDATE CONTACTS SET address_country = null WHERE address_country = '';
-UPDATE CONTACTS SET email = null WHERE email = '';
-UPDATE CONTACTS SET phone = null WHERE phone = '';
-UPDATE CONTACTS SET notes = null WHERE notes = '';
-
-UPDATE res_attachments SET attachment_type = 'response_project' WHERE attachment_type = 'outgoing_mail';
-UPDATE res_attachments SET attachment_type = 'signed_response' WHERE attachment_type = 'outgoing_mail_signed';
-UPDATE res_attachments SET attachment_type = 'simple_attachment' WHERE attachment_type = 'document_with_notes';
-
-ALTER TABLE acknowledgement_receipts ALTER COLUMN contact_id set not null;
-ALTER TABLE acknowledgement_receipts DROP COLUMN IF EXISTS contact_address_id;
-ALTER TABLE contacts_groups_lists ALTER COLUMN contact_id set not null;
-ALTER TABLE contacts_groups_lists DROP COLUMN IF EXISTS contact_addresses_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS dest_contact_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS dest_address_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS dest_user;
-ALTER TABLE contacts_filling DROP COLUMN IF EXISTS rating_columns;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS exp_contact_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS exp_user_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS dest_contact_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS dest_user_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS address_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS is_multicontacts;
-
-DROP TABLE IF EXISTS fp_fileplan;
-DROP TABLE IF EXISTS fp_fileplan_positions;
-DROP TABLE IF EXISTS fp_res_fileplan_positions;
-
-DROP TABLE IF EXISTS folder_tmp;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS folders_system_id;
-
-DROP TABLE IF EXISTS groupbasket_status;
-DROP TABLE IF EXISTS indexingmodels;
-
-DROP TABLE IF EXISTS mlb_coll_ext;
-DROP TABLE IF EXISTS res_version_attachments;
-DROP TABLE IF EXISTS adr_attachments_version;
-ALTER TABLE shippings DROP COLUMN IF EXISTS is_version;
-
-ALTER TABLE priorities DROP COLUMN IF EXISTS default_priority;
-
-DROP TABLE IF EXISTS doctypes_indexes;
-
-DROP TABLE IF EXISTS listmodels;
-
-DROP TABLE IF EXISTS res_linked;
-
-DROP TABLE IF EXISTS thesaurus;
-DROP TABLE IF EXISTS thesaurus_res;
-DROP SEQUENCE IF EXISTS thesaurus_id_seq;
-
-SELECT setval('tags_id_seq', (SELECT max(id)+1 FROM tags), false);
-SELECT setval('contacts_id_seq', (SELECT max(id)+1 FROM contacts), false);
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t1;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t2;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t3;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t4;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t5;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t6;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t7;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t8;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t9;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t10;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t11;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t12;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t13;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t14;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_t15;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d1;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d2;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d3;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d4;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d5;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d6;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d7;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d8;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d9;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_d10;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_n1;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_n2;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_n3;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_n4;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_n5;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_f1;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_f2;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_f3;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_f4;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_f5;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_date;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_user;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_location;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_wkstation;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_batch;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS scan_postmark;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS description;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS author;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS reference_number;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_reference;
-
-
-/* RE CREATE VIEWS */
-CREATE OR REPLACE VIEW res_view_letterbox AS
-SELECT r.res_id,
-       r.type_id,
-       r.policy_id,
-       r.cycle_id,
-       d.description AS type_label,
-       d.doctypes_first_level_id,
-       dfl.doctypes_first_level_label,
-       dfl.css_style AS doctype_first_level_style,
-       d.doctypes_second_level_id,
-       dsl.doctypes_second_level_label,
-       dsl.css_style AS doctype_second_level_style,
-       r.format,
-       r.typist,
-       r.creation_date,
-       r.modification_date,
-       r.docserver_id,
-       r.path,
-       r.filename,
-       r.fingerprint,
-       r.filesize,
-       r.status,
-       r.work_batch,
-       r.doc_date,
-       r.external_id,
-       r.departure_date,
-       r.opinion_limit_date,
-       r.barcode,
-       r.initiator,
-       r.destination,
-       r.dest_user,
-       r.confidentiality,
-       r.category_id,
-       r.alt_identifier,
-       r.admission_date,
-       r.process_limit_date,
-       r.closing_date,
-       r.alarm1_date,
-       r.alarm2_date,
-       r.flag_alarm1,
-       r.flag_alarm2,
-       r.subject,
-       r.priority,
-       r.locker_user_id,
-       r.locker_time,
-       r.custom_fields,
-       en.entity_label,
-       en.entity_type AS entitytype
-FROM doctypes d,
-     doctypes_first_level dfl,
-     doctypes_second_level dsl,
-     res_letterbox r
-    LEFT JOIN entities en ON r.destination::text = en.entity_id::text
-WHERE r.type_id = d.type_id AND d.doctypes_first_level_id = dfl.doctypes_first_level_id AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
diff --git a/migration/20.03/2003.sql b/migration/20.03/2003.sql
deleted file mode 100755
index 18a53d1dcfed3b913b2f85a31e8e14c7b2c5f657..0000000000000000000000000000000000000000
--- a/migration/20.03/2003.sql
+++ /dev/null
@@ -1,934 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 19.04 to 20.03                                  --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-UPDATE parameters SET param_value_string = '20.03.11' WHERE id = 'database_version';
-
-UPDATE parameters SET description = 'Département par défaut sélectionné dans les autocomplétions de la Base Adresse Nationale' WHERE id = 'defaultDepartment';
-
-/*CLEAN DATA*/
-/*Exists in groupbasket_status but not in actions_groupbaskets*/
-DELETE FROM groupbasket_status WHERE system_id IN (
-	select system_id from groupbasket_status gbs
-	where not exists (
-		select 1 from actions_groupbaskets agb where gbs.action_id = agb.id_action and gbs.group_id = agb.group_id and gbs.basket_id = agb.basket_id
-	)
-);
-
-/* VIEWS */
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS res_view_attachments;
-DROP VIEW IF EXISTS view_folders;
-DROP VIEW IF EXISTS res_view_business;
-
-/*USERS*/
-ALTER TABLE users DROP COLUMN IF EXISTS reset_token;
-ALTER TABLE users DROP COLUMN IF EXISTS change_password;
-ALTER TABLE users ADD COLUMN reset_token text;
-ALTER TABLE users DROP COLUMN IF EXISTS preferences;
-ALTER TABLE users ADD COLUMN preferences jsonb NOT NULL DEFAULT '{"documentEdition" : "java"}';
-
-/* FULL TEXT */
-DELETE FROM docservers where docserver_type_id = 'FULLTEXT';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, size_limit_number, actual_size_number, path_template, creation_date, coll_id)
-VALUES ('FULLTEXT_DOCUMENT', 'FULLTEXT', 'Full text indexes for documents', 'N', 50000000000, 0, '/opt/maarch/docservers/indexes/documents/', '2019-11-01 12:00:00.123456', 'letterbox_coll');
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, size_limit_number, actual_size_number, path_template, creation_date, coll_id)
-VALUES ('FULLTEXT_ATTACHMENT', 'FULLTEXT', 'Full text indexes for attachments', 'N', 50000000000, 0, '/opt/maarch/docservers/indexes/attachments/', '2019-11-01 12:00:00.123456', 'attachments_coll');
-UPDATE docserver_types SET fingerprint_mode = NULL WHERE docserver_type_id = 'FULLTEXT';
-UPDATE res_letterbox SET fulltext_result = 'SUCCESS' WHERE fulltext_result = '1' OR fulltext_result = '2';
-UPDATE res_letterbox SET fulltext_result = 'ERROR' WHERE fulltext_result = '-1' OR fulltext_result = '-2';
-UPDATE res_attachments SET fulltext_result = 'SUCCESS' WHERE fulltext_result = '1' OR fulltext_result = '2';
-UPDATE res_attachments SET fulltext_result = 'ERROR' WHERE fulltext_result = '-1' OR fulltext_result = '-2';
-
-/* GROUPS INDEXING */
-ALTER TABLE usergroups ALTER COLUMN group_desc DROP DEFAULT;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS can_index;
-ALTER TABLE usergroups ADD COLUMN can_index boolean NOT NULL DEFAULT FALSE;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS indexation_parameters;
-ALTER TABLE usergroups ADD COLUMN indexation_parameters jsonb NOT NULL DEFAULT '{"actions" : [], "entities" : [], "keywords" : []}';
-
-
-/* BASKETS LIST EVENT */
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS list_event;
-ALTER TABLE groupbasket ADD COLUMN list_event character varying(255) DEFAULT 'documentDetails' NOT NULL;
-UPDATE groupbasket SET list_event = 'processDocument'
-FROM (
-       SELECT basket_id, group_id
-       FROM actions_groupbaskets ag
-         LEFT JOIN actions a ON ag.id_action = a.id
-       WHERE ag.default_action_list = 'Y' AND a.action_page in ('validate_mail', 'process')
-     ) AS subquery
-WHERE groupbasket.basket_id = subquery.basket_id AND groupbasket.group_id = subquery.group_id;
-UPDATE groupbasket SET list_event = 'viewDoc'
-FROM (
-       SELECT basket_id, group_id
-       FROM actions_groupbaskets ag
-         LEFT JOIN actions a ON ag.id_action = a.id
-       WHERE ag.default_action_list = 'Y' AND a.component = 'viewDoc'
-     ) AS subquery
-WHERE groupbasket.basket_id = subquery.basket_id AND groupbasket.group_id = subquery.group_id;
-UPDATE groupbasket SET list_event = 'signatureBookAction'
-FROM (
-       SELECT basket_id, group_id
-       FROM actions_groupbaskets ag
-         LEFT JOIN actions a ON ag.id_action = a.id
-       WHERE ag.default_action_list = 'Y' AND a.action_page in ('visa_mail')
-     ) AS subquery
-WHERE groupbasket.basket_id = subquery.basket_id AND groupbasket.group_id = subquery.group_id;
-ALTER TABLE groupbasket DROP COLUMN IF EXISTS list_event_data;
-ALTER TABLE groupbasket ADD COLUMN list_event_data jsonb;
-
-update groupbasket set list_event_data = '{"canUpdate":true,"defaultTab":"info"}'
-where group_id in (
-    select group_id
-    from actions_groupbaskets
-    where id_action in (
-        select id
-        from actions
-        where action_page = 'validate_mail'
-    ) and groupbasket.basket_id = actions_groupbaskets.basket_id
-);
-
-UPDATE groupbasket SET list_event_data = '{"defaultTab":"info"}'
-WHERE list_event = 'processDocument' AND (list_event_data IS NULL OR list_event_data::text = '');
-
--- /!\ Do not move : update actions AFTER all updates on groupbasket
-UPDATE actions SET component = 'confirmAction', action_page = null  WHERE action_page in ('validate_mail', 'process', 'visa_mail');
-
-DELETE FROM actions_categories WHERE action_id in (SELECT id FROM actions WHERE component = 'viewDoc' OR action_page in ('view'));
-DELETE FROM actions_groupbaskets WHERE id_action in (SELECT id FROM actions WHERE component = 'viewDoc' OR action_page in ('view'));
-DELETE FROM groupbasket_redirect WHERE action_id in (SELECT id FROM actions WHERE component = 'viewDoc' OR action_page in ('view'));
-DELETE FROM actions WHERE component = 'viewDoc' OR action_page in ('view');
-
-ALTER TABLE actions DROP COLUMN IF EXISTS parameters;
-ALTER TABLE actions ADD COLUMN parameters jsonb NOT NULL DEFAULT '{}';
-
-UPDATE actions SET component = 'rejectVisaBackToPreviousAction' WHERE action_page = 'rejection_visa_previous';
-UPDATE actions SET component = 'redirectInitiatorEntityAction' WHERE action_page = 'redirect_visa_entity';
-UPDATE actions SET component = 'rejectVisaBackToPreviousAction' WHERE action_page = 'rejection_visa_previous';
-UPDATE actions SET component = 'resetVisaAction' WHERE action_page = 'rejection_visa_redactor';
-UPDATE actions SET component = 'interruptVisaAction' WHERE action_page = 'interrupt_visa';
-UPDATE actions SET component = 'sendSignatureBookAction' WHERE action_page IN ('send_to_visa', 'send_signed_docs');
-UPDATE actions SET component = 'continueVisaCircuitAction' WHERE action_page = 'visa_workflow';
-UPDATE actions SET component = 'closeMailWithAttachmentsOrNotesAction' WHERE action_page = 'close_mail_with_attachment';
-UPDATE actions SET component = 'sendToOpinionCircuitAction' WHERE action_page = 'send_to_avis';
-UPDATE actions SET component = 'continueOpinionCircuitAction' WHERE action_page = 'avis_workflow';
-UPDATE actions SET component = 'giveOpinionParallelAction' WHERE action_page = 'avis_workflow_simple';
-UPDATE actions SET component = 'sendToParallelOpinion' WHERE action_page = 'send_docs_to_recommendation';
-UPDATE actions SET component = 'validateParallelOpinionDiffusionAction' WHERE action_page = 'validate_recommendation';
-UPDATE actions SET component = 'createAcknowledgementReceiptsAction', parameters = '{"mode": "manual"}' WHERE action_page in ('send_attachments_to_contact', 'send_to_contact_with_mandatory_attachment');
-
-DELETE FROM actions_groupbaskets WHERE id_action IN (SELECT id FROM actions WHERE action_page = 'put_in_copy');
-DELETE FROM actions_categories WHERE action_id IN (SELECT id FROM actions WHERE action_page = 'put_in_copy');
-DELETE FROM actions WHERE action_page = 'put_in_copy';
-
-/* FOLDERS */
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'folders') AND attname = 'folders_system_id') THEN
-    ALTER TABLE folders RENAME TO folder_tmp;
-    ALTER TABLE folder_tmp RENAME CONSTRAINT folders_pkey to folders_tmp_pkey;
-  END IF;
-END$$;
-
-DROP TABLE IF EXISTS folders;
-CREATE TABLE folders
-(
-  id serial NOT NULL,
-  label character varying(255) NOT NULL,
-  public boolean NOT NULL,   
-  user_id INTEGER NOT NULL,
-  parent_id INTEGER,
-  level INTEGER NOT NULL,
-  CONSTRAINT folders_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS resources_folders;
-CREATE TABLE resources_folders
-(
-  id serial NOT NULL,
-  folder_id INTEGER NOT NULL,
-  res_id INTEGER NOT NULL,
-  CONSTRAINT resources_folders_pkey PRIMARY KEY (id),
-  CONSTRAINT resources_folders_unique_key UNIQUE (folder_id, res_id)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS entities_folders;
-CREATE TABLE entities_folders
-(
-  id serial NOT NULL,
-  folder_id INTEGER NOT NULL,
-  entity_id INTEGER,
-  edition boolean NOT NULL,
-  keyword character varying(255),
-  CONSTRAINT entities_folders_pkey PRIMARY KEY (id),
-  CONSTRAINT entities_folders_unique_key UNIQUE (folder_id, entity_id, keyword)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS users_pinned_folders;
-CREATE TABLE users_pinned_folders
-(
-  id serial NOT NULL,
-  folder_id INTEGER NOT NULL,
-  user_id INTEGER NOT NULL,
-  CONSTRAINT users_pinned_folders_pkey PRIMARY KEY (id),
-  CONSTRAINT users_pinned_folders_unique_key UNIQUE (folder_id, user_id)
-)
-WITH (OIDS=FALSE);
-
-
-/* CUSTOM FIELDS */
-DROP TABLE IF EXISTS custom_fields;
-CREATE TABLE custom_fields
-(
-  id serial NOT NULL,
-  label character varying(256) NOT NULL,
-  type character varying(256) NOT NULL,
-  values jsonb,
-  CONSTRAINT custom_fields_pkey PRIMARY KEY (id),
-  CONSTRAINT custom_fields_unique_key UNIQUE (label)
-)
-WITH (OIDS=FALSE);
-
-/* CONTACTS CUSTOM FIELDS */
-DROP TABLE IF EXISTS contacts_custom_fields_list;
-CREATE TABLE contacts_custom_fields_list
-(
-  id serial NOT NULL,
-  label character varying(256) NOT NULL,
-  type character varying(256) NOT NULL,
-  values jsonb,
-  CONSTRAINT contacts_custom_fields_list_pkey PRIMARY KEY (id),
-  CONSTRAINT contacts_custom_fields_list_unique_key UNIQUE (label)
-)
-WITH (OIDS=FALSE);
-
-
-/* INDEXING MODELS */
-DROP TABLE IF EXISTS indexing_models;
-CREATE TABLE indexing_models
-(
-  id SERIAL NOT NULL,
-  label character varying(256) NOT NULL,
-  category character varying(256) NOT NULL,
-  "default" BOOLEAN NOT NULL,
-  owner INTEGER NOT NULL,
-  private BOOLEAN NOT NULL,
-  master INTEGER DEFAULT NULL,
-  enabled BOOLEAN DEFAULT TRUE NOT NULL,
-  CONSTRAINT indexing_models_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS indexing_models_fields;
-CREATE TABLE indexing_models_fields
-(
-  id SERIAL NOT NULL,
-  model_id INTEGER NOT NULL,
-  identifier text NOT NULL,
-  mandatory BOOLEAN NOT NULL,
-  default_value json,
-  unit text NOT NULL,
-  CONSTRAINT indexing_models_fields_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-
-/* TAGS */
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'tags') AND attname = 'tag_label') = 1 THEN
-	  ALTER TABLE tags RENAME COLUMN tag_label TO label;
-	  ALTER TABLE tags DROP COLUMN IF EXISTS coll_id;
-	  ALTER TABLE tags ADD COLUMN id serial NOT NULL;
-	  UPDATE tags SET id = tag_id;
-      ALTER TABLE tags DROP COLUMN IF EXISTS tag_id;
-      ALTER TABLE tags DROP COLUMN IF EXISTS entity_id_owner;
-      ALTER TABLE tags DROP COLUMN IF EXISTS description;
-	  ALTER TABLE tags ADD COLUMN description TEXT;
-      ALTER TABLE tags DROP COLUMN IF EXISTS parent_id;
-      ALTER TABLE tags ADD COLUMN parent_id INT;
-      ALTER TABLE tags DROP COLUMN IF EXISTS creation_date;
-      ALTER TABLE tags ADD COLUMN creation_date TIMESTAMP DEFAULT NOW();
-      ALTER TABLE tags DROP COLUMN IF EXISTS links;
-      ALTER TABLE tags ADD COLUMN links jsonb DEFAULT '[]';
-      ALTER TABLE tags DROP COLUMN IF EXISTS usage;
-      ALTER TABLE tags ADD COLUMN usage TEXT;
-
-      ALTER TABLE tags ADD CONSTRAINT tags_id_pkey PRIMARY KEY (id);
-
-      DROP TABLE IF EXISTS resources_tags;
-      ALTER TABLE tag_res ADD COLUMN id serial NOT NULL;
-      ALTER TABLE tag_res RENAME TO resources_tags;
-  END IF;
-END$$;
-
-SELECT setval('tags_id_seq', (SELECT MAX(id) from tags));
-
-DROP TABLE IF EXISTS tags_entities;
-
-
-/* DOCTYPES */
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mlb_doctype_ext')) > 0 THEN
-	  ALTER TABLE doctypes ADD COLUMN process_delay INTEGER;
-	  ALTER TABLE doctypes ADD COLUMN delay1 INTEGER;
-	  ALTER TABLE doctypes ADD COLUMN delay2 INTEGER;
-	  ALTER TABLE doctypes ADD COLUMN process_mode CHARACTER VARYING(256);
-	  UPDATE doctypes SET process_delay = (SELECT process_delay FROM mlb_doctype_ext where doctypes.type_id = mlb_doctype_ext.type_id);
-	  UPDATE doctypes SET process_delay = 30 WHERE process_delay is null;
-	  UPDATE doctypes SET delay1 = (SELECT delay1 FROM mlb_doctype_ext where doctypes.type_id = mlb_doctype_ext.type_id);
-    UPDATE doctypes SET delay1 = 14 WHERE delay1 is null;
-	  UPDATE doctypes SET delay2 = (SELECT delay2 FROM mlb_doctype_ext where doctypes.type_id = mlb_doctype_ext.type_id);
-    UPDATE doctypes SET delay2 = 1 WHERE delay2 is null;
-	  UPDATE doctypes SET process_mode = (SELECT process_mode FROM mlb_doctype_ext where doctypes.type_id = mlb_doctype_ext.type_id);
-    UPDATE doctypes SET process_mode = 'NORMAL' WHERE process_mode is null;
-	  ALTER TABLE doctypes ALTER COLUMN process_delay SET NOT NULL;
-	  ALTER TABLE doctypes ALTER COLUMN delay1 SET NOT NULL;
-	  ALTER TABLE doctypes ALTER COLUMN delay2 SET NOT NULL;
-	  ALTER TABLE doctypes ALTER COLUMN process_mode SET NOT NULL;
-  END IF;
-END$$;
-
-
-/* NOTES */
-DO $$ BEGIN
-    IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'notes') AND attname = 'type') THEN
-        ALTER TABLE notes ADD COLUMN user_tmp_id integer;
-        UPDATE notes set user_tmp_id = (select id FROM users where users.user_id = notes.user_id);
-        UPDATE notes set user_tmp_id = 0 WHERE user_tmp_id IS NULL;
-        ALTER TABLE notes ALTER COLUMN user_tmp_id set not null;
-        ALTER TABLE notes DROP COLUMN IF EXISTS user_id;
-        ALTER TABLE notes RENAME COLUMN user_tmp_id TO user_id;
-        ALTER TABLE notes DROP COLUMN IF EXISTS type;
-    END IF;
-END$$;
-
-
-/* ATTACHMENTS */
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS origin_id;
-ALTER TABLE res_attachments ADD COLUMN origin_id INTEGER;
-DO $$ BEGIN
-    IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_attachments') AND attname = 'doc_date') THEN
-        ALTER TABLE res_attachments RENAME COLUMN doc_date TO modification_date;
-        ALTER TABLE res_attachments ALTER COLUMN modification_date set DEFAULT NOW();
-    END IF;
-END$$;
-DO $$ BEGIN
-    IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_attachments') AND attname = 'updated_by') THEN
-        ALTER TABLE res_attachments ADD COLUMN modified_by integer;
-        UPDATE res_attachments set modified_by = (select id FROM users where users.user_id = res_attachments.updated_by);
-        ALTER TABLE res_attachments DROP COLUMN IF EXISTS updated_by;
-    END IF;
-END$$;
-
-
-/* DOCSERVERS */
-UPDATE docservers SET coll_id = 'attachments_coll', is_readonly = 'Y' WHERE coll_id = 'attachments_version_coll' AND docserver_type_id = 'CONVERT';
-UPDATE docservers SET coll_id = 'attachments_coll', is_readonly = 'Y' WHERE coll_id = 'attachments_version_coll' AND docserver_type_id = 'FASTHD';
-UPDATE docservers SET coll_id = 'attachments_coll', is_readonly = 'Y' WHERE coll_id = 'attachments_version_coll' AND docserver_type_id = 'FULLTEXT';
-UPDATE docservers SET coll_id = 'attachments_coll', is_readonly = 'Y' WHERE coll_id = 'attachments_version_coll' AND docserver_type_id = 'TNL';
-UPDATE docservers SET docserver_type_id = 'DOC' WHERE coll_id = 'attachments_coll' AND docserver_type_id = 'FASTHD';
-
-
-/* MLB COLL EXT */
-DO $$ BEGIN
-    IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_letterbox') AND attname = 'category_id') = 0 THEN
-        ALTER TABLE res_letterbox ADD COLUMN category_id character varying(32);
-        UPDATE res_letterbox SET category_id = mlb_coll_ext.category_id FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-        UPDATE res_letterbox set category_id = 'incoming' WHERE category_id IS NULL;
-        ALTER TABLE res_letterbox ALTER COLUMN category_id set not null;
-
-        ALTER TABLE res_letterbox ADD COLUMN exp_contact_id integer;
-        UPDATE res_letterbox SET exp_contact_id = mlb_coll_ext.exp_contact_id FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN exp_user_id character varying(128);
-        UPDATE res_letterbox SET exp_user_id = mlb_coll_ext.exp_user_id FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN dest_contact_id integer;
-        UPDATE res_letterbox SET dest_contact_id = mlb_coll_ext.dest_contact_id FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN dest_user_id character varying(128);
-        UPDATE res_letterbox SET dest_user_id = mlb_coll_ext.dest_user_id FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN alt_identifier character varying(256);
-        UPDATE res_letterbox SET alt_identifier = mlb_coll_ext.alt_identifier FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN admission_date timestamp without time zone;
-        UPDATE res_letterbox SET admission_date = mlb_coll_ext.admission_date FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN process_limit_date timestamp without time zone;
-        UPDATE res_letterbox SET process_limit_date = mlb_coll_ext.process_limit_date FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN closing_date timestamp without time zone;
-        UPDATE res_letterbox SET closing_date = mlb_coll_ext.closing_date FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN flag_alarm1 character(1) DEFAULT 'N'::character varying;
-        UPDATE res_letterbox SET flag_alarm1 = mlb_coll_ext.flag_alarm1 FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN flag_alarm2 character(1) DEFAULT 'N'::character varying;
-        UPDATE res_letterbox SET flag_alarm2 = mlb_coll_ext.flag_alarm2 FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN is_multicontacts character(1);
-        UPDATE res_letterbox SET is_multicontacts = mlb_coll_ext.is_multicontacts FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN address_id INTEGER;
-        UPDATE res_letterbox SET address_id = mlb_coll_ext.address_id FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN alarm1_date timestamp without time zone;
-        UPDATE res_letterbox SET alarm1_date = mlb_coll_ext.alarm1_date FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-
-        ALTER TABLE res_letterbox ADD COLUMN alarm2_date timestamp without time zone;
-        UPDATE res_letterbox SET alarm2_date = mlb_coll_ext.alarm2_date FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id;
-    END IF;
-END$$;
-
-UPDATE res_letterbox SET exp_user_id = NULL WHERE exp_user_id = '0';
-UPDATE res_letterbox SET exp_contact_id = NULL WHERE exp_contact_id = 0;
-UPDATE res_letterbox SET dest_user_id = NULL WHERE dest_user_id = '0';
-UPDATE res_letterbox SET dest_contact_id = NULL WHERE dest_contact_id = 0;
-
-DO $$ BEGIN
-    IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'res_letterbox') AND attname = 'external_signatory_book_id') = 1 THEN
-      UPDATE res_letterbox SET external_id = jsonb_set(external_id, '{signatureBookId}', external_signatory_book_id::text::jsonb) WHERE external_signatory_book_id IS NOT NULL;
-      ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_signatory_book_id;
-    END IF;
-END$$;
-
-/* RES_LETTERBOX */
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS department_number_id;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS external_link;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS model_id;
-ALTER TABLE res_letterbox ADD COLUMN model_id INTEGER;
-UPDATE res_letterbox set model_id = 2 WHERE category_id = 'outgoing';
-UPDATE res_letterbox set model_id = 3 WHERE category_id = 'internal';
-UPDATE res_letterbox set model_id = 4 WHERE category_id = 'ged_doc';
-UPDATE res_letterbox set model_id = 1 WHERE model_id IS NULL;
-ALTER TABLE res_letterbox ALTER COLUMN model_id set not null;
-DO $$ BEGIN
-    IF (SELECT count(column_name) from information_schema.columns where table_name = 'res_letterbox' and column_name = 'typist' and data_type != 'integer') THEN
-        ALTER TABLE res_letterbox ADD COLUMN typist_tmp integer;
-        UPDATE res_letterbox set typist_tmp = (select id FROM users where users.user_id = res_letterbox.typist);
-        UPDATE res_letterbox set typist_tmp = 0 WHERE typist_tmp IS NULL;
-        ALTER TABLE res_letterbox ALTER COLUMN typist_tmp set not null;
-        ALTER TABLE res_letterbox DROP COLUMN IF EXISTS typist;
-        ALTER TABLE res_letterbox RENAME COLUMN typist_tmp TO typist;
-        UPDATE baskets SET basket_clause = REGEXP_REPLACE(basket_clause, 'typist(\s*)=(\s*)@user', 'typist = @user_id', 'gmi');
-        UPDATE security SET where_clause = REGEXP_REPLACE(where_clause, 'typist(\s*)=(\s*)@user', 'typist = @user_id', 'gmi');
-    END IF;
-END$$;
-ALTER TABLE res_letterbox ADD COLUMN IF NOT EXISTS scan_date timestamp without time zone;
-ALTER TABLE res_letterbox ADD COLUMN IF NOT EXISTS scan_user CHARACTER VARYING (50) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox ADD COLUMN IF NOT EXISTS scan_location CHARACTER VARYING (255) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox ADD COLUMN IF NOT EXISTS scan_wkstation CHARACTER VARYING (255) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox ADD COLUMN IF NOT EXISTS scan_batch CHARACTER VARYING (50) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox ADD COLUMN IF NOT EXISTS scan_postmark CHARACTER VARYING (50) DEFAULT NULL::character varying;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS custom_fields;
-ALTER TABLE res_letterbox ADD COLUMN custom_fields jsonb DEFAULT '{}';
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS linked_resources;
-ALTER TABLE res_letterbox ADD COLUMN linked_resources jsonb NOT NULL DEFAULT '[]';
-
-
-/* USERGROUP_CONTENT */
-DO $$ BEGIN
-    IF (SELECT count(column_name) from information_schema.columns where table_name = 'usergroup_content' and column_name = 'user_id' and data_type != 'integer') THEN
-        ALTER TABLE usergroup_content ADD COLUMN user_id_tmp integer;
-        UPDATE usergroup_content set user_id_tmp = (select id FROM users where users.user_id = usergroup_content.user_id);
-        DELETE FROM usergroup_content WHERE user_id_tmp IS NULL;
-        ALTER TABLE usergroup_content ALTER COLUMN user_id_tmp set not null;
-        ALTER TABLE usergroup_content DROP COLUMN IF EXISTS user_id;
-        ALTER TABLE usergroup_content RENAME COLUMN user_id_tmp TO user_id;
-    END IF;
-END$$;
-DO $$ BEGIN
-    IF (SELECT count(column_name) from information_schema.columns where table_name = 'usergroup_content' and column_name = 'group_id' and data_type != 'integer') THEN
-        ALTER TABLE usergroup_content ADD COLUMN group_id_tmp integer;
-        UPDATE usergroup_content set group_id_tmp = (select id FROM usergroups where usergroups.group_id = usergroup_content.group_id);
-        DELETE FROM usergroup_content WHERE group_id_tmp IS NULL;
-        ALTER TABLE usergroup_content ALTER COLUMN group_id_tmp set not null;
-        ALTER TABLE usergroup_content DROP COLUMN IF EXISTS group_id;
-        ALTER TABLE usergroup_content RENAME COLUMN group_id_tmp TO group_id;
-    END IF;
-END$$;
-
-
-/* CONTACTS */
-DROP TABLE IF EXISTS contacts;
-CREATE TABLE contacts
-(
-    id SERIAL NOT NULL,
-    civility CHARACTER VARYING(256),
-    firstname CHARACTER VARYING(256),
-    lastname CHARACTER VARYING(256),
-    company CHARACTER VARYING(256),
-    department CHARACTER VARYING(256),
-    function CHARACTER VARYING(256),
-    address_number CHARACTER VARYING(256),
-    address_street CHARACTER VARYING(256),
-    address_additional1 CHARACTER VARYING(256),
-    address_additional2 CHARACTER VARYING(256),
-    address_postcode CHARACTER VARYING(256),
-    address_town CHARACTER VARYING(256),
-    address_country CHARACTER VARYING(256),
-    email CHARACTER VARYING(256),
-    phone CHARACTER VARYING(256),
-    communication_means jsonb,
-    notes text,
-    creator INTEGER NOT NULL,
-    creation_date TIMESTAMP without time zone NOT NULL DEFAULT NOW(),
-    modification_date TIMESTAMP without time zone,
-    enabled boolean NOT NULL DEFAULT TRUE,
-    custom_fields jsonb,
-    external_id jsonb DEFAULT '{}',
-    CONSTRAINT contacts_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS contacts_parameters;
-CREATE TABLE contacts_parameters
-(
-    id SERIAL NOT NULL,
-    identifier text NOT NULL,
-    mandatory boolean NOT NULL DEFAULT FALSE,
-    filling boolean NOT NULL DEFAULT FALSE,
-    searchable boolean NOT NULL DEFAULT FALSE,
-    displayable boolean NOT NULL DEFAULT FALSE,
-    CONSTRAINT contacts_parameters_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-ALTER TABLE acknowledgement_receipts DROP COLUMN IF EXISTS contact_id;
-ALTER TABLE acknowledgement_receipts ADD COLUMN contact_id integer;
-ALTER TABLE contacts_groups_lists DROP COLUMN IF EXISTS contact_id;
-ALTER TABLE contacts_groups_lists ADD COLUMN contact_id integer;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS recipient_type;
-ALTER TABLE res_attachments ADD COLUMN recipient_type character varying(256);
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS recipient_id;
-ALTER TABLE res_attachments ADD COLUMN recipient_id integer;
-
-ALTER TABLE adr_letterbox DROP COLUMN IF EXISTS version;
-ALTER TABLE adr_letterbox ADD COLUMN version integer;
-UPDATE adr_letterbox SET version = 1;
-ALTER TABLE adr_letterbox ALTER COLUMN version SET NOT NULL;
-ALTER TABLE adr_letterbox DROP CONSTRAINT IF EXISTS adr_letterbox_unique_key;
-ALTER TABLE adr_letterbox ADD CONSTRAINT adr_letterbox_unique_key UNIQUE (res_id, type, version);
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS version;
-ALTER TABLE res_letterbox ADD COLUMN version integer;
-UPDATE res_letterbox SET version = 1;
-ALTER TABLE res_letterbox ALTER COLUMN version SET NOT NULL;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS integrations;
-ALTER TABLE res_letterbox ADD COLUMN integrations jsonb DEFAULT '{}' NOT NULL;
-
-ALTER TABLE entities DROP COLUMN IF EXISTS external_id;
-ALTER TABLE entities ADD COLUMN external_id jsonb DEFAULT '{}';
-
-/* REFACTORING DATA */
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'usergroups') AND attname = 'enabled') THEN
-    DELETE FROM usergroup_content WHERE group_id in (SELECT id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM usergroups_reports WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM usergroups_services WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM security WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM groupbasket WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM groupbasket_redirect WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM groupbasket_status WHERE group_id in (SELECT group_id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM users_baskets_preferences WHERE group_serial_id in (SELECT id FROM usergroups WHERE enabled = 'N');
-    DELETE FROM usergroups WHERE enabled = 'N';
-  END IF;
-END$$;
-
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'actions') AND attname = 'enabled') THEN
-    DELETE FROM actions_categories WHERE action_id in (SELECT id FROM actions WHERE enabled = 'N');
-    DELETE FROM actions_groupbaskets WHERE id_action in (SELECT id FROM actions WHERE enabled = 'N');
-    DELETE FROM groupbasket_redirect WHERE action_id in (SELECT id FROM actions WHERE enabled = 'N');
-    DELETE FROM actions WHERE enabled = 'N';
-  END IF;
-END$$;
-
-UPDATE listinstance SET item_mode = 'cc' WHERE item_mode = 'copy';
-DELETE FROM usergroups_services WHERE service_id = 'admin_fileplan';
-DELETE FROM usergroups_services WHERE service_id = 'put_doc_in_fileplan';
-DELETE FROM usergroups_services WHERE service_id = 'fileplan';
-DELETE FROM usergroups_services WHERE service_id = 'update_case';
-DELETE FROM usergroups_services WHERE service_id = 'join_res_case';
-DELETE FROM usergroups_services WHERE service_id = 'join_res_case_in_process';
-DELETE FROM usergroups_services WHERE service_id = 'close_case';
-DELETE FROM usergroups_services WHERE service_id = 'add_cases';
-DELETE FROM usergroups_services WHERE service_id IN ('folder_search', 'view_folder_tree', 'select_folder', 'show_history_folder', 'modify_folder', 'associate_folder', 'delete_folder', 'admin_foldertypes', 'create_folder', 'folder_freeze', 'close_folder');
-DELETE FROM usergroups_services WHERE service_id = 'add_tag_to_res';
-DELETE FROM usergroups_services WHERE service_id = 'tag_view';
-DELETE FROM usergroups_services WHERE service_id = 'thesaurus_view';
-DELETE FROM usergroups_services WHERE service_id = 'add_thesaurus_to_res';
-UPDATE usergroups_services SET service_id = 'manage_tags_application' WHERE service_id = 'create_tag';
-UPDATE usergroups_services SET service_id = 'update_status_mail' WHERE service_id = 'reopen_mail';
-DELETE FROM usergroups_services WHERE service_id = 'quicklaunch';
-DELETE FROM usergroups_services WHERE service_id = 'put_in_validation';
-DELETE FROM usergroups_services WHERE service_id = 'print_details';
-DELETE FROM usergroups_services WHERE service_id = 'print_doc_details_from_list';
-DELETE FROM usergroups_services WHERE service_id = 'view_attachments';
-DELETE FROM usergroups_services WHERE service_id = 'index_attachment';
-DELETE FROM usergroups_services WHERE service_id = 'display_basket_list';
-DELETE FROM usergroups_services WHERE service_id = 'choose_entity';
-DELETE FROM usergroups_services WHERE service_id = 'manage_notes_doc';
-DELETE FROM usergroups_services WHERE service_id = 'notes_restriction';
-DELETE FROM usergroups_services WHERE service_id = 'graphics_reports';
-DELETE FROM usergroups_services WHERE service_id = 'show_reports';
-DELETE FROM usergroups_services WHERE service_id = 'param_templates_doctypes';
-DELETE FROM usergroups_services WHERE service_id = 'doctype_template_use';
-DELETE FROM usergroups_services WHERE service_id = 'search_contacts';
-DELETE FROM usergroups_services WHERE service_id = 'use_date_in_signBlock';
-DELETE FROM usergroups_services WHERE service_id = 'delete_document_in_detail';
-UPDATE usergroups_services SET service_id = 'manage_numeric_package' WHERE service_id = 'save_numeric_package';
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'manage_numeric_package'
-FROM usergroups_services WHERE group_id IN (
-    SELECT group_id FROM usergroups_services
-    WHERE service_id = 'sendmail' AND group_id not in (SELECT group_id FROM usergroups_services WHERE service_id = 'manage_numeric_package')
-);
-
-DELETE FROM usergroups_services WHERE service_id = 'include_folders_and_followed_resources_perimeter';
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'include_folders_and_followed_resources_perimeter' FROM usergroups_services;
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'update_diffusion_indexing'
-FROM usergroups_services WHERE service_id = 'edit_recipient_outside_process';
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'update_diffusion_details'
-FROM usergroups_services WHERE service_id = 'edit_recipient_outside_process';
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'update_diffusion_except_recipient_details'
-FROM usergroups_services WHERE service_id = 'update_list_diff_in_details';
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'update_diffusion_process'
-FROM usergroups_services WHERE service_id = 'edit_recipient_in_process';
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'update_diffusion_except_recipient_process'
-FROM usergroups_services us WHERE group_id NOT IN (SELECT distinct(group_id) FROM usergroups_services WHERE service_id = 'edit_recipient_in_process') 
-AND group_id NOT IN (SELECT group_id FROM usergroups_services us2 WHERE us2.group_id = us.group_id and service_id = 'update_diffusion_except_recipient_process');
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'update_diffusion_except_recipient_indexing'
-FROM usergroups_services WHERE group_id NOT IN (
-SELECT group_id FROM usergroups_services
-WHERE service_id = 'edit_recipient_outside_process' OR service_id = 'update_diffusion_indexing' OR service_id = 'update_diffusion_except_recipient_indexing'
-);
-DELETE FROM usergroups_services WHERE service_id = 'edit_recipient_outside_process';
-DELETE FROM usergroups_services WHERE service_id = 'update_list_diff_in_details';
-DELETE FROM usergroups_services WHERE service_id = 'edit_recipient_in_process';
-UPDATE usergroups_services SET service_id = 'edit_resource' WHERE service_id = 'edit_document_in_detail';
-
-DELETE FROM usergroups_services WHERE service_id = 'edit_attachments_from_detail';
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'manage_attachments'
-FROM usergroups_services WHERE group_id IN (
-    SELECT group_id FROM usergroups_services
-    WHERE service_id = 'modify_attachments' OR service_id = 'delete_attachments'
-);
-DELETE FROM usergroups_services WHERE service_id = 'modify_attachments';
-DELETE FROM usergroups_services WHERE service_id = 'delete_attachments';
-
-ALTER TABLE usergroups_services DROP COLUMN IF EXISTS parameters;
-ALTER TABLE usergroups_services ADD parameters jsonb;
-UPDATE usergroups_services SET parameters = (
-    cast('{"groups": [' || (
-        SELECT string_agg(cast(id AS VARCHAR), ', ' ORDER BY id) FROM usergroups
-    ) || ']}' AS jsonb)
-    )
-WHERE service_id = 'admin_users';
-
-UPDATE groupbasket SET list_event_data = '{"canUpdateDocument":true}'
-WHERE list_event = 'signatureBookAction' AND group_id in (
-    select distinct(group_id)
-    from usergroups_services
-    where service_id = 'manage_attachments'
-);
-
-DELETE FROM usergroups_services WHERE service_id = 'view_personal_data' or service_id = 'manage_personal_data';
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'view_personal_data'
-FROM usergroups_services WHERE group_id IN (
-    SELECT group_id FROM usergroups_services
-    WHERE service_id = 'admin_users'
-);
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'manage_personal_data'
-FROM usergroups_services WHERE group_id IN (
-    SELECT group_id FROM usergroups_services
-    WHERE service_id = 'admin_users'
-);
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'admin_tag'
-FROM usergroups_services WHERE group_id IN (
-    SELECT group_id FROM usergroups_services
-    WHERE service_id = 'admin_thesaurus'
-) AND group_id NOT IN (
-    SELECT group_id FROM usergroups_services
-    WHERE service_id = 'admin_tag'
-);
-DELETE FROM usergroups_services WHERE service_id = 'admin_thesaurus';
-
-UPDATE history SET event_type = 'PRE' where event_type = 'RET';
-
-
-DO $$ 
-  BEGIN
-    IF EXISTS 
-      (select 1 from information_schema.tables where table_name = 'listmodels') 
-    THEN 
-      UPDATE listmodels SET title = object_id WHERE title IS NULL;
-    END IF;
-  END
-$$ ;
-UPDATE baskets SET basket_clause = REGEXP_REPLACE(basket_clause, 'coll_id(\s*)=(\s*)''letterbox_coll''(\s*)AND', '', 'gmi') WHERE basket_id in ('CopyMailBasket', 'DdeAvisBasket');
-UPDATE baskets SET basket_clause = REGEXP_REPLACE(basket_clause, 'coll_id(\s*)=(\s*)''letterbox_coll''(\s*)and', '', 'gmi') WHERE basket_id in ('CopyMailBasket', 'DdeAvisBasket');
-
-
-UPDATE templates SET template_target = 'attachments' WHERE (template_target = '' OR template_target is null) AND template_type = 'OFFICE';
-UPDATE templates SET template_target = 'notes' WHERE (template_target = '' OR template_target is null) AND template_type = 'TXT';
-DELETE FROM templates WHERE template_target = '' OR template_target is null;
-
-/* ListTemplates */
-DROP TABLE IF EXISTS list_templates;
-CREATE TABLE list_templates
-(
-    id SERIAL NOT NULL,
-    title text NOT NULL,
-    description text,
-    type CHARACTER VARYING(32) NOT NULL,
-    entity_id INTEGER,
-    owner INTEGER DEFAULT NULL,
-    CONSTRAINT list_templates_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-DROP TABLE IF EXISTS list_templates_items;
-CREATE TABLE list_templates_items
-(
-    id SERIAL NOT NULL,
-    list_template_id INTEGER NOT NULL,
-    item_id INTEGER NOT NULL,
-    item_type CHARACTER VARYING(32) NOT NULL,
-    item_mode CHARACTER VARYING(64) NOT NULL,
-    sequence INTEGER NOT NULL,
-    CONSTRAINT list_templates_items_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-
-/* REFACTORING MODIFICATION */
-ALTER TABLE notif_email_stack ALTER COLUMN attachments TYPE text;
-ALTER TABLE tags ALTER COLUMN label TYPE character varying(128);
-UPDATE priorities SET delays = 30 WHERE delays IS NULL;
-ALTER TABLE priorities ALTER COLUMN delays SET NOT NULL;
-ALTER TABLE res_letterbox ALTER COLUMN status DROP NOT NULL;
-ALTER TABLE res_letterbox ALTER COLUMN docserver_id DROP NOT NULL;
-ALTER TABLE res_letterbox ALTER COLUMN format DROP NOT NULL;
-ALTER TABLE notif_email_stack ALTER COLUMN recipient TYPE text;
-ALTER TABLE notif_email_stack ALTER COLUMN cc TYPE text;
-ALTER TABLE notif_email_stack ALTER COLUMN bcc TYPE text;
-
-
-/* REFACTORING SUPPRESSION */
-DO $$ BEGIN
-  IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'users') AND attname = 'enabled') THEN
-    UPDATE users SET status = 'SPD' WHERE enabled = 'N' and (status = 'OK' or status = 'ABS');
-    ALTER TABLE users DROP COLUMN IF EXISTS enabled;
-  END IF;
-END$$;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS converter_result;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS convert_result;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS convert_result;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS convert_attempts;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS convert_attempts;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS fulltext_attempts;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS fulltext_attempts;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_attempts;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_attempts;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_result;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_result;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS coll_id;
-ALTER TABLE usergroups DROP COLUMN IF EXISTS enabled;
-ALTER TABLE actions DROP COLUMN IF EXISTS enabled;
-ALTER TABLE actions DROP COLUMN IF EXISTS origin;
-ALTER TABLE actions DROP COLUMN IF EXISTS create_id;
-ALTER TABLE actions DROP COLUMN IF EXISTS category_id;
-DROP VIEW IF EXISTS fp_view_fileplan;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS folders_system_id;
-DROP TABLE IF EXISTS foldertypes;
-DROP TABLE IF EXISTS foldertypes_doctypes;
-DROP TABLE IF EXISTS foldertypes_doctypes_level1;
-DROP TABLE IF EXISTS foldertypes_indexes;
-ALTER TABLE doctypes DROP COLUMN IF EXISTS coll_id;
-DROP TABLE IF EXISTS mlb_doctype_ext;
-ALTER TABLE priorities DROP COLUMN IF EXISTS working_days;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS title;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS identifier;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS source;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS relation;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS offset_doc;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS is_multi_docservers;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tablename;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS validation_date;
-ALTER TABLE listinstance DROP COLUMN IF EXISTS added_by_entity;
-ALTER TABLE listinstance DROP COLUMN IF EXISTS coll_id;
-ALTER TABLE listinstance DROP COLUMN IF EXISTS listinstance_type;
-ALTER TABLE listinstance DROP COLUMN IF EXISTS visible;
-ALTER TABLE listinstance_history_details DROP COLUMN IF EXISTS added_by_entity;
-ALTER TABLE usergroup_content DROP COLUMN IF EXISTS primary_group;
-ALTER TABLE emails ALTER COLUMN document type jsonb;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS subject;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS description;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS type_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS author;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS source;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS folders_system_id;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS offset_doc;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS destination;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS priority;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS initiator;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_multicontacts;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_multi_docservers;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_path;
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_filename;
-ALTER TABLE users DROP COLUMN IF EXISTS custom_t1;
-ALTER TABLE users DROP COLUMN IF EXISTS custom_t2;
-ALTER TABLE users DROP COLUMN IF EXISTS custom_t3;
-DROP TABLE IF EXISTS templates_doctype_ext;
-DROP TABLE IF EXISTS notif_rss_stack;
-
-/* M2M */
-DO $$ BEGIN
-  IF (SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'mlb_coll_ext')) THEN
-    UPDATE res_letterbox SET external_id = json_build_object('m2m', reference_number), reference_number = null FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND mlb_coll_ext.nature_id = 'message_exchange';
-    UPDATE mlb_coll_ext SET nature_id = null WHERE nature_id = 'message_exchange';
-  END IF;
-END$$;
-
-/* DATA */
-TRUNCATE TABLE custom_fields;
-INSERT INTO custom_fields (id, label, type, values) VALUES (1, 'Nature', 'select', '["Courrier simple", "Courriel", "Courrier suivi", "Courrier avec AR", "Autre"]');
-SELECT setval('custom_fields_id_seq', (select max(id)+1 from custom_fields), false);
-
-DO $$ BEGIN
-  IF (SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'mlb_coll_ext')) THEN
-    UPDATE res_letterbox SET custom_fields = json_build_object('1', 'Courrier simple') FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND mlb_coll_ext.nature_id = 'simple_mail';
-    UPDATE res_letterbox SET custom_fields = json_build_object('1', 'Courriel') FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND mlb_coll_ext.nature_id = 'email';
-    UPDATE res_letterbox SET custom_fields = json_build_object('1', 'Autre') FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND mlb_coll_ext.nature_id in ('fax', 'other', 'courier');
-    UPDATE res_letterbox SET custom_fields = json_build_object('1', 'Courrier suivi') FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND mlb_coll_ext.nature_id in ('chronopost', 'fedex');
-    UPDATE res_letterbox SET custom_fields = json_build_object('1', 'Courrier avec AR') FROM mlb_coll_ext WHERE res_letterbox.res_id = mlb_coll_ext.res_id AND mlb_coll_ext.nature_id = 'registered_mail';
-  END IF;
-END$$;
-UPDATE baskets set basket_clause = replace(basket_clause, 'nature_id' , 'custom_fields->>''1''');
-
-UPDATE baskets SET basket_clause = replace(basket_clause, 's.attachment_id = r.res_id', 's.document_id = r.res_id AND s.document_type = ''attachment''')
-WHERE basket_clause ILIKE '%s.attachment_id = r.res_id%';
-
-UPDATE baskets SET basket_clause = replace(basket_clause, 'attachment_id', 'document_id')
-WHERE basket_clause ILIKE '%attachment_id%';
-
-
-UPDATE history SET user_id = (select user_id from users order by user_id='superadmin' desc limit 1) where user_id = '';
-
-/* users followed resources */
-DROP TABLE IF EXISTS users_followed_resources;
-CREATE TABLE users_followed_resources
-(
-    id serial NOT NULL,
-    res_id int NOT NULL,
-    user_id int NOT NULL,
-    CONSTRAINT users_followed_resources_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-/* shipping */
-DO $$ BEGIN
-    IF (SELECT count(attname) FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'shippings') AND attname = 'attachment_id') = 1 THEN
-        ALTER TABLE shippings DROP COLUMN IF EXISTS document_type;
-        ALTER TABLE shippings ADD COLUMN document_type character varying(255);
-        ALTER TABLE shippings RENAME COLUMN attachment_id TO document_id;
-        UPDATE shippings SET document_type = 'attachment';
-        ALTER TABLE shippings ALTER COLUMN document_type SET NOT NULL;
-    END IF;
-END$$;
-ALTER TABLE shippings DROP COLUMN IF EXISTS recipients;
-ALTER TABLE shippings ADD COLUMN recipients jsonb DEFAULT '[]';
-
-TRUNCATE TABLE indexing_models;
-INSERT INTO indexing_models (id, category, label, "default", owner, private) VALUES (1, 'incoming', 'Courrier arrivée', TRUE, 23, FALSE);
-INSERT INTO indexing_models (id, category, label, "default", owner, private) VALUES (2, 'outgoing', 'Courrier départ', FALSE, 23, FALSE);
-INSERT INTO indexing_models (id, category, label, "default", owner, private) VALUES (3, 'internal', 'Courrier interne', FALSE, 23, FALSE);
-INSERT INTO indexing_models (id, category, label, "default", owner, private) VALUES (4, 'ged_doc', 'Document ged', FALSE, 23, FALSE);
-Select setval('indexing_models_id_seq', (select max(id)+1 from indexing_models), false);
-
-TRUNCATE TABLE indexing_models_fields;
-/* Arrivée */
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'doctype', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'priority', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'confidentiality', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'documentDate', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'arrivalDate', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'indexingCustomField_1', FALSE, '"Courrier simple"', 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'senders', TRUE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'recipients', FALSE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'initiator', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'destination', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'processLimitDate', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'folders', FALSE, null, 'classifying');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (1, 'tags', FALSE, null, 'classifying');
-
-/* Départ */
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'doctype', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'priority', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'confidentiality', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'documentDate', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'departureDate', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'indexingCustomField_1', FALSE, '"Courrier simple"', 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'senders', FALSE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'recipients', TRUE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'initiator', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'destination', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'processLimitDate', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'folders', FALSE, null, 'classifying');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (2, 'tags', FALSE, null, 'classifying');
-
-/* Interne */
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'doctype', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'priority', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'confidentiality', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'documentDate', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'indexingCustomField_1', FALSE, '"Courrier simple"', 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'senders', FALSE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'recipients', FALSE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'initiator', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'destination', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'processLimitDate', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'folders', FALSE, null, 'classifying');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (3, 'tags', FALSE, null, 'classifying');
-
-/* GED */
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'doctype', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'confidentiality', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'documentDate', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'subject', TRUE, null, 'mail');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'senders', FALSE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'recipients', FALSE, null, 'contact');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'initiator', TRUE, null, 'process');
-INSERT INTO indexing_models_fields (model_id, identifier, mandatory, default_value, unit) VALUES (4, 'destination', TRUE, null, 'process');
diff --git a/migration/20.03/20036.sql b/migration/20.03/20036.sql
deleted file mode 100644
index c7a2966dfae8451ed52aa55b9a6a5dd76c5a3f25..0000000000000000000000000000000000000000
--- a/migration/20.03/20036.sql
+++ /dev/null
@@ -1,22 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 20.03.5 to 20.03.6                              --
---                                                                          --
---                                                                          --
--- *************************************************************************--
---DATABASE_BACKUP|usergroups_services|groupbasket
-
-UPDATE parameters SET param_value_string = '20.03.6' WHERE id = 'database_version';
-
-DELETE FROM usergroups_services WHERE service_id = 'include_folders_and_followed_resources_perimeter';
-
-INSERT INTO usergroups_services (group_id, service_id)
-SELECT distinct(group_id), 'include_folders_and_followed_resources_perimeter' FROM usergroups_services;
-
-UPDATE groupbasket SET list_event_data = '{"canUpdateDocument":true}'
-WHERE list_event = 'signatureBookAction' AND group_id in (
-    select distinct(group_id)
-    from usergroups_services
-    where service_id = 'manage_attachments'
-);
diff --git a/migration/20.03/exportCases.php b/migration/20.03/exportCases.php
deleted file mode 100644
index 124013affeb64ec7a94927a1993dff080ed9a2e0..0000000000000000000000000000000000000000
--- a/migration/20.03/exportCases.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-    $migrated = 0;
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-
-    $cases = \SrcCore\models\DatabaseModel::select([
-        'select' => ['case_id', 'case_label', 'case_closing_date'],
-        'table'  => ['cases']
-    ]);
-
-    if (!empty($cases)) {
-        $file = fopen("migration/20.03/cases_{$custom}.csv", 'w+');
-        $csvHead = ['Identifiant affaire', 'Libellé affaire', 'Date de cloture', 'Identifiant courrier', 'Numéro chrono', 'Sujet courrier'];
-        fputcsv($file, $csvHead, ',');
-
-        foreach ($cases as $case) {
-            $resources = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['r.res_id', 'r.subject', 'mlb.alt_identifier'],
-                'table'     => ['cases_res c, res_letterbox r, mlb_coll_ext mlb'],
-                'where'     => ['c.res_id = r.res_id', 'r.res_id = mlb.res_id', 'case_id = ?', 'r.status <> \'DEL\''],
-                'data'      => [$case['case_id']]
-            ]);
-            foreach ($resources as $resource) {
-                $csvContent = [$case['case_id'], $case['case_label'], $case['case_closing_date'], $resource['res_id'], $resource['alt_identifier'], $resource['subject']];
-                fputcsv($file, $csvContent, ',');
-            }
-            ++$migrated;
-        }
-
-        fclose($file);
-    }
-
-    printf("Export Affaires (CUSTOM {$custom}) : " . $migrated . " Affaire(s) exportée(s) dans le fichier cases_{$custom}.csv\n");
-}
diff --git a/migration/20.03/exportCustomFields.php b/migration/20.03/exportCustomFields.php
deleted file mode 100644
index cef6aceadab9703dff25827b7462e92ef91edf1f..0000000000000000000000000000000000000000
--- a/migration/20.03/exportCustomFields.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-
-ini_set('memory_limit', -1);
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-    $migrated = 0;
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-
-    $fields = \SrcCore\models\DatabaseModel::select([
-        'select' => ['res_id', 'alt_identifier', 'custom_n1', 'custom_f1', 'custom_d1', 'custom_t2', 'custom_n2', 'custom_f2', 'custom_d2', 'custom_t3', 'custom_n3', 'custom_f3', 'custom_d3', 'custom_t4', 'custom_n4', 'custom_f4', 'custom_d4', 'custom_t5', 'custom_n5', 'custom_f5', 'custom_d5', 'custom_t6', 'custom_d6', 'custom_t7', 'custom_d7', 'custom_t8', 'custom_d8', 'custom_t9', 'custom_d9', 'custom_t10', 'custom_d10', 'custom_t11', 'custom_t12', 'custom_t13', 'custom_t14', 'custom_t15'],
-        'table'  => ['res_letterbox'],
-        'where' => ['custom_n1 is not null or custom_f1 is not null or custom_d1 is not null or custom_t2 is not null or custom_n2 is not null or custom_f2 is not null or custom_d2 is not null or custom_t3 is not null or custom_n3 is not null or custom_f3 is not null or custom_d3 is not null or custom_t4 is not null or custom_n4 is not null or custom_f4 is not null or custom_d4 is not null or custom_t5 is not null or custom_n5 is not null or custom_f5 is not null or custom_d5 is not null or custom_t6 is not null or custom_d6 is not null or custom_t7 is not null or custom_d7 is not null or custom_t8 is not null or custom_d8 is not null  or custom_t9 is not null or custom_d9 is not null or custom_t10 is not null or custom_d10 is not null or custom_t11 is not null or custom_t12 is not null or custom_t13 is not null or custom_t14 is not null or custom_t15 is not null']
-    ]);
-
-    if (!empty($fields)) {
-        $file = fopen("migration/20.03/customFields_{$custom}.csv", 'w+');
-        $csvHead = ['Res id', 'Numéro chrono', 'custom_n1', 'custom_f1', 'custom_d1', 'custom_t2', 'custom_n2', 'custom_f2', 'custom_d2', 'custom_t3', 'custom_n3', 'custom_f3', 'custom_d3', 'custom_t4', 'custom_n4', 'custom_f4', 'custom_d4', 'custom_t5', 'custom_n5', 'custom_f5', 'custom_d5', 'custom_t6', 'custom_d6', 'custom_t7', 'custom_d7', 'custom_t8', 'custom_d8', 'custom_t9', 'custom_d9', 'custom_t10', 'custom_d10', 'custom_t11', 'custom_t12', 'custom_t13', 'custom_t14', 'custom_t15'];
-        fputcsv($file, $csvHead, ',');
-
-        foreach ($fields as $field) {
-            fputcsv($file, $field, ',');
-            $migrated++;
-        }
-
-        fclose($file);
-    }
-
-    printf("Export champs custom de res_letterbox (CUSTOM {$custom}) : " . $migrated . " Champ(s) exporté(s) dans le fichier customFields_{$custom}.csv\n");
-}
diff --git a/migration/20.03/exportFileplans.php b/migration/20.03/exportFileplans.php
deleted file mode 100644
index bb60f324124d8c1c9f7107bd896a380a87c92deb..0000000000000000000000000000000000000000
--- a/migration/20.03/exportFileplans.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-    $migrated = 0;
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-
-    $fileplans = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['fileplan_id', 'fileplan_label'],
-        'table'     => ['fp_fileplan'],
-        'where'     => ['user_id is null']
-    ]);
-
-    if (!empty($fileplans)) {
-        $file = fopen("migration/20.03/fileplans_{$custom}.csv", 'w+');
-        $csvHead = ['Identifiant plan', 'Libellé plan', 'Identifiant position', 'Libellé position', 'Identifiant courrier', 'Numéro chrono', 'Sujet courrier'];
-        fputcsv($file, $csvHead, ',');
-
-        foreach ($fileplans as $fileplan) {
-            $csvContent = [];
-            $positions = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['position_id', 'position_label'],
-                'table'     => ['fp_fileplan_positions'],
-                'where'     => ['fileplan_id = ?'],
-                'data'      => [$fileplan['fileplan_id']]
-            ]);
-
-            foreach ($positions as $position) {
-                $resources = \SrcCore\models\DatabaseModel::select([
-                    'select'    => ['r.res_id', 'r.subject', 'mlb.alt_identifier'],
-                    'table'     => ['fp_res_fileplan_positions p, res_letterbox r, mlb_coll_ext mlb'],
-                    'where'     => ['p.res_id = r.res_id', 'r.res_id = mlb.res_id', 'position_id = ?', 'r.status <> \'DEL\''],
-                    'data'      => [$position['position_id']]
-                ]);
-                foreach ($resources as $resource) {
-                    $csvContent = [$fileplan['fileplan_id'], $fileplan['fileplan_label'], $position['position_id'], $position['position_label'], $resource['res_id'], $resource['alt_identifier'], $resource['subject']];
-                    fputcsv($file, $csvContent, ',');
-                }
-            }
-
-            if (!empty($csvContent)) {
-                ++$migrated;
-            }
-        }
-
-        fclose($file);
-    }
-
-    printf("Export Plans de Classements (CUSTOM {$custom}) : " . $migrated . " Plan(s) de classement public exporté(s) dans le fichier fileplans_{$custom}.csv\n");
-}
diff --git a/migration/20.03/exportFolders.php b/migration/20.03/exportFolders.php
deleted file mode 100644
index 2a2a9804096f8d6c04c182b30f24c37e2807d903..0000000000000000000000000000000000000000
--- a/migration/20.03/exportFolders.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-    $migrated = 0;
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $folders = \SrcCore\models\DatabaseModel::select([
-        'select'   => ['f.folders_system_id', 'f.folder_name', 'f.status', 'r.res_id', 'mlb.alt_identifier', 'r.subject'],
-        'table'    => ['folder_tmp f, res_letterbox r, mlb_coll_ext mlb'],
-        'where'    => ['f.folders_system_id = r.folders_system_id', 'r.res_id = mlb.res_id', '(f.destination is null or f.destination = \'\')', 'f.status <> \'DEL\'', 'r.status <> \'DEL\''],
-        'order_by' => ['f.folder_name']
-    ]);
-
-    if (!empty($folders)) {
-        $file = fopen("migration/20.03/folders_{$custom}.csv", 'w+');
-        $csvHead = ['Identifiant dossier', 'Libellé dossier', 'Statut dossier', 'Identifiant courrier', 'Numéro chrono', 'Sujet courrier'];
-        fputcsv($file, $csvHead, ',');
-
-        foreach ($folders as $folder) {
-            $csvContent = [$folder['folders_system_id'], $folder['folder_name'], $folder['status'], $folder['res_id'], $folder['alt_identifier'], $folder['subject']];
-            fputcsv($file, $csvContent, ',');
-
-            if (!empty($csvContent)) {
-                ++$migrated;
-            }
-        }
-
-        fclose($file);
-    }
-
-    printf("Export Dossiers (CUSTOM {$custom}) : " . $migrated . " Dossier(s) public(s) exporté(s) dans le fichier folders_{$custom}.csv\n");
-}
diff --git a/migration/20.03/migrate.sh b/migration/20.03/migrate.sh
deleted file mode 100644
index c0706844211511a254af24fd05e6f239cd111d0f..0000000000000000000000000000000000000000
--- a/migration/20.03/migrate.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-php ./exportCustomFields.php
-php ./exportCases.php
-php ./exportFileplans.php
-php ./exportFolders.php
-php ./migrateCategories.php
-php ./migrateCustomFields.php
-php ./migrateFileplans.php
-php ./migrateFolders.php
-php ./migrateFullText.php
-php ./migrateRedirectKeywords.php
-php ./migrateIndexing.php
-php ./migrateListTemplates.php
-php ./migrateServicesEntities.php
-php ./migrateMenuEntities.php
-php ./removeProcessModes.php
-php ./migrateOldIndexingModels.php
-php ./migrateWorkingDays.php
-php ./migrateExtensions.php
-php ./migrateM2MConfiguration.php
-php ./removeNatureFromPrint.php
-php ./migrateCustomValues.php
-# migrateVersionAttachments always before migrateOutgoingAttachments
-php ./migrateVersionAttachments.php
-php ./migrateOutgoingAttachments.php
-php ./migrateContacts.php
-# migrateTemplates always before migrateOutgoingTemplate
-php ./migrateTemplates.php
-php ./migrateOutgoingTemplate.php
-php ./migrateLinkedResources.php
-php ./migrateThesaurus.php
diff --git a/migration/20.03/migrateCategories.php b/migration/20.03/migrateCategories.php
deleted file mode 100644
index ea4bd42df4ab558884540e70f289002f81583e61..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateCategories.php
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$migrated = 0;
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/config.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        
-        if ($loadedXml) {
-            if (!empty($loadedXml->COLLECTION[0]->categories->category)) {
-                foreach ($loadedXml->COLLECTION[0]->categories->category as $category) {
-                    $aCategories[] = (string)$category->id;
-                }
-                if (!empty($aCategories)) {
-                    $indexingModels = \IndexingModel\models\IndexingModelModel::get([
-                        'select'=> ['id'],
-                        'where' => ['category not in (?)'],
-                        'data'  => [$aCategories]
-                    ]);
-    
-                    if (!empty($indexingModels)) {
-                        $indexingModelsId = array_column($indexingModels, 'id');
-    
-                        \IndexingModel\models\IndexingModelFieldModel::delete([
-                            'where' => ['model_id in (?)'],
-                            'data'  => [$indexingModelsId]
-                        ]);
-                    }
-    
-                    \IndexingModel\models\IndexingModelModel::delete([
-                        'where' => ['category not in (?)'],
-                        'data'  => [$aCategories]
-                    ]);
-                }
-                $defaultCategory = (string)$loadedXml->COLLECTION[0]->categories->default_category;
-    
-                \IndexingModel\models\IndexingModelModel::update([
-                    'set'   => [
-                        '"default"' => 'false'
-                    ],
-                    'where' => ['1=?'],
-                    'data' => [1]
-                ]);
-    
-                \IndexingModel\models\IndexingModelModel::update([
-                    'set'   => [
-                        '"default"' => 'true'
-                    ],
-                    'where' => ['category = ?'],
-                    'data' => [$defaultCategory],
-                ]);
-            }
-
-            $i = 0;
-            foreach ($loadedXml->COLLECTION as $value) {
-                unset($loadedXml->COLLECTION[$i]->categories);
-                $i++;
-            }
-
-            $res = formatXml($loadedXml);
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-
-            //Default Priority
-            $defaultPriority = \Priority\models\PriorityModel::get([
-                'select' => ['id'],
-                'where'  => ['default_priority = ?'],
-                'data'   => [1]
-            ]);
-            if (!empty($defaultPriority)) {
-                \SrcCore\models\DatabaseModel::update([
-                    'set'   => ['default_value' => json_encode($defaultPriority[0]['id'])],
-                    'table' => 'indexing_models_fields',
-                    'where' => ['identifier = ?', 'model_id in (SELECT id FROM indexing_models WHERE private = FALSE)'],
-                    'data'  => ['priority']
-                ]);
-            }
-
-            $migrated++;
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
-
-printf($migrated . " custom(s) avec config.xml (categorie) trouvé(s) et migré(s).\n");
-
-function formatXml($simpleXMLElement)
-{
-    $xmlDocument = new DOMDocument('1.0');
-    $xmlDocument->preserveWhiteSpace = false;
-    $xmlDocument->formatOutput = true;
-    $xmlDocument->loadXML($simpleXMLElement->asXML());
-
-    return $xmlDocument->saveXML();
-}
diff --git a/migration/20.03/migrateContacts.php b/migration/20.03/migrateContacts.php
deleted file mode 100644
index d9c2560f27740d7e3d2a2bc33318c0065e6cc77f..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateContacts.php
+++ /dev/null
@@ -1,759 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    $debut = microtime(true);
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    if (file_exists("custom/{$custom}/apps/maarch_entreprise/xml/config.xml")) {
-        $path = "custom/{$custom}/apps/maarch_entreprise/xml/config.xml";
-    } else {
-        $path = 'apps/maarch_entreprise/xml/config.xml';
-    }
-
-    if (file_exists($path)) {
-        $loadedXml = simplexml_load_file($path);
-        if ($loadedXml) {
-            $server     = (string)$loadedXml->CONFIG->databaseserver;
-            $port       = (string)$loadedXml->CONFIG->databaseserverport;
-            $name       = (string)$loadedXml->CONFIG->databasename;
-            $user       = (string)$loadedXml->CONFIG->databaseuser;
-            $password   = (string)$loadedXml->CONFIG->databasepassword;
-        }
-
-        $databaseConnection = pg_connect(
-            'host=' . $server .
-            ' user=' . $user .
-            ' password=' . $password .
-            ' dbname=' . $name .
-            ' port=' . $port
-        );
-    } else {
-        echo "No config file found ";
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    // TRUNCATE CONTACTS TABLES
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'contacts',
-        'where' => ['id > 0']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'contacts_custom_fields_list',
-        'where' => ['id > 0']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'contacts_parameters',
-        'where' => ['id > 0']
-    ]);
-
-    $aValues = [];
-    $migrated = 0;
-    $contactsInfo = \SrcCore\models\DatabaseModel::select([
-        'select' => ['contact_id', 'society', 'contact_firstname', 'contact_lastname', 'contact_title', 'contact_function', 'contact_other_data',
-            'creation_date', 'update_date', 'ca_id', 'departement', 'firstname', 'lastname', 'title', 'function', 'occupancy',
-            'address_num', 'address_street', 'address_complement', 'address_town', 'address_postal_code', 'address_country', 'phone', 'email', 'other_data',
-            'user_id', 'enabled', 'external_id', 'society_short', 'contact_purpose_label', 'contact_type_label', 'website', 'salutation_header', 'salutation_footer'
-        ],
-        'table' => ['view_contacts']
-    ]);
-
-    // Fields not migrated
-    //contact_user_id, contact_enabled, contact_entity_id, entity_id, is_private, is_corporate_person, contact_type, contact_purpose_id
-
-    $contactTypes = \SrcCore\models\DatabaseModel::select([
-        'select' => ['label'],
-        'table'  => ['contact_types']
-    ]);
-    $contactTypes = array_column($contactTypes, 'label');
-
-    $contactPurposes = \SrcCore\models\DatabaseModel::select([
-        'select' => ['label'],
-        'table'  => ['contact_purposes']
-    ]);
-    $contactPurposes = array_column($contactPurposes, 'label');
-
-    $customFields= [
-        ['oldId' => 'salutation_header',     'label' => 'Formule de politesse (Début)',     'type' => 'string',     'value' => ['']],
-        ['oldId' => 'salutation_footer',     'label' => 'Formule de politesse (Fin)',       'type' => 'string',     'value' => ['']],
-        ['oldId' => 'website',               'label' => 'Site internet',                    'type' => 'string',     'value' => ['']],
-        ['oldId' => 'contact_type_label',    'label' => 'Type de contact',                  'type' => 'select',     'value' => $contactTypes],
-        ['oldId' => 'contact_purpose_label', 'label' => 'Dénomination',                     'type' => 'select',     'value' => $contactPurposes],
-        ['oldId' => 'society_short',         'label' => 'Sigle de la structure',            'type' => 'string',     'value' => ['']],
-    ];
-
-    $newCustomFields = addCustomFields(['customFields' => $customFields]);
-
-    $firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1, 'where' => ['status = ?'], 'data' => ['OK']]);
-
-    $table = "contacts (id, civility, firstname, lastname, company, department, function, address_number, address_street,"
-        . "address_additional1, address_additional2, address_postcode, address_town, address_country, email, phone,"
-        . "communication_means, notes, creator, creation_date, modification_date, enabled, external_id)";
-
-    $contactInfoSeparator = "\t";
-
-    $id = 1;
-    $contacts = [];
-    $customInfos = [];
-    $debutMigrateInProgress = microtime(true);
-    foreach ($contactsInfo as $contactInfo) {
-        $oldContactId = $contactInfo['contact_id'];
-        $oldAddressId = $contactInfo['ca_id'];
-        unset($contactInfo['contact_id']);
-        unset($contactInfo['ca_id']);
-
-        // Civility
-        $contactInfo['civility'] = !empty($contactInfo['contact_title']) ? $contactInfo['contact_title'] : $contactInfo['title'];
-        unset($contactInfo['contact_title']);
-        unset($contactInfo['title']);
-
-        // Firstname
-        $contactInfo['firstname'] = !empty($contactInfo['contact_firstname']) ? $contactInfo['contact_firstname'] : $contactInfo['firstname'];
-        unset($contactInfo['contact_firstname']);
-
-        // Lastname
-        $contactInfo['lastname'] = !empty($contactInfo['contact_lastname']) ? $contactInfo['contact_lastname'] : $contactInfo['lastname'];
-        unset($contactInfo['contact_lastname']);
-
-        // Company
-        $contactInfo['company'] = $contactInfo['society'];
-        unset($contactInfo['society']);
-
-        // Function
-        $contactInfo['function'] = !empty($contactInfo['contact_function']) ? $contactInfo['contact_function'] : $contactInfo['function'];
-        unset($contactInfo['contact_function']);
-
-        // Department
-        $contactInfo['department'] = $contactInfo['departement'];
-        unset($contactInfo['departement']);
-
-        // Address
-        $contactInfo['address_number'] = $contactInfo['address_num'];
-        unset($contactInfo['address_num']);
-        $contactInfo['address_additional1'] = $contactInfo['occupancy'];
-        unset($contactInfo['occupancy']);
-        $contactInfo['address_additional2'] = $contactInfo['address_complement'];
-        unset($contactInfo['address_complement']);
-        $contactInfo['address_postcode'] = $contactInfo['address_postal_code'];
-        unset($contactInfo['address_postal_code']);
-
-        //Moyen de communication
-        $communicationMeans = \SrcCore\models\DatabaseModel::select(['select' => ['value'], 'table' => ['contact_communication'], 'where' => ['contact_id = ?'], 'data' => [$oldContactId]]);
-        if (!empty($communicationMeans)) {
-            $communicationMeans = $communicationMeans[0]['value'];
-            if (filter_var($communicationMeans, FILTER_VALIDATE_EMAIL)) {
-                $aCommunicationMeans = ['email' => $communicationMeans];
-            } elseif (filter_var($communicationMeans, FILTER_VALIDATE_URL)) {
-                $aCommunicationMeans = ['url' => $communicationMeans];
-            }
-        }
-        $contactInfo['communication_means'] = !empty($communicationMeans) ? json_encode($aCommunicationMeans) : null;
-
-        // Notes
-        $contactInfo['notes'] = !empty($contactInfo['contact_other_data']) ? $contactInfo['contact_other_data'] : $contactInfo['other_data'];
-        unset($contactInfo['contact_other_data']);
-        unset($contactInfo['other_data']);
-
-        // Creator
-        $creator = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $contactInfo['user_id']]);
-        if (empty($creator)) {
-            $contactInfo['creator'] = $firstMan[0]['id'];
-        } else {
-            $contactInfo['creator'] = $creator['id'];
-        }
-        unset($contactInfo['user_id']);
-
-        // Modification date
-        $contactInfo['modification_date'] = $contactInfo['update_date'];
-        unset($contactInfo['update_date']);
-
-        // Enabled
-        $contactInfo['enabled'] = $contactInfo['enabled'] == 'Y' ? 'true' : 'false';
-
-        $contactCustomInfo = [
-            'salutation_header'     => $contactInfo['salutation_header'],
-            'salutation_footer'     => $contactInfo['salutation_footer'],
-            'website'               => $contactInfo['website'],
-            'contact_type_label'    => $contactInfo['contact_type_label'],
-            'contact_purpose_label' => $contactInfo['contact_purpose_label'],
-            'society_short'         => $contactInfo['society_short'],
-        ];
-
-        unset($contactInfo['salutation_header']);
-        unset($contactInfo['salutation_footer']);
-        unset($contactInfo['website']);
-        unset($contactInfo['contact_type_label']);
-        unset($contactInfo['contact_purpose_label']);
-        unset($contactInfo['society_short']);
-
-        $contactInfo['id'] = $id;
-
-        foreach ($contactInfo as $key => $item) {
-            $contactInfo[$key] = (str_replace("\t", " ", $contactInfo[$key]));
-            $contactInfo[$key] = $contactInfo[$key] ?? "NULL";
-            if (empty($contactInfo[$key])) {
-                $contactInfo[$key] = "NULL";
-            }
-        }
-
-        if ($contactInfo['creation_date'] == 'NULL') {
-            $contactInfo['creation_date'] = 'NOW()';
-        }
-
-        $contact = $id . $contactInfoSeparator
-            . $contactInfo['civility'] . $contactInfoSeparator
-            . $contactInfo['firstname'] . $contactInfoSeparator
-            . $contactInfo['lastname'] . $contactInfoSeparator
-            . $contactInfo['company'] . $contactInfoSeparator
-            . $contactInfo['departement'] . $contactInfoSeparator
-            . $contactInfo['function'] . $contactInfoSeparator
-            . $contactInfo['address_number'] . $contactInfoSeparator
-            . $contactInfo['address_street'] . $contactInfoSeparator
-            . $contactInfo['address_additional1'] . $contactInfoSeparator
-            . $contactInfo['address_additional2'] . $contactInfoSeparator
-            . $contactInfo['address_postcode'] . $contactInfoSeparator
-            . $contactInfo['address_town'] . $contactInfoSeparator
-            . $contactInfo['address_country'] . $contactInfoSeparator
-            . $contactInfo['email'] . $contactInfoSeparator
-            . $contactInfo['phone'] . $contactInfoSeparator
-            . $contactInfo['communication_means'] . $contactInfoSeparator
-            . $contactInfo['notes'] . $contactInfoSeparator
-            . $contactInfo['creator'] . $contactInfoSeparator
-            . $contactInfo['creation_date'] . $contactInfoSeparator
-            . $contactInfo['modification_date'] . $contactInfoSeparator
-            . $contactInfo['enabled'] . $contactInfoSeparator
-            . $contactInfo['external_id'];
-
-        $contact = str_replace("\r", " ", $contact);
-        $contact = str_replace("\n", " ", $contact);
-
-        $contacts[] = $contact;
-
-        $ids[$id] = ['oldAddressId' => $oldAddressId, 'oldContactId' => $oldContactId];
-
-        $customInfos[$id] = $contactCustomInfo;
-
-        $currentValuesContactRes = migrateContactRes(['oldAddressId' => $oldAddressId, 'oldContactId' => $oldContactId, 'newContactId' => $id]);
-
-        $aValues = array_merge($aValues, $currentValuesContactRes);
-
-        $migrated++;
-
-        if ($migrated % 5000 == 0) {
-            $finMigrateInProgress = microtime(true);
-            $delaiInProgress = $finMigrateInProgress - $debutMigrateInProgress;
-            echo "Migration En cours : ".$delaiInProgress." secondes.\n";
-            $debutMigrateInProgress = microtime(true);
-            printf($migrated . " contact(s) migré(s) - En cours...\n");
-        }
-
-        if ($migrated % 50000 == 0) {
-            echo "Migration de 50000 contacts...\n";
-
-            $beforeCopyContacts = microtime(true);
-            pg_copy_from($databaseConnection, $table, $contacts, $contactInfoSeparator, "NULL");
-            $afterCopyContacts = microtime(true);
-            $copyTimeContacts = $afterCopyContacts - $beforeCopyContacts;
-            echo "Temps copy contacts = $copyTimeContacts\n";
-
-            $beforeCustomFields = microtime(true);
-            foreach ($customInfos as $newId => $customInfo) {
-                migrateCustomField(['newContactId' => $newId, 'contactCustomInfo' => $customInfo, 'newCustomFields' => $newCustomFields]);
-            }
-            $customInfos = [];
-            $afterCustomFields = microtime(true);
-            $timeCustoms = $afterCustomFields - $beforeCustomFields;
-            echo "Temps migrate custom fields = $timeCustoms\n";
-
-            pg_copy_from($databaseConnection, 'resource_contacts (res_id, item_id, type, mode)', $aValues, "\t", 	"\\\\N");
-            $finMigrateInProgress = microtime(true);
-            $delaiInProgress = $finMigrateInProgress - $debutMigrateInProgress;
-            echo "Migration En cours : ".$delaiInProgress." secondes.\n";
-            $debutMigrateInProgress = microtime(true);
-            printf($migrated . " contact(s) migré(s) - En cours...\n");
-            $aValues = [];
-
-            $contacts = [];
-        }
-
-        $id++;
-    }
-
-    if (!empty($aValues)) {
-        $beforeCopy = microtime(true);
-        pg_copy_from($databaseConnection, 'resource_contacts (res_id, item_id, type, mode)', $aValues, "\t", "\\\\N");
-        $afterCopy = microtime(true);
-        $copyTime = $afterCopy - $beforeCopy;
-        echo "Temps copy resource contacts = $copyTime secondes\n";
-    }
-
-    if (!empty($contacts)) {
-        $beforeCopyContacts = microtime(true);
-        pg_copy_from($databaseConnection, $table, $contacts, $contactInfoSeparator, "NULL");
-        $afterCopyContacts = microtime(true);
-        $copyTimeContacts = $afterCopyContacts - $beforeCopyContacts;
-        echo "Temps copy contacts = $copyTimeContacts\n";
-    }
-
-    if (!empty($customInfos)) {
-        $beforeCustomFields = microtime(true);
-        foreach ($customInfos as $newId => $customInfo) {
-            migrateCustomField(['newContactId'    => $newId, 'contactCustomInfo' => $customInfo,
-                                'newCustomFields' => $newCustomFields]);
-        }
-        $customInfos = [];
-        $afterCustomFields = microtime(true);
-        $timeCustoms = $afterCustomFields - $beforeCustomFields;
-        echo "Temps migrate custom fields = $timeCustoms\n";
-    }
-
-    $beforeUpdates = microtime(true);
-    $valuesOldAddress = '';
-    $firstDone = false;
-    foreach ($ids as $newId => $value) {
-        $oldAddressId = $value['oldAddressId'];
-        if ($firstDone) {
-            $valuesOldAddress .= ', ';
-        }
-        $valuesOldAddress .= "( $newId , $oldAddressId)";
-        if (!$firstDone) {
-            $firstDone = true;
-        }
-    }
-
-    // Migrate addresses in res_letterbox
-    $query = "insert into resource_contacts (res_id, item_id, type, mode)
-    select res_id, tmp.new_id, 'contact_v3' as type,
-       case
-           when category_id = 'outgoing' then 'recipient'
-           else 'sender'
-       end as mode
-    from res_letterbox,
-         (values 
-             $valuesOldAddress
-         ) as tmp(new_id, old_address_id)
-    where tmp.old_address_id = res_letterbox.address_id";
-    pg_query($databaseConnection, $query);
-
-
-    // Acknowledgement Receipts
-    $query = "update acknowledgement_receipts as ar set
-            contact_id = tmp.new_id
-        from (values
-               $valuesOldAddress 
-            ) as tmp(new_id, old_address_id) 
-        where ar.contact_address_id = tmp.old_address_id";
-    pg_query($databaseConnection, $query);
-
-
-    // Group list
-    $query = "update contacts_groups_lists as cgl set
-            contact_id = tmp.new_id
-        from (values
-               $valuesOldAddress
-            ) as tmp(new_id, old_address_id) 
-        where cgl.contact_addresses_id = tmp.old_address_id";
-
-    pg_query($databaseConnection, $query);
-
-
-    // Resources contacts
-    $query = "update resource_contacts as rc set
-        item_id = tmp.new_id, type = 'contact_v3'
-    from (values
-           $valuesOldAddress
-        ) as tmp(new_id, old_address_id) 
-    where rc.item_id = tmp.old_address_id and type = 'contact'";
-    pg_query($databaseConnection, $query);
-
-    $valuesOld= '';
-    $firstDone = false;
-    foreach ($ids as $newId => $value) {
-        $oldAddressId = !empty($value['oldAddressId']) ? $value['oldAddressId'] : 'NULL';
-        $oldContactId = !empty($value['oldContactId']) ? $value['oldContactId'] : 'NULL';
-
-        if ($firstDone) {
-            $valuesOld .= ', ';
-        }
-        $valuesOld .= "( $newId , $oldAddressId, $oldContactId)";
-        if (!$firstDone) {
-            $firstDone = true;
-        }
-    }
-
-    // Res attach
-    $query = "update res_attachments as ra set
-        recipient_id = tmp.new_id, recipient_type = 'contact'
-    from (values
-           $valuesOld
-        ) as tmp(new_id, old_address_id, old_contact_id) 
-    where ra.dest_contact_id = tmp.old_contact_id and ra.dest_address_id = tmp.old_address_id";
-    pg_query($databaseConnection, $query);
-
-    $afterUpdates = microtime(true);
-    $updatesTime = $afterUpdates - $beforeUpdates;
-    echo "Temps updates = $updatesTime secondes\n";
-
-    $finMigrateInProgress = microtime(true);
-    $delaiInProgress = $finMigrateInProgress - $debutMigrateInProgress;
-    echo "Dernière Migration En cours : ".$delaiInProgress." secondes.\n";
-    $debutMigrateInProgress = microtime(true);
-    printf($migrated . " contact(s) migré(s) - Fin...\n");
-
-    $debutEndMigrate = microtime(true);
-    migrateContactRes_Users(['firstManId' => $firstMan[0]['id'], 'databaseConnection' => $databaseConnection]);
-    migrateResletterbox_Users(['firstManId' => $firstMan[0]['id'], 'databaseConnection' => $databaseConnection]);
-    migrateResattachments_Users(['firstManId' => $firstMan[0]['id']]);
-    migrateContactParameters();
-    migrateContactPrivileges();
-    $finEndMigrate = microtime(true);
-    $delaiEndMigrate = $finEndMigrate - $debutEndMigrate;
-    echo "Migration du bas : ".$delaiEndMigrate." secondes.\n";
-
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['type' => 'contact'],
-        'table' => 'resource_contacts',
-        'where' => ['type = ?'],
-        'data'  => ['contact_v3']
-    ]);
-
-    $fin = microtime(true);
-    $delai = $fin - $debut;
-    echo "Le temps écoulé est de ".$delai." secondes.\n";
-    printf("Migration Contacts (CUSTOM {$custom}) : " . $migrated . " Contact(s) trouvée(s) et migrée(s).\n");
-}
-
-function addCustomFields($args = [])
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    $fillingValues = \SrcCore\models\DatabaseModel::select([
-        'select' => ['rating_columns'],
-        'table'  => ['contacts_filling']
-    ]);
-
-    $fillingValues = json_decode($fillingValues[0]['rating_columns'], true);
-
-    $customFields = [];
-    $aValues      = [];
-    foreach ($args['customFields'] as $value) {
-        $customFieldId = \Contact\models\ContactCustomFieldListModel::create([
-            'label'  => $value['label'],
-            'type'   => $value['type'],
-            'values' => json_encode($value['value'])
-        ]);
-
-        $filling = 'false';
-        if (in_array($value['oldId'], $fillingValues)) {
-            $filling = 'true';
-        }
-
-        $aValues[] = [
-            'contactCustomField_' . $customFieldId,
-            'false',
-            $filling,
-            'false',
-            'false',
-        ];
-
-        $customFields[$value['oldId']] = $customFieldId;
-    }
-
-    if (!empty($aValues)) {
-        \SrcCore\models\DatabaseModel::insertMultiple([
-            'table'    => 'contacts_parameters',
-            'columns'  => ['identifier', 'mandatory', 'filling', 'searchable', 'displayable'],
-            'values'   => $aValues
-        ]);
-    }
-    \SrcCore\models\DatabaseModel::commitTransaction();
-    return $customFields;
-}
-
-function migrateCustomField($args = [])
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    foreach ($args['contactCustomInfo'] as $key => $value) {
-        if (!empty($value)) {
-            $value = json_encode($value);
-            $value = str_replace("'", "''", $value);
-            \Contact\models\ContactModel::update([
-                'postSet' => ['custom_fields' => "jsonb_set('{}', '{{$args['newCustomFields'][$key]}}', '{$value}')"],
-                'where' => ['id = ?'],
-                'data' => [$args['newContactId']]
-            ]);
-        }
-    }
-    \SrcCore\models\DatabaseModel::commitTransaction();
-}
-
-function migrateContactRes($args = [])
-{
-    $contactRes = \SrcCore\models\DatabaseModel::select([
-        'select' => ['res_id'],
-        'table'  => ['contacts_res'],
-        'where'  => ['contact_id = ?', 'address_id = ?'],
-        'data'  => [$args['oldContactId'], $args['oldAddressId']],
-    ]);
-
-    $aValues = [];
-    foreach ($contactRes as $value) {
-        $resInfo = \SrcCore\models\DatabaseModel::select([
-            'select' => ['category_id'],
-            'table'  => ['res_letterbox'],
-            'where'  => ['res_id = ?'],
-            'data'   => [$value['res_id']]
-        ]);
-
-        $mode = 'sender';
-        if ($resInfo[0]['category_id'] == 'outgoing') {
-            $mode = 'recipient';
-        }
-
-        $aValues[] = implode("\t", [
-            $value['res_id'],
-            $args['newContactId'],
-            'contact_v3',
-            $mode
-        ]) . "\n";
-    }
-
-    return $aValues;
-}
-
-function migrateContactRes_Users($args = [])
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    $userContactRes = \SrcCore\models\DatabaseModel::select([
-        'select' => ['res_id', 'contact_id'],
-        'table'  => ['contacts_res'],
-        'where'  => ['address_id = 0']
-    ]);
-
-    $aValues = [];
-    foreach ($userContactRes as $value) {
-        $resInfo = \SrcCore\models\DatabaseModel::select([
-            'select' => ['category_id'],
-            'table'  => ['res_letterbox'],
-            'where'  => ['res_id = ?'],
-            'data'   => [$value['res_id']]
-        ]);
-
-        $user = \User\models\UserModel::getByLogin(['login' => $value['contact_id'], 'select' => ['id']]);
-        if (empty($user)) {
-            $user = $args['firstManId'];
-        } else {
-            $user = $user['id'];
-        }
-
-        $mode = 'sender';
-        if ($resInfo[0]['category_id'] == 'outgoing') {
-            $mode = 'recipient';
-        }
-
-        $aValues[] = implode("\t", [
-            $value['res_id'],
-            $user,
-            'user',
-            $mode
-        ]) . "\n";
-    }
-
-    if (!empty($aValues)) {
-        pg_copy_from($args['databaseConnection'], 'resource_contacts (res_id, item_id, type, mode)', $aValues, "\t", "\\\\N");
-    }
-    \SrcCore\models\DatabaseModel::commitTransaction();
-}
-
-function migrateResletterbox_Users($args = [])
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    $userContact = \SrcCore\models\DatabaseModel::select([
-        'select' => ['res_id', 'exp_user_id', 'dest_user_id'],
-        'table'  => ['res_letterbox'],
-        'where'  => ['(exp_user_id != \'\' and exp_user_id is not null) or (dest_user_id != \'\' and dest_user_id is not null)']
-    ]);
-
-    $aValues = [];
-    foreach ($userContact as $value) {
-        if (!empty($value['exp_user_id'])) {
-            $login = $value['exp_user_id'];
-            $mode = 'sender';
-        } else {
-            $login = $value['dest_user_id'];
-            $mode = 'recipient';
-        }
-        if (empty($login)) {
-            continue;
-        }
-        $user = \User\models\UserModel::getByLogin(['login' => $login, 'select' => ['id']]);
-        if (empty($user)) {
-            $user = $args['firstManId'];
-        } else {
-            $user = $user['id'];
-        }
-
-        $aValues[] = implode("\t", [
-            $value['res_id'],
-            $user,
-            'user',
-            $mode
-        ]) . "\n";
-    }
-
-    if (!empty($aValues)) {
-        pg_copy_from($args['databaseConnection'], 'resource_contacts (res_id, item_id, type, mode)', $aValues, "\t", "\\\\N");
-    }
-    \SrcCore\models\DatabaseModel::commitTransaction();
-}
-
-function migrateResattachments_Users($args = [])
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    $attachments = \SrcCore\models\DatabaseModel::select([
-        'select' => ['dest_user', 'res_id'],
-        'table'  => ['res_attachments'],
-        'where'  => ['dest_user != \'\' and dest_user is not null']
-    ]);
-
-    foreach ($attachments as $value) {
-        $user = \User\models\UserModel::getByLogin(['login' => $value['dest_user'], 'select' => ['id']]);
-        if (empty($user)) {
-            $user = $args['firstManId'];
-        } else {
-            $user = $user['id'];
-        }
-
-        \SrcCore\models\DatabaseModel::update([
-            'set'   => ['recipient_id' => $user, 'recipient_type' => 'user'],
-            'table' => 'res_attachments',
-            'where' => ['res_id = ?'],
-            'data'  => [$value['res_id']],
-        ]);
-    }
-    \SrcCore\models\DatabaseModel::commitTransaction();
-}
-
-function migrateContactParameters()
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    $fillingValues = \SrcCore\models\DatabaseModel::select([
-        'select' => ['rating_columns'],
-        'table'  => ['contacts_filling']
-    ]);
-
-    $fillingValues = json_decode($fillingValues[0]['rating_columns'], true);
-
-    $contactParameters = [
-        ['oldIdentifier' => 'title',                'identifier' => 'civility',             'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'firstname',            'identifier' => 'firstname',            'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'true', 'displayable' => 'true'],
-        ['oldIdentifier' => 'lastname',             'identifier' => 'lastname',             'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'true', 'displayable' => 'true'],
-        ['oldIdentifier' => 'society',              'identifier' => 'company',              'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'true', 'displayable' => 'true'],
-        ['oldIdentifier' => 'departement',          'identifier' => 'department',           'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'function',             'identifier' => 'function',             'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'address_num',          'identifier' => 'addressNumber',        'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'true', 'displayable' => 'true'],
-        ['oldIdentifier' => 'address_street',       'identifier' => 'addressStreet',        'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'true', 'displayable' => 'true'],
-        ['oldIdentifier' => 'occupancy',            'identifier' => 'addressAdditional1',   'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'address_complement',   'identifier' => 'addressAdditional2',   'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'address_postal_code',  'identifier' => 'addressPostcode',      'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'address_town',         'identifier' => 'addressTown',          'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'true', 'displayable' => 'true'],
-        ['oldIdentifier' => 'address_country',      'identifier' => 'addressCountry',       'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'email',                'identifier' => 'email',                'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-        ['oldIdentifier' => 'phone',                'identifier' => 'phone',                'mandatory' => 'false', 'filling' => 'false', 'searchable' => 'false', 'displayable' => 'false'],
-    ];
-    
-    foreach ($contactParameters as $value) {
-        $filling = 'false';
-        if (in_array($value['oldIdentifier'], ['lastname', 'society']) || in_array($value['oldIdentifier'], $fillingValues)) {
-            $filling = 'true';
-        }
-
-        $aValues[] = [
-            $value['identifier'],
-            $value['mandatory'],
-            $filling,
-            $value['searchable'],
-            $value['displayable']
-        ];
-    }
-
-    \SrcCore\models\DatabaseModel::insertMultiple([
-        'table'     => 'contacts_parameters',
-        'columns'   => ['identifier', 'mandatory', 'filling', 'searchable', 'displayable'],
-        'values'    => $aValues
-    ]);
-    
-    \SrcCore\models\DatabaseModel::commitTransaction();
-}
-
-function migrateContactPrivileges()
-{
-    \SrcCore\models\DatabaseModel::beginTransaction();
-    $usergroupServices = \SrcCore\models\DatabaseModel::select([
-        'select' => ['group_id'],
-        'table'  => ['usergroups_services'],
-        'where'  => ['service_id = ?'],
-        'data'   => ['create_contacts']
-    ]);
-
-    foreach ($usergroupServices as $usergroupService) {
-        $servicesEnabled = \SrcCore\models\DatabaseModel::select([
-            'select' => ['group_id'],
-            'table'  => ['usergroups_services'],
-            'where'  => ['service_id = ?', 'group_id = ?'],
-            'data'   => ['update_contacts', $usergroupService['group_id']]
-        ]);
-        if (empty($servicesEnabled)) {
-            \SrcCore\models\DatabaseModel::insert([
-                'table'         => 'usergroups_services',
-                'columnsValues' => [
-                    'service_id' => 'update_contacts',
-                    'group_id'   => $usergroupService['group_id']
-                ]
-            ]);
-        }
-    }
-
-    foreach (['my_contacts_menu', 'my_contacts'] as $service) {
-        $usergroupServices = \SrcCore\models\DatabaseModel::select([
-            'select' => ['group_id'],
-            'table'  => ['usergroups_services'],
-            'where'  => ['service_id = ?'],
-            'data'   => [$service]
-        ]);
-    
-        foreach ($usergroupServices as $usergroupService) {
-            $servicesEnabled = \SrcCore\models\DatabaseModel::select([
-                'select' => ['group_id', 'service_id'],
-                'table'  => ['usergroups_services'],
-                'where'  => ['service_id = ?', 'group_id = ?'],
-                'data'   => ['create_contacts', $usergroupService['group_id']]
-            ]);
-            if (empty($servicesEnabled)) {
-                \SrcCore\models\DatabaseModel::insert([
-                    'table'         => 'usergroups_services',
-                    'columnsValues' => [
-                        'service_id' => 'create_contacts',
-                        'group_id'   => $usergroupService['group_id']
-                    ]
-                ]);
-            }
-        }
-    }
-
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'usergroups_services',
-        'where' => ['service_id in (?)'],
-        'data'  => [['my_contacts_menu', 'my_contacts']]
-    ]);
-    \SrcCore\models\DatabaseModel::commitTransaction();
-}
diff --git a/migration/20.03/migrateCustomFields.php b/migration/20.03/migrateCustomFields.php
deleted file mode 100755
index 9fdab722c6c1629b10eeb921e0d2813032f41d8f..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateCustomFields.php
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = 0;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/index_letterbox.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        
-        if ($loadedXml) {
-            $indexingModels = \IndexingModel\models\IndexingModelModel::get(['select'=> ['id']]);
-            if (!empty($indexingModels)) {
-                $indexingModelsId = array_column($indexingModels, 'id');
-            }
-
-            $i = 0;
-            foreach ($loadedXml->INDEX as $value) {
-                $customExists = \SrcCore\models\DatabaseModel::select([
-                        'select' => [1],
-                        'table'  => ['doctypes_indexes'],
-                        'where'  => ['field_name = ?'],
-                        'data'   => [(string)$value->column]
-                ]);
-                if (empty($customExists)) {
-                    continue;
-                }
-
-                $label = (string)$value->label;
-                $type = trim((string)$value->type);
-                if ($type == 'float') {
-                    $type = 'integer';
-                }
-
-                $values = [];
-                if (!empty($value->values_list)) {
-                    foreach ($value->values_list->value as $valueList) {
-                        $values[] = (string)$valueList->label;
-                    }
-                }
-                if (!empty($value->table) && !empty($value->table->table_name) && !empty($value->table->foreign_label)) {
-                    $tableName    = (string)$value->table->table_name;
-                    $foreignLabel = (string)$value->table->foreign_label;
-                    $whereClause  = (string)$value->table->where_clause;
-                    $order        = (string)$value->table->order;
-
-                    $customValues = \SrcCore\models\DatabaseModel::select([
-                        'select'   => [$foreignLabel],
-                        'table'    => [$tableName],
-                        'where'    => empty($whereClause) ? [] : [$whereClause],
-                        'order_by' => [str_ireplace("order by", "", $order)]
-                    ]);
-
-                    foreach ($customValues as $valueList) {
-                        $values[] = $valueList[$foreignLabel];
-                    }
-                }
-
-                $fieldId = \CustomField\models\CustomFieldModel::create([
-                    'label'     => $label,
-                    'type'      => $type,
-                    'values'    => empty($values) ? '[]' : json_encode($values)
-                ]);
-
-                if (!empty($indexingModelsId)) {
-                    foreach ($indexingModelsId as $indexingModelId) {
-                        \SrcCore\models\DatabaseModel::insert([
-                            'table'         => 'indexing_models_fields',
-                            'columnsValues' => [
-                                'model_id'      => $indexingModelId,
-                                'identifier'    => 'indexingCustomField_'.$fieldId,
-                                'mandatory'     => 'false',
-                                'default_value' => null,
-                                'unit'          => 'mail'
-                            ]
-                        ]);
-                    }
-                }
-
-                $column = (string)$value->column;
-                $csColumn = "custom_fields->>''{$fieldId}''";
-
-                if ($type == 'date') {
-                    $csColumn = "custom_fields->>''{$fieldId}'' is not null and custom_fields->>''{$fieldId}'' <> '''' and ($csColumn)::date";
-                }
-
-                \Basket\models\BasketModel::update(['postSet' => ['basket_clause' => "REPLACE(basket_clause, 'doc_{$column}', '{$csColumn}')"], 'where' => ['1 = ?'], 'data' => [1]]);
-                \Basket\models\BasketModel::update(['postSet' => ['basket_clause' => "REPLACE(basket_clause, '{$column}', '{$csColumn}')"], 'where' => ['1 = ?'], 'data' => [1]]);
-                $resources = \Resource\models\ResModel::get([
-                    'select'    => ['res_id', $column],
-                    'where'     => [$column . ' is not null'],
-                ]);
-
-                foreach ($resources as $resource) {
-                    $valueColumn = json_encode($resource[$column]);
-                    $valueColumn = str_replace("'", "''", $valueColumn);
-                    $resId = $resource['res_id'];
-                    \Resource\models\ResModel::update([
-                        'postSet'   => ['custom_fields' => "jsonb_set(custom_fields, '{{$fieldId}}', '{$valueColumn}')"],
-                        'where'     => ['res_id = ?'],
-                        'data'      => [$resId]
-                    ]);
-                }
-
-                $migrated++;
-            }
-        }
-    }
-
-    printf("Migration Champs Custom (CUSTOM {$custom}) : " . $migrated . " Champs custom utilisé(s) et migré(s).\n");
-}
diff --git a/migration/20.03/migrateCustomValues.php b/migration/20.03/migrateCustomValues.php
deleted file mode 100755
index 243336734d62e9b85cb8c72c2905f59712d28de2..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateCustomValues.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = [];
-
-    // Migrate others Field
-    $migrateToCustom = [
-        ['id' => 'description',         'label' => 'Autres informations',             'customType' => 'string', 'modelId' => [1, 2, 3, 4]],
-        ['id' => 'external_reference',  'label' => 'Référence courrier expéditeur',   'customType' => 'string', 'modelId' => [1]],
-        ['id' => 'reference_number',    'label' => 'N° recommandé',                   'customType' => 'string', 'modelId' => [1, 2]],
-        ['id' => 'scan_date',           'label' => 'Date de scan',                    'customType' => 'date',   'modelId' => [1, 2]],
-        ['id' => 'scan_user',           'label' => 'Utilisateur de scan',             'customType' => 'string', 'modelId' => [1, 2]],
-        ['id' => 'scan_location',       'label' => 'Lieu de scan',                    'customType' => 'string', 'modelId' => [1, 2]],
-        ['id' => 'scan_wkstation',      'label' => 'Station de scan',                 'customType' => 'string', 'modelId' => [1, 2]],
-        ['id' => 'scan_batch',          'label' => 'Batch de scan',                   'customType' => 'string', 'modelId' => [1, 2]],
-        ['id' => 'scan_postmark',       'label' => 'Tampon de scan',                  'customType' => 'string', 'modelId' => [1, 2]],
-    ];
-
-    foreach ($migrateToCustom as $migration) {
-        if ($migration['customType'] == 'date') {
-            $where = [$migration['id'].' is not null'];
-        } else {
-            $where = [$migration['id'].' is not null', $migration['id'].' != \'\''];
-        }
-        $columnValues = \SrcCore\models\DatabaseModel::select([
-            'select' => ['res_id', $migration['id']],
-            'table'  => ['res_letterbox'],
-            'where'  => $where
-        ]);
-
-        if (!empty($columnValues)) {
-            $fieldId = \CustomField\models\CustomFieldModel::create([
-                'label'     => $migration['label'],
-                'type'      => $migration['customType'],
-                'values'    => '[]'
-            ]);
-
-            $csColumn = "custom_fields->>''{$fieldId}''";
-            if ($type == 'date') {
-                $csColumn = "($csColumn)::date";
-            }
-            \Basket\models\BasketModel::update(['postSet' => ['basket_clause' => "REPLACE(basket_clause, '{$migration['id']}', '{$csColumn}')"], 'where' => ['1 = ?'], 'data' => [1]]);
-
-            foreach ($migration['modelId'] as $modelId) {
-                $indexingModels = \IndexingModel\models\IndexingModelModel::get([
-                    'select'=> [1],
-                    'where' => ['id = ?'],
-                    'data'  => [$modelId]
-                ]);
-
-                if (!empty($indexingModels)) {
-                    \SrcCore\models\DatabaseModel::insert([
-                        'table'         => 'indexing_models_fields',
-                        'columnsValues' => [
-                            'model_id'      => $modelId,
-                            'identifier'    => 'indexingCustomField_'.$fieldId,
-                            'mandatory'     => 'false',
-                            'default_value' => null,
-                            'unit'          => 'mail'
-                        ]
-                    ]);
-                }
-            }
-    
-            $aValues = [];
-            foreach ($columnValues as $columnValue) {
-                $aValues[] = [$columnValue['res_id'], $fieldId, json_encode($columnValue[$migration['id']])];
-                $valueColumn = json_encode($columnValue[$migration['id']]);
-                $valueColumn = str_replace("'", "''", $valueColumn);
-                \Resource\models\ResModel::update([
-                    'postSet'   => ['custom_fields' => "jsonb_set(custom_fields, '{{$fieldId}}', '{$valueColumn}')"],
-                    'where'     => ['res_id = ?'],
-                    'data'      => [$columnValue['res_id']]
-                ]);
-            }
-
-            $migrated[] = $migration['id'];
-        }
-    }
-
-    if (!empty($migrated)) {
-        $migrated = implode(',', $migrated);
-        printf("Migration vers les champs personnalisés (CUSTOM {$custom}) : Les champs suivants ont été migrés : " . $migrated . ".\n");
-    }
-}
diff --git a/migration/20.03/migrateExtensions.php b/migration/20.03/migrateExtensions.php
deleted file mode 100644
index f88f005b18d4a20ce8d7224f23b1970d519af274..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateExtensions.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/extensions.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-
-        if ($xmlfile) {
-            $i = 0;
-            foreach ($xmlfile->FORMAT as $item) {
-                if (isset($item->index_frame_show)) {
-                    $xmlfile->FORMAT[$i]->canConvert = $item->index_frame_show;
-                    unset($xmlfile->FORMAT[$i]->index_frame_show);
-                }
-                ++$i;
-            }
-
-            $res = $xmlfile->asXML();
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-
-            $migrated++;
-        }
-    }
-}
-
-printf("Migration Extensions : " . $migrated . " custom(s) avec un fichier extensions.xml trouvé(s) et migré(s).\n");
diff --git a/migration/20.03/migrateFileplans.php b/migration/20.03/migrateFileplans.php
deleted file mode 100644
index 4fe647c43d8e3e47328d9bdbfc3ae1d34eab7134..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateFileplans.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = 0;
-
-    $fileplans = \SrcCore\models\DatabaseModel::select([
-        'select' => ['*'],
-        'table'  => ['fp_fileplan']
-    ]);
-
-    if (!empty($fileplans)) {
-
-        $superadmin = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => 'superadmin']);
-        if (empty($superadmin)) {
-            $firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1]);
-            $masterOwnerId = $firstMan[0]['id'];
-        } else {
-            $masterOwnerId = $superadmin['id'];
-        }
-
-        $masterFolderId = \Folder\models\FolderModel::create([
-            'label'     => 'Reprise Plan de Classement',
-            'public'    => true,
-            'user_id'   => $masterOwnerId,
-            'parent_id' => null,
-            'level'     => 0
-        ]);
-
-        fillEntities($masterFolderId);
-
-        foreach ($fileplans as $fileplan) {
-            $positions = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['*'],
-                'table'     => ['fp_fileplan_positions'],
-                'where'     => ['fileplan_id = ?'],
-                'data'      => [$fileplan['fileplan_id']]
-            ]);
-
-            if (empty($fileplan['user_id'])) {
-                $id = \Folder\models\FolderModel::create([
-                    'label'     => $fileplan['fileplan_label'],
-                    'public'    => true,
-                    'user_id'   => $masterOwnerId,
-                    'parent_id' => $masterFolderId,
-                    'level'     => 1
-                ]);
-                fillEntities($id);
-
-                foreach ($positions as $position) {
-                    if (empty($position['parent_id'])) {
-                        $id = \Folder\models\FolderModel::create([
-                            'label'     => $position['position_label'],
-                            'public'    => true,
-                            'user_id'   => $masterOwnerId,
-                            'parent_id' => $id,
-                            'level'     => 2
-                        ]);
-                        fillEntities($id);
-
-                        runPositionsForPublic($positions, $position['position_id'], $id, 3, $masterOwnerId);
-                    }
-                }
-            } else {
-                $user = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $fileplan['user_id']]);
-                if (empty($user)) {
-                    continue;
-                }
-
-                $id = \Folder\models\FolderModel::create([
-                    'label'     => $fileplan['fileplan_label'],
-                    'public'    => false,
-                    'user_id'   => $user['id'],
-                    'parent_id' => null,
-                    'level'     => 0
-                ]);
-
-                foreach ($positions as $position) {
-                    if (empty($position['parent_id'])) {
-                        $id = \Folder\models\FolderModel::create([
-                            'label'     => $position['position_label'],
-                            'public'    => false,
-                            'user_id'   => $user['id'],
-                            'parent_id' => $id,
-                            'level'     => 1
-                        ]);
-                        fillResources($id, $position['position_id']);
-
-                        runPositionsForPrivate($positions, $position['position_id'], $id, 2, $user['id']);
-                    }
-                }
-            }
-
-            ++$migrated;
-        }
-    }
-
-    printf("Migration Plan de Classement (CUSTOM {$custom}) : " . $migrated . " Plan trouvé(s) et migré(s).\n");
-}
-
-function runPositionsForPublic($positions, $parentPositionId, $parentFolderId, $level, $masterOwnerId)
-{
-    foreach ($positions as $position) {
-        if ($position['parent_id'] == $parentPositionId) {
-            $id = \Folder\models\FolderModel::create([
-                'label'     => $position['position_label'],
-                'public'    => true,
-                'user_id'   => $masterOwnerId,
-                'parent_id' => $parentFolderId,
-                'level'     => $level
-            ]);
-            fillEntities($id);
-
-            runPositionsForPublic($positions, $position['position_id'], $id, $level + 1, $masterOwnerId);
-            break;
-        }
-    }
-}
-
-function runPositionsForPrivate($positions, $parentPositionId, $parentFolderId, $level, $ownerId)
-{
-    foreach ($positions as $position) {
-        if ($position['parent_id'] == $parentPositionId) {
-            $id = \Folder\models\FolderModel::create([
-                'label'     => $position['position_label'],
-                'public'    => false,
-                'user_id'   => $ownerId,
-                'parent_id' => $parentFolderId,
-                'level'     => $level
-            ]);
-            fillResources($id, $position['position_id']);
-
-            runPositionsForPrivate($positions, $position['position_id'], $id, $level + 1, $ownerId);
-            break;
-        }
-    }
-}
-
-function fillEntities($folderId)
-{
-    \Folder\models\EntityFolderModel::create([
-        'folder_id' => $folderId,
-        'entity_id' => null,
-        'edition'   => true,
-        'keyword'   => 'ALL_ENTITIES'
-    ]);
-}
-
-function fillResources($folderId, $positionId)
-{
-    $resources = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['*'],
-        'table'     => ['fp_res_fileplan_positions'],
-        'where'     => ['position_id = ?', 'coll_id = ?'],
-        'data'      => [$positionId, 'letterbox_coll']
-    ]);
-
-    foreach ($resources as $resource) {
-        \Folder\models\ResourceFolderModel::create([
-            'folder_id' => $folderId,
-            'res_id'    => $resource['res_id']
-        ]);
-    }
-}
diff --git a/migration/20.03/migrateFolders.php b/migration/20.03/migrateFolders.php
deleted file mode 100644
index 049d9edd1d8f6ee9f33ac1a91ed28654d58a7a3c..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateFolders.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = 0;
-    $folders = \SrcCore\models\DatabaseModel::select([
-        'select'   => ['folders_system_id', 'typist', 'destination', 'folder_name', 'parent_id'],
-        'table'    => ['folder_tmp'],
-        'order_by' => ['folder_level asc']
-    ]);
-
-    if (!empty($folders)) {
-        $superadmin = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => 'superadmin']);
-        if (empty($superadmin)) {
-            $firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1]);
-            $masterOwnerId = $firstMan[0]['id'];
-        } else {
-            $masterOwnerId = $superadmin['id'];
-        }
-
-        $masterFolderId = \Folder\models\FolderModel::create([
-            'label'     => 'Reprise Dossier',
-            'public'    => true,
-            'user_id'   => $masterOwnerId,
-            'parent_id' => null,
-            'level'     => 0
-        ]);
-
-        fillEntities($masterFolderId);
-
-        $aFolderIdMap = [];
-        foreach ($folders as $folder) {
-            if (empty($folder['typist'])) {
-                $user['id'] = $masterOwnerId;
-            } else {
-                $user = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $folder['typist']]);
-            }
-            if (empty($folder['destination'])) {
-                // Public
-                if (empty($user)) {
-                    $user['id'] = $masterOwnerId;
-                }
-
-                $folderId = \Folder\models\FolderModel::create([
-                    'label'     => $folder['folder_name'],
-                    'public'    => true,
-                    'user_id'   => $user['id'],
-                    'parent_id' => empty($folder['parent_id']) ? $masterFolderId : $aFolderIdMap[$folder['parent_id']],
-                    'level'     => empty($folder['parent_id']) ? 1 : 2
-                ]);
-                fillEntities($folderId);
-            } elseif (!empty($user)) {
-                // Private
-                $entity = \Entity\models\EntityModel::getByEntityId(['select' => ['id'], 'entityId' => $folder['destination']]);
-                if (empty($entity)) {
-                    continue;
-                }
-
-                $folderId = \Folder\models\FolderModel::create([
-                    'label'     => $folder['folder_name'],
-                    'public'    => true,
-                    'user_id'   => $user['id'],
-                    'parent_id' => $aFolderIdMap[$folder['parent_id']],
-                    'level'     => empty($folder['parent_id']) ? 0 : 1
-                ]);
-
-                \Folder\models\EntityFolderModel::create([
-                    'folder_id' => $folderId,
-                    'entity_id' => $entity['id'],
-                    'edition'   => true,
-                ]);
-
-                fillResources($folderId, $folder['folders_system_id']);
-            }
-
-            $aFolderIdMap[$folder['folders_system_id']] = $folderId;
-            ++$migrated;
-        }
-    }
-
-    printf("Migration Dossier (CUSTOM {$custom}) : " . $migrated . " Dossier(s) trouvé(s) et migré(s).\n");
-}
-
-function fillEntities($folderId)
-{
-    \Folder\models\EntityFolderModel::create([
-        'folder_id' => $folderId,
-        'entity_id' => null,
-        'edition'   => true,
-        'keyword'   => 'ALL_ENTITIES'
-    ]);
-}
-
-function fillResources($folderId, $folderSystemId)
-{
-    $resources = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['res_id'],
-        'table'     => ['res_letterbox'],
-        'where'     => ['folders_system_id = ?'],
-        'data'      => [$folderSystemId]
-    ]);
-
-    foreach ($resources as $resource) {
-        \Folder\models\ResourceFolderModel::create([
-            'folder_id' => $folderId,
-            'res_id'    => $resource['res_id']
-        ]);
-    }
-}
diff --git a/migration/20.03/migrateFullText.php b/migration/20.03/migrateFullText.php
deleted file mode 100644
index 39a9192bfc58bfd7d8db5f5f28469f1e11d3e7ba..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateFullText.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/config.xml";
-    $xmlfile = simplexml_load_file($path);
-
-    if ($xmlfile) {
-
-        $i = 0;
-        foreach ($xmlfile->COLLECTION as $collection) {
-            if ((string)$collection->table == 'res_letterbox') {
-                $collId = 'letterbox_coll';
-            } elseif ((string)$collection->table == 'res_attachments') {
-                $collId = 'attachments_coll';
-            } else {
-                unset($xmlfile->COLLECTION[$i]);
-                continue;
-            }
-
-            \Docserver\models\DocserverModel::update([
-                'set'   => [
-                    'path_template' => (string)$collection->path_to_lucene_index
-                ],
-                'where' => ['docserver_type_id = ?', 'coll_id = ?'],
-                'data'  => ['FULLTEXT', $collId]
-            ]);
-            unset($xmlfile->COLLECTION[$i]->path_to_lucene_index);
-
-            ++$i;
-        }
-
-        $i = 0;
-        foreach ($xmlfile->MODULES as $module) {
-            if ((string)$module->moduleid == 'full_text') {
-                unset($xmlfile->MODULES[$i]);
-                break;
-            }
-            ++$i;
-        }
-
-        $res = $xmlfile->asXML();
-        $fp = fopen($path, "w+");
-        if ($fp) {
-            fwrite($fp, $res);
-        }
-
-        $migrated++;
-    }
-}
-
-printf("Migration Full Text : " . $migrated . " custom(s) avec un fichier config.xml trouvé(s) et migré(s).\n");
diff --git a/migration/20.03/migrateIndexing.php b/migration/20.03/migrateIndexing.php
deleted file mode 100644
index b7b862ad148496c88d7fe4fd3dc081359a89f7e7..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateIndexing.php
+++ /dev/null
@@ -1,238 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $groupBasket = \Basket\models\GroupBasketModel::get(['select' => ['group_id'], 'where' => ['basket_id = ?'], 'data' => ['IndexingBasket']]);
-
-    $migrated = 0;
-    foreach ($groupBasket as $value) {
-        $hasService = \SrcCore\models\DatabaseModel::select([
-            'select'    => [1],
-            'table'     => ['usergroups_services'],
-            'where'     => ['group_id = ?', 'service_id = ?'],
-            'data'      => [$value['group_id'], 'index_mlb']
-        ]);
-
-        if (!empty($hasService)) {
-            $actions = [];
-            $entities = [];
-            $keywords = [];
-            \Group\models\GroupModel::update([
-                'set'   => ['can_index' => 'true'],
-                'where' => ['group_id = ?'],
-                'data'  => [$value['group_id']]
-            ]);
-
-            // ACTIONS WITHOUT DIRECT STATUS
-            $actionsWithStatusesToCreate = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['status_id', 'action_id'],
-                'table'     => ['groupbasket_status'],
-                'where'     => ['group_id = ?', 'basket_id = ?'],
-                'data'      => [$value['group_id'], 'IndexingBasket'],
-                'order_by'  => ['"order"']
-            ]);
-
-            foreach ($actionsWithStatusesToCreate as $item) {
-                $existingActions = \SrcCore\models\DatabaseModel::select([
-                    'select'    => ['id'],
-                    'table'     => ['actions'],
-                    'where'     => ['id_status = ?', '(action_page = ? OR component = ?)'],
-                    'data'      => [$item['status_id'], 'confirm_status', 'confirmAction']
-                ]);
-
-                if (!empty($existingActions[0])) {
-                    $actions[] = (string)$existingActions[0]['id'];
-                } else {
-                    $statusLabel = \Status\models\StatusModel::getById(['id' => $item['status_id'], 'select' => ['label_status']]);
-
-                    $id = \Action\models\ActionModel::create([
-                        'label_action'  => "Enregistrer vers le status : {$statusLabel['label_status']}" ,
-                        'id_status'     => $item['status_id'],
-                        'history'       => 'Y',
-                        'component'     => 'confirmAction'
-                    ]);
-                    \Action\models\ActionModel::createCategories(['id' => $id, 'categories' => ['incoming', 'outgoing', 'internal', 'ged_doc']]);
-
-                    $actions[] = (string)$id;
-                }
-            }
-
-            // ACTIONS WITH STATUS
-            $actionsToMigrate = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['id_action'],
-                'table'     => ['actions_groupbaskets, actions'],
-                'where'     => ['group_id = ?', 'basket_id = ?', 'id_action = id', '(action_page = ? OR action_page = ? OR component = ? OR action_page = ?)'],
-                'data'      => [$value['group_id'], 'IndexingBasket', 'index_mlb', 'confirm_status', 'confirmAction', "''"]
-            ]);
-
-            foreach ($actionsToMigrate as $item) {
-                if (!in_array($item['id_action'], $actions)) {
-                    $actions[] = (string)$item['id_action'];
-                }
-            }
-
-            // KEYWORDS + ENTITIES
-            $keywordsAndEntities = \SrcCore\models\DatabaseModel::select([
-                'select'    => ['entity_id', 'keyword'],
-                'table'     => ['groupbasket_redirect'],
-                'where'     => ['group_id = ?', 'basket_id = ?', 'redirect_mode = ?'],
-                'data'      => [$value['group_id'], 'IndexingBasket', 'ENTITY']
-            ]);
-            foreach ($keywordsAndEntities as $item) {
-                if (!empty($item['keyword']) && !in_array($item['keyword'], $keywords)) {
-                    $keywords[] = $item['keyword'];
-                } elseif (!empty($item['entity_id'])) {
-                    $entityToMigrate = \Entity\models\EntityModel::getByEntityId(['entityId' => $item['entity_id'], 'select' => ['id']]);
-                    if (!in_array($entityToMigrate['id'], $entities)) {
-                        $entities[] = (string)$entityToMigrate['id'];
-                    }
-                }
-            }
-
-            // UPDATE INDEXING PARAMS
-            \Group\models\GroupModel::update([
-                'set'   => ['indexation_parameters' => json_encode(['actions' => $actions, 'entities' => $entities, 'keywords' => $keywords])],
-                'where' => ['group_id = ?'],
-                'data'  => [$value['group_id']]
-            ]);
-
-            $migrated++;
-        }
-    }
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'groupbasket',
-        'where' => ['basket_id = ?'],
-        'data'  => ['IndexingBasket']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'actions_groupbaskets',
-        'where' => ['basket_id = ?'],
-        'data'  => ['IndexingBasket']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'groupbasket_redirect',
-        'where' => ['basket_id = ?'],
-        'data'  => ['IndexingBasket']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'groupbasket_status',
-        'where' => ['basket_id = ?'],
-        'data'  => ['IndexingBasket']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'users_baskets_preferences',
-        'where' => ['basket_id = ?'],
-        'data'  => ['IndexingBasket']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'baskets',
-        'where' => ['basket_id = ?'],
-        'data'  => ['IndexingBasket']
-    ]);
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'usergroups_services',
-        'where' => ['service_id = ?'],
-        'data'  => ['index_mlb']
-    ]);
-
-    printf("Migration Indexing Basket (CUSTOM {$custom}) : " . $migrated . " groupe(s) avec le service et la bannette IndexingBasket trouvé(s) et migré(s).\n");
-
-
-    //MIGRATION ACTIONS AVEC STATUS
-    $basketsWithStatuses = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['group_id', 'basket_id', 'status_id', 'action_id'],
-        'table'     => ['groupbasket_status']
-    ]);
-
-    $migrated = 0;
-    $actionsToDelete = [];
-    foreach ($basketsWithStatuses as $value) {
-        if (!in_array($value['action_id'], $actionsToDelete) && !in_array($value['action_id'], $actions)) {
-            $actionsToDelete[] = $value['action_id'];
-        }
-
-        $existingActions = \SrcCore\models\DatabaseModel::select([
-            'select'    => ['id'],
-            'table'     => ['actions'],
-            'where'     => ['id_status = ?', '(action_page = ? OR component = ?)'],
-            'data'      => [$value['status_id'], 'confirm_status', 'confirmAction']
-        ]);
-
-        if (!empty($existingActions[0])) {
-            $id = (string)$existingActions[0]['id'];
-        } else {
-            $statusLabel = \Status\models\StatusModel::getById(['id' => $value['status_id'], 'select' => ['label_status']]);
-
-            $id = \Action\models\ActionModel::create([
-                'label_action'  => "Enregistrer vers le status : {$statusLabel['label_status']}" ,
-                'id_status'     => $value['status_id'],
-                'history'       => 'Y',
-                'component'     => 'confirmAction'
-            ]);
-            \Action\models\ActionModel::createCategories(['id' => $id, 'categories' => ['incoming', 'outgoing', 'internal', 'ged_doc']]);
-        }
-        $actionAlreadyExists = \Basket\models\ActionGroupBasketModel::get([
-            'select'            => [1],
-            'where'             => ['group_id = ?', 'basket_id = ?', 'id_action = ?'],
-            'data'          => [$value['group_id'], $value['basket_id'], $id]
-        ]);
-        if (empty($actionAlreadyExists)) {
-            \Basket\models\ActionGroupBasketModel::create([
-                'id'                => $value['basket_id'],
-                'groupId'           => $value['group_id'],
-                'actionId'          => $id,
-                'whereClause'       => '',
-                'usedInBasketlist'  => 'N',
-                'usedInActionPage'  => 'Y',
-                'defaultActionList' => 'N'
-            ]);
-        }
-
-        $migrated++;
-    }
-
-    if (!empty($actionsToDelete)) {
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'actions',
-            'where' => ['id in (?)'],
-            'data'  => [$actionsToDelete]
-        ]);
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'actions_groupbaskets',
-            'where' => ['id_action in (?)'],
-            'data'  => [$actionsToDelete]
-        ]);
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'actions_categories',
-            'where' => ['action_id in (?)'],
-            'data'  => [$actionsToDelete]
-        ]);
-    }
-
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['keyword' => ''],
-        'table' => 'actions',
-        'where' => ['keyword = ?'],
-        'data'  => ['indexing']
-    ]);
-
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['action_page' => '', 'component' => 'confirmAction'],
-        'table' => 'actions',
-        'where' => ['action_page = ?'],
-        'data'  => ['index_mlb']
-    ]);
-
-    printf("Migration Indexing Basket (CUSTOM {$custom}) : " . $migrated . " action(s) avec des status (mot clé indexation) trouvé(s) et migré(s).\n");
-}
diff --git a/migration/20.03/migrateLinkedResources.php b/migration/20.03/migrateLinkedResources.php
deleted file mode 100644
index b7cb0d4206b3ada0ad2650e71cfcf8dda96950cb..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateLinkedResources.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-use Resource\models\ResModel;
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs = scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = 0;
-
-    $links = \SrcCore\models\DatabaseModel::select([
-        'select' => ['res_parent', 'res_child'],
-        'table'  => ['res_linked']
-    ]);
-
-    foreach ($links as $link) {
-        $resParent = (string)$link['res_parent'];
-        $resChild = (string)$link['res_child'];
-
-        ResModel::update([
-            'postSet' => ['linked_resources' => "jsonb_insert(linked_resources, '{0}', '\"{$resChild}\"')"],
-            'where'   => ['res_id = ?', "(linked_resources @> ?) = false"],
-            'data'    => [(int)$resParent, "\"{$resChild}\""]
-        ]);
-        ResModel::update([
-            'postSet' => ['linked_resources' => "jsonb_insert(linked_resources, '{0}', '\"{$resParent}\"')"],
-            'where'   => ['res_id = ?', "(linked_resources @> ?) = false"],
-            'data'    => [(int)$resChild, "\"{$resParent}\""]
-        ]);
-        $migrated++;
-    }
-
-    printf("Migration des liaisons dans res_letterbox (CUSTOM {$custom}) : " . $migrated . " liaisons migrés.\n");
-}
diff --git a/migration/20.03/migrateListTemplates.php b/migration/20.03/migrateListTemplates.php
deleted file mode 100644
index b222917eb2306843f59136664168fc13d95850c3..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateListTemplates.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $migrated = 0;
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $listModels = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['*'],
-        'table'     => ['listmodels'],
-        'order_by'  => ['sequence', 'id']
-    ]);
-
-    $formattedListModels = [];
-    foreach ($listModels as $listModel) {
-        $formattedId = $listModel['object_id'].$listModel['object_type'];
-        if (empty($formattedListModels[$formattedId])) {
-            $formattedListModels[$formattedId] = [
-                'object_id'     => $listModel['object_id'],
-                'object_type'   => $listModel['object_type'],
-                'title'         => $listModel['title'],
-                'description'   => $listModel['description'],
-                'items'         => [$listModel]
-            ];
-        } else {
-            $formattedListModels[$formattedId]['items'][] = $listModel;
-        }
-    }
-
-    foreach ($formattedListModels as $value) {
-        $entityId = null;
-        if (strpos($value['object_id'], 'VISA_CIRCUIT_') === false && strpos($value['object_id'], 'AVIS_CIRCUIT_') === false) {
-            $entity = \Entity\models\EntityModel::getByEntityId(['entityId' => $value['object_id'], 'select' => ['id']]);
-            $entityId = $entity['id'];
-        }
-
-        $type = $value['object_type'] == 'entity_id' ? 'diffusionList' : ($value['object_type'] == 'VISA_CIRCUIT' ? 'visaCircuit' : 'opinionCircuit');
-        if (!empty($value['title'])) {
-            $title = $value['title'];
-        } elseif (!empty($value['description'])) {
-            $title = $value['description'];
-        } else {
-            $title = $value['object_id'];
-        }
-
-        $listTemplateId = \Entity\models\ListTemplateModel::create([
-            'title'         => $title,
-            'description'   => $value['description'],
-            'type'          => $type,
-            'entity_id'     => $entityId
-        ]);
-
-        foreach ($value['items'] as $key => $item) {
-            if (empty($item['item_id'])) {
-                continue;
-            }
-            if ($item['item_type'] == 'user_id') {
-                $itemId = \User\models\UserModel::getByLogin(['login' => $item['item_id'], 'select' => ['id']]);
-            } else {
-                $itemId = \Entity\models\EntityModel::getByEntityId(['entityId' => $item['item_id'], 'select' => ['id']]);
-            }
-            if (empty($itemId['id'])) {
-                continue;
-            }
-
-            \Entity\models\ListTemplateItemModel::create([
-                'list_template_id'  => $listTemplateId,
-                'item_id'           => $itemId['id'],
-                'item_type'         => $item['item_type'] == 'user_id' ? 'user' : 'entity',
-                'item_mode'         => $item['item_mode'],
-                'sequence'          => $key
-            ]);
-        }
-
-        ++$migrated;
-    }
-
-    printf("Migration List templates (CUSTOM {$custom}) : " . $migrated . " modèles de listes trouvé(s) et migré(s).\n");
-}
diff --git a/migration/20.03/migrateM2MConfiguration.php b/migration/20.03/migrateM2MConfiguration.php
deleted file mode 100644
index 1967cb6cff42a997d9d3251b3cf3ddae0c3d9fd0..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateM2MConfiguration.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/m2m_config.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-
-        if ($xmlfile) {
-            $xmlfile->res_letterbox->indexingModelId = 1;
-            unset($xmlfile->contacts_v2);
-            unset($xmlfile->contact_addresses);
-
-            $res = $xmlfile->asXML();
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-
-            $migrated++;
-        }
-    }
-}
-
-printf("Migration m2m configuration : " . $migrated . " custom(s) avec un fichier m2m_config.xml trouvé(s) et migré(s).\n");
diff --git a/migration/20.03/migrateMenuEntities.php b/migration/20.03/migrateMenuEntities.php
deleted file mode 100644
index 0576d0df00aea737efccca98d8fd335e6bc22817..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateMenuEntities.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$migrated = 0;
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $natures = [];
-    $path = "custom/{$custom}/modules/entities/xml/menu.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        
-        if ($loadedXml) {
-            $i = 0;
-            foreach ($loadedXml->MENU as $value) {
-                if ($value->id == 'entities_print_sep_mlb') {
-                    $loadedXml->MENU[$i]->url = '/separators/print';
-                    $loadedXml->MENU[$i]->angular = 'true';
-                    break;
-                }
-                ++$i;
-            }
-            $res = formatXml($loadedXml);
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-                $migrated++;
-            }
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
-
-printf($migrated . " custom(s) avec menu.xml (entities) trouvé(s) et migré(s).\n");
-
-function formatXml($simpleXMLElement)
-{
-    $xmlDocument = new DOMDocument('1.0');
-    $xmlDocument->preserveWhiteSpace = false;
-    $xmlDocument->formatOutput = true;
-    $xmlDocument->loadXML($simpleXMLElement->asXML());
-
-    return $xmlDocument->saveXML();
-}
diff --git a/migration/20.03/migrateOldIndexingModels.php b/migration/20.03/migrateOldIndexingModels.php
deleted file mode 100755
index 304b372debb4dd073b501178b92ba37d86751390..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateOldIndexingModels.php
+++ /dev/null
@@ -1,143 +0,0 @@
-<?php
-
-$aDataIncoming['incoming'] = [
-    'doctype'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'priority'              => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'confidentiality'          => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'docDate'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'arrivalDate'           => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'subject'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'indexingCustomField_1' => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'mail'],
-    'senders'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'contact'],
-    'recipients'            => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'contact'],
-    'initiator'             => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'destination'           => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'processLimitDate'      => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'folder'                => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'classement'],
-    'tags'                  => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'classement'],
-];
-
-$aDataIncoming['outgoing'] = [
-    'doctype'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'priority'              => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'confidentiality'          => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'docDate'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'subject'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'indexingCustomField_1' => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'mail'],
-    'senders'               => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'contact'],
-    'recipients'            => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'contact'],
-    'initiator'             => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'destination'           => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'processLimitDate'      => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'folder'                => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'classement'],
-    'tags'                  => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'classement'],
-];
-
-$aDataIncoming['internal'] = [
-    'doctype'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'priority'              => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'confidentiality'          => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'docDate'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'subject'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'indexingCustomField_1' => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'mail'],
-    'senders'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'contact'],
-    'recipients'            => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'contact'],
-    'initiator'             => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'destination'           => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'processLimitDate'      => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'folder'                => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'classement'],
-    'tags'                  => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'classement'],
-];
-
-$aDataIncoming['ged_doc'] = [
-    'doctype'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'confidentiality'          => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'docDate'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'subject'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'mail'],
-    'senders'               => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'contact'],
-    'recipients'         => ['mandatory' => 'false', 'default_value' => '""', 'unit' => 'contact'],
-    'initiator'             => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-    'destination'           => ['mandatory' => 'true', 'default_value' => '""', 'unit' => 'process'],
-];
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-
-    $oldIndexingModels = \SrcCore\models\DatabaseModel::select([
-        'select' => ['*'],
-        'table'  => ['indexingmodels']
-    ]);
-
-    $superadmin = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => 'superadmin']);
-    if (empty($superadmin)) {
-        $firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1]);
-        $masterOwnerId = $firstMan[0]['id'];
-    } else {
-        $masterOwnerId = $superadmin['id'];
-    }
-
-    $migrated = 0;
-    foreach ($oldIndexingModels as $oldIndexingModel) {
-        $fieldContent = json_decode($oldIndexingModel['fields_content'], true);
-        if (empty($fieldContent['category_id'])) {
-            continue;
-        }
-        $datasToImport = $aDataIncoming[$fieldContent['category_id']];
-
-        $modelId = \IndexingModel\models\IndexingModelModel::create([
-            'label'     => $oldIndexingModel['label'],
-            'category'  => $fieldContent['category_id'],
-            'default'   => 'false',
-            'owner'     => $masterOwnerId,
-            'private'   => 'false'
-        ]);
-
-        foreach ($fieldContent as $key => $field) {
-            if ($key == 'type_id') {
-                $doctype = \Doctype\models\DoctypeModel::get(['select' => [1], 'where' => ['type_id = ?', 'enabled = ?'], 'data' => [$field, 'Y']]);
-                if (!empty($doctype)) {
-                    $datasToImport['doctype']['default_value'] = json_encode($field);
-                }
-            } elseif ($key == 'priority') {
-                $priority = \Priority\models\PriorityModel::getById(['select' => [1], 'id' => $field]);
-                if (!empty($priority)) {
-                    $datasToImport['priority']['default_value'] = json_encode($field);
-                }
-            } elseif ($key == 'destination') {
-                $destination = \Entity\models\EntityModel::get(['select' => ['id'], 'where' => ['entity_id = ?', 'enabled = ?'], 'data' => [$field, 'Y']]);
-                if (!empty($destination)) {
-                    $datasToImport['destination']['default_value'] = json_encode($destination[0]['id']);
-                }
-            } elseif ($key == 'subject') {
-                $datasToImport['subject']['default_value'] = json_encode($field);
-            }
-        }
-        foreach ($datasToImport as $id => $defaultValue) {
-            \SrcCore\models\DatabaseModel::insert([
-                'table'         => 'indexing_models_fields',
-                'columnsValues' => [
-                    'model_id'      => $modelId,
-                    'identifier'    => $id,
-                    'mandatory'     => $defaultValue['mandatory'],
-                    'default_value' => $defaultValue['default_value'],
-                    'unit'          => $defaultValue['unit']
-                ]
-            ]);
-        }
-        ++$migrated;
-    }
-
-    printf("Migration anciens modèles d'indexation (CUSTOM {$custom}) : " . $migrated . " modèle(s) utilisé(s) et migré(s).\n");
-}
diff --git a/migration/20.03/migrateOutgoingAttachments.php b/migration/20.03/migrateOutgoingAttachments.php
deleted file mode 100644
index 308e8112f84cf127e999822522dd2f7e0229bd07..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateOutgoingAttachments.php
+++ /dev/null
@@ -1,335 +0,0 @@
-<?php
-
-use Convert\models\AdrModel;
-use Docserver\controllers\DocserverController;
-use Docserver\models\DocserverModel;
-use Resource\models\ResModel;
-use SrcCore\models\CoreConfigModel;
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = 0;
-    $attachmentsInfo = \SrcCore\models\DatabaseModel::select([
-        'select' => ['l.category_id', 'a.res_id', 'a.relation', 'a.docserver_id', 'a.path', 'a.filename', 'a.filesize', 'a.format', 'a.res_id_master', 'a.in_signature_book',
-                        'a.in_send_attach', 'a.external_id->>\'signatureBookId\' as signaturebookid', 'a.origin_id', 'a.fingerprint'],
-        'table'  => ['res_attachments a, res_letterbox l'],
-        'where'  => ['attachment_type = ?', 'a.status not in (?)', 'a.res_id_master = l.res_id', 'category_id = ?'],
-        'data'   => ['outgoing_mail', ['DEL', 'TMP', 'OBS'], 'outgoing'],
-        'orderBy' => ['a.res_id desc']
-    ]);
-
-    $superadmin = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => 'superadmin']);
-    if (empty($superadmin)) {
-        $firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1]);
-        $masterOwnerId = $firstMan[0]['id'];
-    } else {
-        $masterOwnerId = $superadmin['id'];
-    }
-
-    $tmpPath = CoreConfigModel::getTmpPath();
-
-
-    $resIdsMaster = array_column($attachmentsInfo, 'res_id_master', 'res_id');
-
-    $resIdsUniqueMaster = array_column($attachmentsInfo, 'res_id_master', 'res_id');
-    $resIdsUniqueMaster = array_unique($resIdsUniqueMaster);
-    $resIdsUniqueMaster = array_keys($resIdsUniqueMaster);
-
-    if (!empty($resIdsMaster)) {
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'adr_letterbox',
-            'where' => ['res_id in (?)'],
-            'data'  => [$resIdsMaster]
-        ]);
-
-        $convertedDocuments = \SrcCore\models\DatabaseModel::select([
-            'select'    => ['docserver_id','path', 'filename', 'fingerprint', 'res_id'],
-            'table'     => ['adr_attachments'],
-            'where'     => ['res_id in (?)', 'type = ?'],
-            'data'      => [$resIdsUniqueMaster, 'PDF'],
-        ]);
-        $convertedDocuments = array_column($convertedDocuments, null, 'res_id');
-
-        $outgoingMailsSigned = \SrcCore\models\DatabaseModel::select([
-            'select'  => ['res_id', 'relation', 'docserver_id', 'path', 'filename', 'format', 'res_id_master'],
-            'table'   => ['res_attachments'],
-            'where'   => ['attachment_type = ?', 'res_id_master in (?)', 'status not in (?)'],
-            'data'    => ['outgoing_mail_signed', $resIdsMaster, ['DEL']],
-            'orderBy' => ['res_id desc']
-        ]);
-        $outgoingMailsSigned = array_column($outgoingMailsSigned, null, 'res_id');
-
-        $signedResponses = \SrcCore\models\DatabaseModel::select([
-            'select'  => ['res_id', 'relation', 'docserver_id', 'path', 'filename', 'format', 'res_id_master'],
-            'table'   => ['res_attachments'],
-            'where'   => ['attachment_type = ?', 'origin = ?', 'status not in (?)'],
-            'data'    => ['signed_response', $resIdsMaster.',res_attachments', ['DEL']],
-            'orderBy' => ['res_id desc']
-        ]);
-        $signedResponses = array_column($signedResponses, null, 'res_id');
-    }
-
-    $previousResId = 0;
-    $attachmentToDelete = [];
-    foreach ($attachmentsInfo as $attachmentInfo) {
-        if ($previousResId == $attachmentInfo['res_id_master']) {
-            continue;
-        }
-        $previousResId = $attachmentInfo['res_id_master'];
-
-        $integration = [];
-        $integration['inSignatureBook'] = empty($attachmentInfo['in_signature_book']) ?  'false' : 'true';
-        $integration['inShipping']      = empty($attachmentInfo['in_send_attach']) ?  'false' : 'true';
-
-        if (empty($attachmentInfo['signaturebookid'])) {
-            $attachmentInfo['signaturebookid'] = 'null';
-        }
-
-        ResModel::update([
-            'set' => [
-                'docserver_id' => $attachmentInfo['docserver_id'],
-                'path'         => $attachmentInfo['path'],
-                'filename'     => $attachmentInfo['filename'],
-                'fingerprint'  => $attachmentInfo['fingerprint'],
-                'filesize'     => $attachmentInfo['filesize'],
-                'version'      => $attachmentInfo['relation'],
-                'integrations' => json_encode($integration)
-            ],
-            'postSet' => ['external_id' => "jsonb_set(external_id, '{signatureBookId}', to_jsonb('{$attachmentInfo['signaturebookid']}'::text))"],
-            'where' => ['res_id = ?'],
-            'data'  => [$attachmentInfo['res_id_master']]
-        ]);
-
-        if (!empty($convertedDocuments[$attachmentInfo['res_id']])) {
-            $convertedDocument = $convertedDocuments[$attachmentInfo['res_id']];
-
-            AdrModel::createDocumentAdr([
-                'resId'         => $attachmentInfo['res_id_master'],
-                'type'          => 'PDF',
-                'docserverId'   => $convertedDocument['docserver_id'],
-                'path'          => $convertedDocument['path'],
-                'filename'      => $convertedDocument['filename'],
-                'version'       => $attachmentInfo['relation'],
-                'fingerprint'   => $convertedDocument['fingerprint']
-            ]);
-        }
-    
-        $attachmentToDelete[] = $attachmentInfo['res_id'];
-        $customId = empty($custom) ? 'null' : $custom;
-        exec("php src/app/convert/scripts/FullTextScript.php --customId {$customId} --resId {$attachmentInfo['res_id_master']} --collId letterbox_coll --userId {$masterOwnerId} > /dev/null &");
-    
-        if ($attachmentInfo['relation'] > 1) {
-            $attachmentsVersion = \SrcCore\models\DatabaseModel::select([
-                'select'  => ['res_id', 'relation', 'docserver_id', 'path', 'filename', 'fingerprint', 'format', 'res_id_master'],
-                'table'   => ['res_attachments'],
-                'where'   => ['(origin_id = ? or res_id = ?)', 'relation < ?'],
-                'data'    => [$attachmentInfo['origin_id'], $attachmentInfo['origin_id'], $attachmentInfo['relation']],
-                'orderBy' => ['relation asc']
-            ]);
-
-            foreach ($attachmentsVersion as $attachmentVersion) {
-                $docserver      = DocserverModel::getByDocserverId(['docserverId' => $attachmentVersion['docserver_id'], 'select' => ['path_template']]);
-                $pathToDocument = $docserver['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $attachmentVersion['path']) . $attachmentVersion['filename'];
-
-                if (file_exists($pathToDocument)) {
-                    $resource = file_get_contents($pathToDocument);
-                    $pathInfo = pathinfo($pathToDocument);
-                    $storeResult = DocserverController::storeResourceOnDocServer([
-                        'collId'            => 'letterbox_coll',
-                        'docserverTypeId'   => 'DOC',
-                        'encodedResource'   => base64_encode($resource),
-                        'format'            => $pathInfo['extension']
-                    ]);
-                    \SrcCore\models\DatabaseModel::insert([
-                        'table'         => 'adr_letterbox',
-                        'columnsValues' => [
-                            'res_id'       => $attachmentVersion['res_id_master'],
-                            'type'         => 'DOC',
-                            'docserver_id' => $storeResult['docserver_id'],
-                            'path'         => $storeResult['destination_dir'],
-                            'filename'     => $storeResult['file_destination_name'],
-                            'version'      => $attachmentVersion['relation'],
-                            'fingerprint'  => empty($storeResult['fingerPrint']) ? null : $storeResult['fingerPrint']
-                        ]
-                    ]);
-                } else {
-                    echo "Le document suivant n'est pas migré car il n'existe pas :" . $pathToDocument . "\n";
-                }
-                $attachmentToDelete[] = $attachmentVersion['res_id'];
-            }
-        }
-
-        if (!empty($outgoingMailsSigned[$attachmentInfo['res_id']])) {
-            $outgoingMailSigned = $outgoingMailsSigned[$attachmentInfo['res_id']];
-            // Version signée outgoing_mail_signed
-            $outgoingMailSigned['adrType'] = 'SIGN';
-            $outgoingMailSigned['relation'] = $attachmentInfo['relation'];
-            addOutgoingMailSignedInAdr($outgoingMailSigned);
-            $attachmentToDelete[] = $outgoingMailSigned['res_id'];
-        } else {
-            if (!empty($signedResponses[$attachmentInfo['res_id']])) {
-                $signedResponse = $signedResponses[$attachmentInfo['res_id']];
-                // Réponse signée signed_response
-                $signedResponse['adrType'] = 'SIGN';
-                $signedResponse['relation'] = $attachmentInfo['relation'];
-                addOutgoingMailSignedInAdr($signedResponse);
-                $attachmentToDelete[] = $signedResponse['res_id'];
-            }
-        }
-            
-        migrateHistoryVersion(['oldResId' => $attachmentInfo['res_id'], 'newResId' => $attachmentInfo['res_id_master']]);
-        migrateEmailsVersion(['oldResId' => $attachmentInfo['res_id'], 'newResId' => $attachmentInfo['res_id_master']]);
-        migrateMessageExchangeVersion(['oldResId' => $attachmentInfo['res_id'], 'newResId' => $attachmentInfo['res_id_master']]);
-        migrateShippingVersion(['oldResId' => $attachmentInfo['res_id'], 'newResId' => $attachmentInfo['res_id_master']]);
-
-        $migrated++;
-    }
-
-    // Version annotée
-    $outgoigAnnotated = \SrcCore\models\DatabaseModel::select([
-        'select'  => ['l.version', 'a.res_id', 'a.docserver_id', 'a.path', 'a.filename', 'a.format', 'a.res_id_master'],
-        'table'   => ['res_attachments a, res_letterbox l'],
-        'where'   => ['a.attachment_type = ?', 'a.status in (?)', 'category_id = ?', 'a.res_id_master = l.res_id'],
-        'data'    => ['document_with_notes', ['A_TRA', 'TRA'], 'incoming'],
-        'orderBy' => ['res_id desc']
-    ]);
-
-    $documentWithNote = 0;
-    $previousResId    = 0;
-    foreach ($outgoigAnnotated as $document) {
-        if ($previousResId == $document['res_id_master']) {
-            continue;
-        }
-        $previousResId = $document['res_id_master'];
-        $document['adrType']  = 'NOTE';
-        $document['relation'] = $document['version'];
-        addOutgoingMailSignedInAdr($document);
-        $attachmentToDelete[] = $document['res_id'];
-        migrateHistoryVersion(['oldResId' => $document['res_id'], 'newResId' => $document['res_id_master']]);
-        migrateEmailsVersion(['oldResId' => $document['res_id'], 'newResId' => $document['res_id_master']]);
-        migrateMessageExchangeVersion(['oldResId' => $document['res_id'], 'newResId' => $document['res_id_master']]);
-        migrateShippingVersion(['oldResId' => $document['res_id'], 'newResId' => $document['res_id_master']]);
-        $documentWithNote++;
-    }
-
-    if (!empty($attachmentToDelete)) {
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'res_attachments',
-            'where' => ['res_id in (?)'],
-            'data'  => [$attachmentToDelete]
-        ]);
-
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'adr_attachments',
-            'where' => ['res_id in (?)'],
-            'data'  => [$attachmentToDelete]
-        ]);
-    }
-
-    printf("Migration outgoing_mail, outgoing_mail_signed (CUSTOM {$custom}) : " . $migrated . " courier(s) départ(s) trouvé(s) et migré(s). ".$documentWithNote." courrier(s) annoté(s)\n");
-}
-
-function addOutgoingMailSignedInAdr($args = [])
-{
-    $convertedDocument = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['docserver_id','path', 'filename', 'fingerprint'],
-        'table'     => ['adr_attachments'],
-        'where'     => ['res_id = ?', 'type = ?'],
-        'data'      => [$args['res_id'], 'PDF'],
-    ]);
-
-    if (!empty($convertedDocument)) {
-        \SrcCore\models\DatabaseModel::delete([
-            'table' => 'adr_letterbox',
-            'where' => ['res_id = ?', 'type = ?', 'version = ?'],
-            'data'  => [$args['res_id_master'], $args['adrType'], $args['relation']]
-        ]);
-        AdrModel::createDocumentAdr([
-            'resId'       => $args['res_id_master'],
-            'type'        => $args['adrType'],
-            'docserverId' => $convertedDocument[0]['docserver_id'],
-            'path'        => $convertedDocument[0]['path'],
-            'filename'    => $convertedDocument[0]['filename'],
-            'version'     => $args['relation'],
-            'fingerprint' => $convertedDocument[0]['fingerprint']
-        ]);
-    
-        if ($args['adrType'] == 'SIGN') {
-            \SrcCore\models\DatabaseModel::delete([
-                'table' => 'adr_letterbox',
-                'where' => ['res_id = ?', 'type = ?', 'version = ?'],
-                'data'  => [$args['res_id_master'], 'TNL', $args['relation']]
-            ]);
-        }
-    }
-}
-
-function migrateHistoryVersion($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'postSet' => ['info' => "REPLACE(info, '{$args['oldResId']} (res_attachments)', '{$args['newResId']} (res_letterbox)')"],
-        'table'   => 'history',
-        'where'   => ['table_name = ?', 'record_id = ?'],
-        'data'    => ['res_attachments', $args['oldResId']]
-    ]);
-}
-
-function migrateEmailsVersion($args = [])
-{
-    $emails = \SrcCore\models\DatabaseModel::select([
-        'select' => ['id', 'document'],
-        'table' => ['emails'],
-        'where' => ['document->\'attachments\' @> ?'],
-        'data' => ['[{"id":'.$args['oldResId'].'}]']
-    ]);
-
-    foreach ($emails as $email) {
-        $document = json_decode($email['document'], true);
-        foreach ($document['attachments'] as $key => $attachment) {
-            if ($attachment['id'] == $args['oldResId']) {
-                $document['isLinked'] = true;
-                $document['original'] = $attachment['original'];
-                unset($document['attachments'][$key]);
-                break;
-            }
-        }
-        \SrcCore\models\DatabaseModel::update([
-            'set'   => ['document' => json_encode($document)],
-            'table' => 'emails',
-            'where' => ['id = ?'],
-            'data'  => [$email['id']]
-        ]);
-    }
-}
-
-function migrateMessageExchangeVersion($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['res_id' => $args['newResId'], 'tablename' => 'res_letterbox'],
-        'table' => 'unit_identifier',
-        'where' => ['res_id = ?', 'tablename = ?'],
-        'data'  => [$args['oldResId'], 'res_attachments']
-    ]);
-}
-
-function migrateShippingVersion($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['document_id' => $args['newResId'], 'document_type' => 'resource'],
-        'table' => 'shippings',
-        'where' => ['document_id = ?', 'document_type = ?'],
-        'data'  => [$args['oldResId'], 'attachment']
-    ]);
-}
diff --git a/migration/20.03/migrateOutgoingTemplate.php b/migration/20.03/migrateOutgoingTemplate.php
deleted file mode 100644
index f0cedefaceef00449a577cc73006349b6f1b0e46..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateOutgoingTemplate.php
+++ /dev/null
@@ -1,454 +0,0 @@
-<?php
-
-use Contact\models\ContactCustomFieldListModel;
-use CustomField\models\CustomFieldModel;
-use Docserver\controllers\DocserverController;
-use Docserver\models\DocserverModel;
-use SrcCore\models\DatabaseModel;
-use Template\models\TemplateModel;
-
-require '../../vendor/autoload.php';
-
-include_once('../../vendor/tinybutstrong/opentbs/tbs_plugin_opentbs.php');
-
-const OFFICE_EXTENSIONS = ['odt', 'ods', 'odp', 'xlsx', 'pptx', 'docx', 'odf'];
-
-$DATA_TO_REPLACE = [
-    'res_letterbox.destination'         => '[destination.entity_id]',
-    'res_letterbox.entity_label'        => '[destination.entity_label]',
-    'res_letterbox.process_notes'       => '[notes]',
-    'res_letterbox.contact_firstname'   => '[recipient.firstname]',
-    'res_letterbox.contact_lastname'    => '[recipient.lastname]',
-    'res_letterbox.contact_society'     => '[recipient.company]',
-
-    'res_letterbox.nature_id' => '[res_letterbox.customField_1]',
-
-    // Initiator
-    'res_letterbox.initiator_entity_id'           => '[initiator.entity_id]',
-    'res_letterbox.initiator_entity_label'        => '[initiator.entity_label]',
-    'res_letterbox.initiator_short_label'         => '[initiator.short_label]',
-    'res_letterbox.initiator_email'               => '[initiator.email]',
-    'res_letterbox.initiator_parent_entity_id'    => '[initiator.parent_entity_id]',
-    'res_letterbox.initiator_parent_entity_label' => '[initiator.parent_entity_label]',
-    'res_letterbox.initiator_entity_type'         => '[initiator.entity_type]',
-    'res_letterbox.initiator_entity_path'         => '[initiator.entity_path]',
-    'res_letterbox.initiator_entity_fullname'     => '[initiator.entity_fullname]',
-    'res_letterbox.initiator_zipcode'             => '[initiator.zipcode]',
-    'res_letterbox.initiator_city'                => '[initiator.city]',
-    'res_letterbox.initiator_country'             => '[initiator.country]',
-    'res_letterbox.initiator_ldap_id'             => '[initiator.ldap_id]',
-    'res_letterbox.initiator_archival_agence'     => '[initiator.archival_agence]',
-    'res_letterbox.initiator_archival_agreement'  => '[initiator.archival_agreement]',
-    'res_letterbox.initiator_business_id'         => '[initiator.business_id]',
-
-    'attachments.chrono' => '[res_letterbox.alt_identifier]',
-
-    'visa.firstnameSign' => '',
-    'visa.lastnameSign'  => '[visas]',
-    'visa.entitySign'    => '',
-    'visa.firstname1'    => '',
-    'visa.lastname1'     => '[visas]',
-    'visa.firstname2'    => '',
-    'visa.lastname2'     => '',
-    'visa.firstname3'    => '',
-    'visa.lastname3'     => '',
-    'visa.firstname4'    => '',
-    'visa.lastname4'     => '',
-    'visa.firstname5'    => '',
-    'visa.lastname5'     => '',
-    'visa.firstname6'    => '',
-    'visa.lastname6'     => '',
-    'visa.firstname7'    => '',
-    'visa.lastname7'     => '',
-    'visa.firstname8'    => '',
-    'visa.lastname8'     => '',
-    'visa.firstname9'    => '',
-    'visa.lastname9'     => '',
-    'visa.entity1'       => '',
-    'visa.entity2'       => '',
-    'visa.entity3'       => '',
-    'visa.entity4'       => '',
-    'visa.entity5'       => '',
-    'visa.entity6'       => '',
-    'visa.entity7'       => '',
-    'visa.entity8'       => '',
-    'visa.entity9'       => '',
-
-    'avis.firstname1' => '',
-    'avis.lastname1'  => '[opinions]',
-    'avis.firstname2' => '',
-    'avis.lastname2'  => '',
-    'avis.firstname3' => '',
-    'avis.lastname3'  => '',
-    'avis.firstname4' => '',
-    'avis.lastname4'  => '',
-    'avis.firstname5' => '',
-    'avis.lastname5'  => '',
-    'avis.firstname6' => '',
-    'avis.lastname6'  => '',
-    'avis.firstname7' => '',
-    'avis.lastname7'  => '',
-    'avis.firstname8' => '',
-    'avis.lastname8'  => '',
-    'avis.firstname9' => '',
-    'avis.lastname9'  => '',
-    'avis.role1'      => '',
-    'avis.entity1'    => '',
-    'avis.note1'      => '',
-    'avis.role2'      => '',
-    'avis.entity2'    => '',
-    'avis.note2'      => '',
-    'avis.role3'      => '',
-    'avis.entity3'    => '',
-    'avis.note3'      => '',
-    'avis.role4'      => '',
-    'avis.entity4'    => '',
-    'avis.note4'      => '',
-    'avis.role5'      => '',
-    'avis.entity5'    => '',
-    'avis.note5'      => '',
-    'avis.role6'      => '',
-    'avis.entity6'    => '',
-    'avis.note6'      => '',
-    'avis.role7'      => '',
-    'avis.entity7'    => '',
-    'avis.note7'      => '',
-    'avis.role8'      => '',
-    'avis.entity8'    => '',
-    'avis.note8'      => '',
-    'avis.role9'      => '',
-    'avis.entity9'    => '',
-    'avis.note9'      => '',
-
-    'copies.firstname1' => '',
-    'copies.lastname1'  => '[copies]',
-    'copies.firstname2' => '',
-    'copies.lastname2'  => '',
-    'copies.firstname3' => '',
-    'copies.lastname3'  => '',
-    'copies.firstname4' => '',
-    'copies.lastname4'  => '',
-    'copies.firstname5' => '',
-    'copies.lastname5'  => '',
-    'copies.firstname6' => '',
-    'copies.lastname6'  => '',
-    'copies.firstname7' => '',
-    'copies.lastname7'  => '',
-    'copies.firstname8' => '',
-    'copies.lastname8'  => '',
-    'copies.firstname9' => '',
-    'copies.lastname9'  => '',
-    'copies.entity1'    => '',
-    'copies.entity2'    => '',
-    'copies.entity3'    => '',
-    'copies.entity4'    => '',
-    'copies.entity5'    => '',
-    'copies.entity6'    => '',
-    'copies.entity7'    => '',
-    'copies.entity8'    => '',
-    'copies.entity9'    => '',
-
-    'user.role'             => '[userPrimaryEntity.role]',
-    'user.entity_id'        => '[userPrimaryEntity.entity_id]',
-    'user.entity_label'     => '[userPrimaryEntity.entity_label]',
-    'user.short_label'      => '[userPrimaryEntity.short_label]',
-    'user.adrs_1'           => '[userPrimaryEntity.adrs_1]',
-    'user.adrs_2'           => '[userPrimaryEntity.adrs_2]',
-    'user.adrs_3'           => '[userPrimaryEntity.adrs_3]',
-    'user.zipcode'          => '[userPrimaryEntity.zipcode]',
-    'user.city'             => '[userPrimaryEntity.city]',
-    'user.email'            => '[userPrimaryEntity.email]',
-    'user.parent_entity_id' => '[userPrimaryEntity.parent_entity_id]',
-    'user.entity_type'      => '[userPrimaryEntity.entity_type]',
-    'user.entity_path'      => '[userPrimaryEntity.path]',
-
-    'contact.contact_type_label'        => '',
-    'contact.society_short'             => '',
-    'contact.contact_purpose_label'     => '',
-    'contact.website'                   => '',
-    'contact.salutation_header'         => '',
-    'contact.salutation_footer'         => '',
-    'contact.society'                   => '[recipient.company]',
-    'contact.departement'               => '[recipient.department]',
-    'contact.title'                     => '[recipient.civility]',
-    'contact.contact_title'             => '[recipient.civility]',
-    'contact.contact_lastname'          => '[recipient.lastname]',
-    'contact.contact_firstname'         => '[recipient.firstname]',
-    'contact.lastname'                  => '[recipient.lastname]',
-    'contact.firstname'                 => '[recipient.firstname]',
-    'contact.function'                  => '[recipient.function]',
-    'contact.postal_address;strconv=no' => '[recipient.postal_address;strconv=no]',
-    'contact.postal_address'            => '[recipient.postal_address]',
-    'contact.address_num'               => '[recipient.address_number]',
-    'contact.address_street'            => '[recipient.address_street]',
-    'contact.occupancy'                 => '[recipient.address_additional1]',
-    'contact.address_complement'        => '[recipient.address_additional2]',
-    'contact.address_town'              => '[recipient.address_town]',
-    'contact.address_postal_code'       => '[recipient.address_postcode]',
-    'contact.address_country'           => '[recipient.address_country]',
-    'contact.phone'                     => '[recipient.phone]',
-    'contact.email'                     => '[recipient.email]',
-
-    'attachmentRecipient.company'                   => '[recipient.company]',
-    'attachmentRecipient.departement'               => '[recipient.department]',
-    'attachmentRecipient.civility'                  => '[recipient.civility]',
-    'attachmentRecipient.lastname'                  => '[recipient.lastname]',
-    'attachmentRecipient.firstname'                 => '[recipient.firstname]',
-    'attachmentRecipient.function'                  => '[recipient.function]',
-    'attachmentRecipient.postal_address;strconv=no' => '[recipient.postal_address;strconv=no]',
-    'attachmentRecipient.postal_address'            => '[recipient.postal_address]',
-    'attachmentRecipient.address_number'            => '[recipient.address_number]',
-    'attachmentRecipient.address_street'            => '[recipient.address_street]',
-    'attachmentRecipient.address_additional1'       => '[recipient.address_additional1]',
-    'attachmentRecipient.address_additional2'       => '[recipient.address_additional2]',
-    'attachmentRecipient.address_town'              => '[recipient.address_town]',
-    'attachmentRecipient.address_postcode'          => '[recipient.address_postcode]',
-    'attachmentRecipient.address_country'           => '[recipient.address_country]',
-    'attachmentRecipient.phone'                     => '[recipient.phone]',
-    'attachmentRecipient.email'                     => '[recipient.email]',
-
-    'notes.identifier'                       => '[res_letterbox.res_id]',
-    'notes.subject'                          => '[res_letterbox.subject]',
-    'notes.note_text'                        => '[notes]',
-    'notes.user_id'                          => '',
-    'notes.# ;frm=0000'                      => '[res_letterbox.# ;frm=0000]',
-    'notes.doc_date;block=tr;frm=dd/mm/yyyy' => '[res_letterbox.doc_date;block=tr;frm=dd/mm/yyyy]',
-    'notes.doc_date;block=tr'                => '[res_letterbox.doc_date;block=tr]',
-    'notes.doc_date;frm=dd/mm/yyyy'          => '[res_letterbox.doc_date;frm=dd/mm/yyyy]',
-    'notes.doc_date'                         => '[res_letterbox.doc_date]',
-    'notes.contact_society'                  => '[contact.company]',
-    'notes.contact_firstname'                => '[contact.firstname]',
-    'notes.contact_lastname'                 => '[contact.lastname]',
-    'notes.linktodetail'                     => '[res_letterbox.linktodetail]',
-    'notes.linktodoc'                        => '[res_letterbox.linktodoc]',
-];
-
-$contactCustomFields = [
-    ['oldId' => 'salutation_header', 'label' => 'Formule de politesse (Début)'],
-    ['oldId' => 'salutation_footer', 'label' => 'Formule de politesse (Fin)'],
-    ['oldId' => 'website', 'label' => 'Site internet'],
-    ['oldId' => 'contact_type_label', 'label' => 'Type de contact'],
-    ['oldId' => 'contact_purpose_label', 'label' => 'Dénomination'],
-    ['oldId' => 'society_short', 'label' => 'Sigle de la structure'],
-];
-
-$resourceCustomFields = [
-    ['id' => 'description', 'label' => 'Autres informations'],
-    ['id' => 'external_reference', 'label' => 'Référence courrier expéditeur'],
-    ['id' => 'reference_number', 'label' => 'N° recommandé'],
-    ['id' => 'scan_date', 'label' => 'Date de scan'],
-    ['id' => 'scan_user', 'label' => 'Utilisateur de scan'],
-    ['id' => 'scan_location', 'label' => 'Lieu de scan'],
-    ['id' => 'scan_wkstation', 'label' => 'Station de scan'],
-    ['id' => 'scan_batch', 'label' => 'Batch de scan'],
-    ['id' => 'scan_postmark', 'label' => 'Tampon de scan'],
-];
-
-chdir('../..');
-
-$customs = scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $docserver     = DocserverModel::getByDocserverId(['docserverId' => 'TEMPLATES']);
-    $templatesPath = $docserver['path_template'];
-
-    // BEGIN Change attachment all in outgoingMail
-
-    $templatesAllAttachmentTypes = TemplateModel::get([
-        'where' => ['template_target = ?', 'template_attachment_type in (?)'],
-        'data'  => ['attachments', ['all', 'outgoing_mail']]
-    ]);
-
-    $migrated      = 0;
-    $nonMigrated   = 0;
-
-    foreach ($templatesAllAttachmentTypes as $template) {
-        $path = str_replace('#', '/', $template['template_path']);
-
-        $pathToDocument = $templatesPath . $path . $template['template_file_name'];
-
-        $pathInfo = pathinfo($pathToDocument);
-        $extension = $pathInfo['extension'];
-
-        if (!in_array($extension, OFFICE_EXTENSIONS)) {
-            $nonMigrated++;
-            continue;
-        }
-
-        if (!is_writable($pathToDocument) || !is_readable($pathToDocument)) {
-            $nonMigrated++;
-            continue;
-        }
-
-        $encodedFile = base64_encode(file_get_contents($pathToDocument));
-
-        $storeResult = DocserverController::storeResourceOnDocServer([
-            'collId'            => 'templates',
-            'docserverTypeId'   => 'TEMPLATES',
-            'encodedResource'   => $encodedFile,
-            'format'            => $pathInfo['extension']
-        ]);
-
-        $template['template_path']      = $storeResult['destination_dir'];
-        $template['template_file_name'] = $storeResult['file_destination_name'];
-
-        $nextSequenceId = DatabaseModel::getNextSequenceValue(['sequenceId' => 'templates_seq']);
-        DatabaseModel::insert([
-            'table'         => 'templates',
-            'columnsValues' => [
-                'template_id'               => $nextSequenceId,
-                'template_label'            => $template['template_label'] . ' (départ)',
-                'template_comment'          => $template['template_comment'],
-                'template_content'          => $template['template_content'],
-                'template_type'             => $template['template_type'],
-                'template_style'            => $template['template_style'],
-                'template_datasource'       => $template['template_datasource'],
-                'template_target'           => 'indexingFile',
-                'template_attachment_type'  => 'all',
-                'template_path'             => $template['template_path'],
-                'template_file_name'        => $template['template_file_name'],
-            ]
-        ]);
-        $templateAssociations = DatabaseModel::select([
-            'select'    => ['value_field'],
-            'table'     => ['templates_association'],
-            'where'     => ['template_id = ?'],
-            'data'      => [$template['template_id']]
-        ]);
-
-        $aValues = [];
-        foreach ($templateAssociations as $templateAssociation) {
-            $aValues[] = [$nextSequenceId, $templateAssociation['value_field']];
-        }
-        if (!empty($aValues)) {
-            DatabaseModel::insertMultiple([
-                'table'     => 'templates_association',
-                'columns'   => ['template_id', 'value_field'],
-                'values'    => $aValues
-            ]);
-        }
-    }
-
-    // END
-
-    foreach ($contactCustomFields as $customField) {
-        $idNewCustomField = ContactCustomFieldListModel::get([
-            'select' => ['id'],
-            'where'  => ['label = ?'],
-            'data'   => [$customField['label']]
-        ]);
-        $DATA_TO_REPLACE["contact." . $customField['oldId']] = "[recipient.customField_{$idNewCustomField[0]['id']}]";
-    }
-
-    foreach ($resourceCustomFields as $customField) {
-        $idNewCustomField = CustomFieldModel::get([
-            'select' => ['id'],
-            'where'  => ['label = ?'],
-            'data'   => [$customField['label']]
-        ]);
-        $DATA_TO_REPLACE["res_letterbox." . $customField['id']] = "[res_letterbox.customField_{$idNewCustomField[0]['id']}]";
-    }
-
-    $templates     = TemplateModel::get([
-        'where' => ['template_target = ?', 'template_attachment_type = ?'],
-        'data'  => ['indexingFile', 'all']
-    ]);
-
-    foreach ($templates as $template) {
-        $path = str_replace('#', '/', $template['template_path']);
-
-        $pathToDocument = $templatesPath . $path . $template['template_file_name'];
-
-        $pathInfo = pathinfo($pathToDocument);
-        $extension = $pathInfo['extension'];
-
-        if (!in_array($extension, OFFICE_EXTENSIONS)) {
-            $nonMigrated++;
-            continue;
-        }
-
-        if (!is_writable($pathToDocument) || !is_readable($pathToDocument)) {
-            $nonMigrated++;
-            continue;
-        }
-
-        $tbs = new clsTinyButStrong();
-        $tbs->NoErr = true;
-        $tbs->Protect = false;
-        $tbs->PlugIn(TBS_INSTALL, OPENTBS_PLUGIN);
-
-        $tbs->LoadTemplate($pathToDocument, OPENTBS_ALREADY_UTF8);
-
-        $pages = 1;
-        if ($extension == 'xlsx') {
-            $pages = $tbs->PlugIn(OPENTBS_COUNT_SHEETS);
-        }
-
-        for ($i = 0; $i < $pages; ++$i) {
-            if ($extension == 'xlsx') {
-                $tbs->PlugIn(OPENTBS_SELECT_SHEET, $i + 1);
-            }
-
-            $tbs->ReplaceFields($DATA_TO_REPLACE);
-        }
-
-        if (in_array($extension, OFFICE_EXTENSIONS)) {
-            $tbs->Show(OPENTBS_STRING);
-        } else {
-            $tbs->Show(TBS_NOTHING);
-        }
-
-        $content = base64_encode($tbs->Source);
-
-        $result = file_put_contents($pathToDocument, base64_decode($content));
-        if ($result !== false) {
-            $migrated++;
-        } else {
-            echo "Erreur lors de la migration du modèle : $pathToDocument\n";
-            $nonMigrated++;
-        }
-    }
-
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/entreprise.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            printf("The file $path it is not readable or not writable.\n");
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        
-        if ($loadedXml) {
-            for ($i=count($loadedXml->attachment_types->type); $i >= 0; $i--) {
-                if (in_array($loadedXml->attachment_types->type[$i]->id, ['outgoing_mail_signed'])) {
-                    unset($loadedXml->attachment_types->type[$i]);
-                }
-            }
-
-            $res = formatXml($loadedXml);
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-            $migrated++;
-        }
-    }
-
-    printf("Migration de Modèles de document départ spontannée (CUSTOM {$custom}) : " . $migrated . " Modèle(s) migré(s), $nonMigrated non migré(s).\n");
-}
-
-function formatXml($simpleXMLElement)
-{
-    $xmlDocument = new DOMDocument('1.0');
-    $xmlDocument->preserveWhiteSpace = false;
-    $xmlDocument->formatOutput = true;
-    $xmlDocument->loadXML($simpleXMLElement->asXML());
-
-    return $xmlDocument->saveXML();
-}
diff --git a/migration/20.03/migrateRedirectKeywords.php b/migration/20.03/migrateRedirectKeywords.php
deleted file mode 100644
index 72c54b17a6a964f236ccf341e2483a08eaad2f8e..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateRedirectKeywords.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $redirectGroupBasket = \SrcCore\models\DatabaseModel::select([
-        'select'    => ['group_id', 'basket_id', 'id'],
-        'table'     => ['actions_groupbaskets, actions'],
-        'where'     => ['keyword = ?', 'id_action = id'],
-        'data'      => ['redirect']
-    ]);
-
-    $migrated = 0;
-    foreach ($redirectGroupBasket as $value) {
-        $keywordsAndEntities = \SrcCore\models\DatabaseModel::select([
-            'select'    => [1],
-            'table'     => ['groupbasket_redirect'],
-            'where'     => ['group_id = ?', 'basket_id = ?', 'action_id in (?)'],
-            'data'      => [$value['group_id'], $value['basket_id'], $value['id']]
-        ]);
-
-        if (empty($keywordsAndEntities)) {
-            \Basket\models\GroupBasketRedirectModel::create([
-                'id'            => $value['basket_id'],
-                'groupId'       => $value['group_id'],
-                'actionId'      => $value['id'],
-                'entityId'      => '',
-                'keyword'       => 'ALL_ENTITIES',
-                'redirectMode'  => 'ENTITY'
-            ]);
-            $migrated++;
-        }
-    }
-
-    printf("Migration keywords redirection vide (CUSTOM {$custom}) : " . $migrated . " keyword(s) ALL_ENTITIES ajouté(s).\n");
-}
diff --git a/migration/20.03/migrateServicesEntities.php b/migration/20.03/migrateServicesEntities.php
deleted file mode 100644
index be7dc6fb3a94facfd91b175f5450550d10f11115..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateServicesEntities.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$nonReadableFiles = [];
-$migrated = 0;
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $natures = [];
-    $path = "custom/{$custom}/modules/entities/xml/services.xml";
-    if (file_exists($path)) {
-        if (!is_readable($path) || !is_writable($path)) {
-            $nonReadableFiles[] = $path;
-            continue;
-        }
-        $loadedXml = simplexml_load_file($path);
-        
-        if ($loadedXml) {
-            $i = 0;
-            foreach ($loadedXml->SERVICE as $value) {
-                if ($value->id == 'entities_print_sep_mlb') {
-                    $loadedXml->SERVICE[$i]->servicepage = '/separators/print';
-                    $loadedXml->SERVICE[$i]->angular = 'true';
-                    break;
-                }
-                ++$i;
-            }
-            $res = formatXml($loadedXml);
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-                $migrated++;
-            }
-        }
-    }
-}
-
-foreach ($nonReadableFiles as $file) {
-    printf("The file %s it is not readable or not writable.\n", $file);
-}
-
-printf($migrated . " custom(s) avec services.xml (entities) trouvé(s) et migré(s).\n");
-
-function formatXml($simpleXMLElement)
-{
-    $xmlDocument = new DOMDocument('1.0');
-    $xmlDocument->preserveWhiteSpace = false;
-    $xmlDocument->formatOutput = true;
-    $xmlDocument->loadXML($simpleXMLElement->asXML());
-
-    return $xmlDocument->saveXML();
-}
diff --git a/migration/20.03/migrateTemplates.php b/migration/20.03/migrateTemplates.php
deleted file mode 100644
index f12f94353e86f383f34d1444d67cbfd4a39839ee..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateTemplates.php
+++ /dev/null
@@ -1,465 +0,0 @@
-<?php
-
-use Contact\models\ContactCustomFieldListModel;
-use CustomField\models\CustomFieldModel;
-use Docserver\controllers\DocserverController;
-use Docserver\models\DocserverModel;
-use SrcCore\models\CoreConfigModel;
-use Template\models\TemplateModel;
-
-require '../../vendor/autoload.php';
-
-include_once('../../vendor/tinybutstrong/opentbs/tbs_plugin_opentbs.php');
-
-const OFFICE_EXTENSIONS = ['odt', 'ods', 'odp', 'xlsx', 'pptx', 'docx', 'odf'];
-
-$DATA_TO_REPLACE = [
-    'res_letterbox.destination'         => '[destination.entity_id]',
-    'res_letterbox.entity_label'        => '[destination.entity_label]',
-    'res_letterbox.process_notes'       => '[notes]',
-    'res_letterbox.contact_firstname'   => '[sender.firstname]',
-    'res_letterbox.contact_lastname'    => '[sender.lastname]',
-    'res_letterbox.contact_society'     => '[sender.company]',
-
-    'res_letterbox.nature_id' => '[res_letterbox.customField_1]',
-
-    // Initiator
-    'res_letterbox.initiator_entity_id'           => '[initiator.entity_id]',
-    'res_letterbox.initiator_entity_label'        => '[initiator.entity_label]',
-    'res_letterbox.initiator_short_label'         => '[initiator.short_label]',
-    'res_letterbox.initiator_email'               => '[initiator.email]',
-    'res_letterbox.initiator_parent_entity_id'    => '[initiator.parent_entity_id]',
-    'res_letterbox.initiator_parent_entity_label' => '[initiator.parent_entity_label]',
-    'res_letterbox.initiator_entity_type'         => '[initiator.entity_type]',
-    'res_letterbox.initiator_entity_path'         => '[initiator.entity_path]',
-    'res_letterbox.initiator_entity_fullname'     => '[initiator.entity_fullname]',
-    'res_letterbox.initiator_zipcode'             => '[initiator.zipcode]',
-    'res_letterbox.initiator_city'                => '[initiator.city]',
-    'res_letterbox.initiator_country'             => '[initiator.country]',
-    'res_letterbox.initiator_ldap_id'             => '[initiator.ldap_id]',
-    'res_letterbox.initiator_archival_agence'     => '[initiator.archival_agence]',
-    'res_letterbox.initiator_archival_agreement'  => '[initiator.archival_agreement]',
-    'res_letterbox.initiator_business_id'         => '[initiator.business_id]',
-
-    'attachments.chrono' => '[attachment.chrono]',
-
-    'visa.firstnameSign' => '',
-    'visa.lastnameSign'  => '[visas]',
-    'visa.entitySign'    => '',
-    'visa.firstname1'    => '',
-    'visa.lastname1'     => '[visas]',
-    'visa.firstname2'    => '',
-    'visa.lastname2'     => '',
-    'visa.firstname3'    => '',
-    'visa.lastname3'     => '',
-    'visa.firstname4'    => '',
-    'visa.lastname4'     => '',
-    'visa.firstname5'    => '',
-    'visa.lastname5'     => '',
-    'visa.firstname6'    => '',
-    'visa.lastname6'     => '',
-    'visa.firstname7'    => '',
-    'visa.lastname7'     => '',
-    'visa.firstname8'    => '',
-    'visa.lastname8'     => '',
-    'visa.firstname9'    => '',
-    'visa.lastname9'     => '',
-    'visa.entity1'       => '',
-    'visa.entity2'       => '',
-    'visa.entity3'       => '',
-    'visa.entity4'       => '',
-    'visa.entity5'       => '',
-    'visa.entity6'       => '',
-    'visa.entity7'       => '',
-    'visa.entity8'       => '',
-    'visa.entity9'       => '',
-
-    'avis.firstname1' => '',
-    'avis.lastname1'  => '[opinions]',
-    'avis.firstname2' => '',
-    'avis.lastname2'  => '',
-    'avis.firstname3' => '',
-    'avis.lastname3'  => '',
-    'avis.firstname4' => '',
-    'avis.lastname4'  => '',
-    'avis.firstname5' => '',
-    'avis.lastname5'  => '',
-    'avis.firstname6' => '',
-    'avis.lastname6'  => '',
-    'avis.firstname7' => '',
-    'avis.lastname7'  => '',
-    'avis.firstname8' => '',
-    'avis.lastname8'  => '',
-    'avis.firstname9' => '',
-    'avis.lastname9'  => '',
-    'avis.role1'      => '',
-    'avis.entity1'    => '',
-    'avis.note1'      => '',
-    'avis.role2'      => '',
-    'avis.entity2'    => '',
-    'avis.note2'      => '',
-    'avis.role3'      => '',
-    'avis.entity3'    => '',
-    'avis.note3'      => '',
-    'avis.role4'      => '',
-    'avis.entity4'    => '',
-    'avis.note4'      => '',
-    'avis.role5'      => '',
-    'avis.entity5'    => '',
-    'avis.note5'      => '',
-    'avis.role6'      => '',
-    'avis.entity6'    => '',
-    'avis.note6'      => '',
-    'avis.role7'      => '',
-    'avis.entity7'    => '',
-    'avis.note7'      => '',
-    'avis.role8'      => '',
-    'avis.entity8'    => '',
-    'avis.note8'      => '',
-    'avis.role9'      => '',
-    'avis.entity9'    => '',
-    'avis.note9'      => '',
-
-    'copies.firstname1' => '',
-    'copies.lastname1'  => '[copies]',
-    'copies.firstname2' => '',
-    'copies.lastname2'  => '',
-    'copies.firstname3' => '',
-    'copies.lastname3'  => '',
-    'copies.firstname4' => '',
-    'copies.lastname4'  => '',
-    'copies.firstname5' => '',
-    'copies.lastname5'  => '',
-    'copies.firstname6' => '',
-    'copies.lastname6'  => '',
-    'copies.firstname7' => '',
-    'copies.lastname7'  => '',
-    'copies.firstname8' => '',
-    'copies.lastname8'  => '',
-    'copies.firstname9' => '',
-    'copies.lastname9'  => '',
-    'copies.entity1'    => '',
-    'copies.entity2'    => '',
-    'copies.entity3'    => '',
-    'copies.entity4'    => '',
-    'copies.entity5'    => '',
-    'copies.entity6'    => '',
-    'copies.entity7'    => '',
-    'copies.entity8'    => '',
-    'copies.entity9'    => '',
-
-    'user.role'             => '[userPrimaryEntity.role]',
-    'user.entity_id'        => '[userPrimaryEntity.entity_id]',
-    'user.entity_label'     => '[userPrimaryEntity.entity_label]',
-    'user.short_label'      => '[userPrimaryEntity.short_label]',
-    'user.adrs_1'           => '[userPrimaryEntity.adrs_1]',
-    'user.adrs_2'           => '[userPrimaryEntity.adrs_2]',
-    'user.adrs_3'           => '[userPrimaryEntity.adrs_3]',
-    'user.zipcode'          => '[userPrimaryEntity.zipcode]',
-    'user.city'             => '[userPrimaryEntity.city]',
-    'user.email'            => '[userPrimaryEntity.email]',
-    'user.parent_entity_id' => '[userPrimaryEntity.parent_entity_id]',
-    'user.entity_type'      => '[userPrimaryEntity.entity_type]',
-    'user.entity_path'      => '[userPrimaryEntity.path]',
-
-    'notes.identifier'                       => '[res_letterbox.res_id]',
-    'notes.subject'                          => '[res_letterbox.subject]',
-    'notes.note_text'                        => '[notes.content;block=tr]',
-    'notes.user_id'                          => '',
-    'notes.# ;frm=0000'                      => '[res_letterbox.# ;frm=0000]',
-    'notes.doc_date;block=tr;frm=dd/mm/yyyy' => '[res_letterbox.doc_date;block=tr;frm=dd/mm/yyyy]',
-    'notes.doc_date;block=tr'                => '[res_letterbox.doc_date;block=tr]',
-    'notes.doc_date;frm=dd/mm/yyyy'          => '[res_letterbox.doc_date;frm=dd/mm/yyyy]',
-    'notes.doc_date'                         => '[res_letterbox.doc_date]',
-    'notes.contact_society'                  => '[contact.company]',
-    'notes.contact_firstname'                => '[contact.firstname]',
-    'notes.contact_lastname'                 => '[contact.lastname;block=tr]',
-    'notes.linktodetail'                     => '[res_letterbox.linktodetail]',
-    'notes.linktodoc'                        => '[res_letterbox.linktodoc]',
-];
-
-const DATA_CONTACT_NOTIFICATION = [
-    'sender.firstname'                  => '[contact.firstname]',
-    'sender.lastname'                   => '[contact.lastname]',
-    'sender.company'                    => '[contact.company]',
-    'contact.contact_type_label'        => '',
-    'contact.society_short'             => '',
-    'contact.contact_purpose_label'     => '',
-    'contact.website'                   => '',
-    'contact.salutation_header'         => '',
-    'contact.salutation_footer'         => '',
-    'contact.society'                   => '[contact.company]',
-    'contact.departement'               => '[contact.department]',
-    'contact.title'                     => '[contact.civility]',
-    'contact.contact_title'             => '[contact.civility]',
-    'contact.contact_lastname'          => '[contact.lastname]',
-    'contact.contact_firstname'         => '[contact.firstname]',
-    'contact.lastname'                  => '[contact.lastname]',
-    'contact.firstname'                 => '[contact.firstname]',
-    'contact.function'                  => '[contact.function]',
-    'contact.postal_address;strconv=no' => '[contact.postal_address;strconv=no]',
-    'contact.postal_address'            => '[contact.postal_address]',
-    'contact.address_num'               => '[contact.address_number]',
-    'contact.address_street'            => '[contact.address_street]',
-    'contact.occupancy'                 => '[contact.address_additional1]',
-    'contact.address_complement'        => '[contact.address_additional2]',
-    'contact.address_town'              => '[contact.address_town]',
-    'contact.address_postal_code'       => '[contact.address_postcode]',
-    'contact.address_country'           => '[contact.address_country]',
-    'contact.phone'                     => '[contact.phone]',
-    'contact.email'                     => '[contact.email]',
-];
-
-const DATA_CONTACT_ATTACHMENT = [
-    'contact.contact_type_label'        => '',
-    'contact.society_short'             => '',
-    'contact.contact_purpose_label'     => '',
-    'contact.website'                   => '',
-    'contact.salutation_header'         => '',
-    'contact.salutation_footer'         => '',
-    'contact.society'                   => '[attachmentRecipient.company]',
-    'contact.departement'               => '[attachmentRecipient.department]',
-    'contact.title'                     => '[attachmentRecipient.civility]',
-    'contact.contact_title'             => '[attachmentRecipient.civility]',
-    'contact.contact_lastname'          => '[attachmentRecipient.lastname]',
-    'contact.contact_firstname'         => '[attachmentRecipient.firstname]',
-    'contact.lastname'                  => '[attachmentRecipient.lastname]',
-    'contact.firstname'                 => '[attachmentRecipient.firstname]',
-    'contact.function'                  => '[attachmentRecipient.function]',
-    'contact.postal_address;strconv=no' => '[attachmentRecipient.postal_address;strconv=no]',
-    'contact.postal_address'            => '[attachmentRecipient.postal_address]',
-    'contact.address_num'               => '[attachmentRecipient.address_number]',
-    'contact.address_street'            => '[attachmentRecipient.address_street]',
-    'contact.occupancy'                 => '[attachmentRecipient.address_additional1]',
-    'contact.address_complement'        => '[attachmentRecipient.address_additional2]',
-    'contact.address_town'              => '[attachmentRecipient.address_town]',
-    'contact.address_postal_code'       => '[attachmentRecipient.address_postcode]',
-    'contact.address_country'           => '[attachmentRecipient.address_country]',
-    'contact.phone'                     => '[attachmentRecipient.phone]',
-    'contact.email'                     => '[attachmentRecipient.email]',
-];
-
-const DATA_CONTACT_ACKNOWLEDGEMENT_RECEIPT = [
-    'contact.contact_type_label'        => '',
-    'contact.society_short'             => '',
-    'contact.contact_purpose_label'     => '',
-    'contact.website'                   => '',
-    'contact.salutation_header'         => '',
-    'contact.salutation_footer'         => '',
-    'contact.society'                   => '[sender.company]',
-    'contact.departement'               => '[sender.department]',
-    'contact.title'                     => '[sender.civility]',
-    'contact.contact_title'             => '[sender.civility]',
-    'contact.contact_lastname'          => '[sender.lastname]',
-    'contact.contact_firstname'         => '[sender.firstname]',
-    'contact.lastname'                  => '[sender.lastname]',
-    'contact.firstname'                 => '[sender.firstname]',
-    'contact.function'                  => '[sender.function]',
-    'contact.postal_address;strconv=no' => '[sender.postal_address;strconv=no]',
-    'contact.postal_address'            => '[sender.postal_address]',
-    'contact.address_num'               => '[sender.address_number]',
-    'contact.address_street'            => '[sender.address_street]',
-    'contact.occupancy'                 => '[sender.address_additional1]',
-    'contact.address_complement'        => '[sender.address_additional2]',
-    'contact.address_town'              => '[sender.address_town]',
-    'contact.address_postal_code'       => '[sender.address_postcode]',
-    'contact.address_country'           => '[sender.address_country]',
-    'contact.phone'                     => '[sender.phone]',
-    'contact.email'                     => '[sender.email]',
-];
-
-$contactCustomFields = [
-    ['oldId' => 'salutation_header', 'label' => 'Formule de politesse (Début)'],
-    ['oldId' => 'salutation_footer', 'label' => 'Formule de politesse (Fin)'],
-    ['oldId' => 'website', 'label' => 'Site internet'],
-    ['oldId' => 'contact_type_label', 'label' => 'Type de contact'],
-    ['oldId' => 'contact_purpose_label', 'label' => 'Dénomination'],
-    ['oldId' => 'society_short', 'label' => 'Sigle de la structure'],
-];
-
-$resourceCustomFields = [
-    ['id' => 'description', 'label' => 'Autres informations'],
-    ['id' => 'external_reference', 'label' => 'Référence courrier expéditeur'],
-    ['id' => 'reference_number', 'label' => 'N° recommandé'],
-    ['id' => 'scan_date', 'label' => 'Date de scan'],
-    ['id' => 'scan_user', 'label' => 'Utilisateur de scan'],
-    ['id' => 'scan_location', 'label' => 'Lieu de scan'],
-    ['id' => 'scan_wkstation', 'label' => 'Station de scan'],
-    ['id' => 'scan_batch', 'label' => 'Batch de scan'],
-    ['id' => 'scan_postmark', 'label' => 'Tampon de scan'],
-];
-
-chdir('../..');
-
-$customs = scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    foreach ($contactCustomFields as $customField) {
-        $idNewCustomField = ContactCustomFieldListModel::get([
-            'select' => ['id'],
-            'where'  => ['label = ?'],
-            'data'   => [$customField['label']]
-        ]);
-        $DATA_TO_REPLACE["contact." . $customField['oldId']] = "[recipient.customField_{$idNewCustomField[0]['id']}]";
-    }
-
-    foreach ($resourceCustomFields as $customField) {
-        $idNewCustomField = CustomFieldModel::get([
-            'select' => ['id'],
-            'where'  => ['label = ?'],
-            'data'   => [$customField['label']]
-        ]);
-        $DATA_TO_REPLACE["res_letterbox." . $customField['id']] = "[res_letterbox.customField_{$idNewCustomField[0]['id']}]";
-    }
-
-    $migrated    = 0;
-    $nonMigrated = 0;
-
-    $docserver     = DocserverModel::getByDocserverId(['docserverId' => 'TEMPLATES']);
-    $templatesPath = $docserver['path_template'];
-    $templates     = TemplateModel::get(['where' => ['template_target != ?'], 'data' => ['indexingFile']]);
-
-    $tmpPath = CoreConfigModel::getTmpPath();
-
-    foreach ($templates as $template) {
-        if ($template['template_type'] == 'HTML' || $template['template_type'] == 'TXT' || $template['template_type'] == 'OFFICE_HTML') {
-            $content = $template['template_content'];
-
-            $newContent = $content;
-            foreach ($DATA_TO_REPLACE as $key => $value) {
-                $newContent = str_replace('[' . $key . ']', $value, $newContent);
-            }
-
-            if ($template['template_target'] == 'acknowledgementReceipt') {
-                foreach (DATA_CONTACT_ACKNOWLEDGEMENT_RECEIPT as $key => $value) {
-                    $newContent = str_replace('[' . $key . ']', $value, $newContent);
-                }
-            } elseif ($template['template_target'] == 'notifications') {
-                foreach (DATA_CONTACT_NOTIFICATION as $key => $value) {
-                    $newContent = str_replace('[' . $key . ']', $value, $newContent);
-                }
-            } else {
-                foreach (DATA_CONTACT_ATTACHMENT as $key => $value) {
-                    $newContent = str_replace('[' . $key . ']', $value, $newContent);
-                }
-            }
-
-            if ($template['template_target'] == 'doctypes') {
-                $pathFilename = $tmpPath . 'template_migration_' . rand() . '_'. rand() .'.html';
-                file_put_contents($pathFilename, $newContent);
-
-                $resource = file_get_contents($pathFilename);
-                $pathInfo = pathinfo($pathFilename);
-                $storeResult = DocserverController::storeResourceOnDocServer([
-                    'collId'           => 'templates',
-                    'docserverTypeId'  => 'TEMPLATES',
-                    'encodedResource'  => base64_encode($resource),
-                    'format'           => $pathInfo['extension']
-                ]);
-
-                if (!empty($storeResult['errors'])) {
-                    echo $storeResult['errors'];
-                    continue;
-                }
-
-                TemplateModel::update([
-                        'set'   => [
-                            'template_content'    => '',
-                            'template_type'       => 'OFFICE',
-                            'template_path'       => $storeResult['destination_dir'],
-                            'template_file_name'  => $storeResult['file_destination_name'],
-                            'template_style'      => '',
-                            'template_datasource' => 'letterbox_attachment',
-                            'template_target'     => 'indexingFile',
-                            'template_attachment_type' => 'all'
-                        ],
-                        'where' => ['template_id = ?'],
-                        'data'  => [$template['template_id']]
-                    ]);
-                unlink($pathFilename);
-            } else {
-                if ($content != $newContent) {
-                    TemplateModel::update([
-                        'set'   => [
-                            'template_content' => $newContent
-                        ],
-                        'where' => ['template_id = ?'],
-                        'data'  => [$template['template_id']]
-                    ]);
-                    $migrated++;
-                } else {
-                    $nonMigrated++;
-                }
-            }
-        }
-        if ($template['template_type'] == 'OFFICE' || $template['template_type'] == 'OFFICE_HTML') {
-            $path = str_replace('#', '/', $template['template_path']);
-
-            $pathToDocument = $templatesPath . $path . $template['template_file_name'];
-
-            $pathInfo = pathinfo($pathToDocument);
-            $extension = $pathInfo['extension'];
-
-            if (!in_array($extension, OFFICE_EXTENSIONS)) {
-                $nonMigrated++;
-                continue;
-            }
-
-            if (!is_writable($pathToDocument) || !is_readable($pathToDocument)) {
-                $nonMigrated++;
-                continue;
-            }
-
-            $tbs = new clsTinyButStrong();
-            $tbs->NoErr = true;
-            $tbs->Protect = false;
-            $tbs->PlugIn(TBS_INSTALL, OPENTBS_PLUGIN);
-
-            $tbs->LoadTemplate($pathToDocument, OPENTBS_ALREADY_UTF8);
-
-            $pages = 1;
-            if ($extension == 'xlsx') {
-                $pages = $tbs->PlugIn(OPENTBS_COUNT_SHEETS);
-            }
-
-            for ($i = 0; $i < $pages; ++$i) {
-                if ($extension == 'xlsx') {
-                    $tbs->PlugIn(OPENTBS_SELECT_SHEET, $i + 1);
-                }
-
-                $tbs->ReplaceFields($DATA_TO_REPLACE);
-
-                if ($template['template_target'] == 'acknowledgementReceipt') {
-                    $tbs->ReplaceFields(DATA_CONTACT_ACKNOWLEDGEMENT_RECEIPT);
-                } else {
-                    $tbs->ReplaceFields(DATA_CONTACT_ATTACHMENT);
-                }
-            }
-
-            if (in_array($extension, OFFICE_EXTENSIONS)) {
-                $tbs->Show(OPENTBS_STRING);
-            } else {
-                $tbs->Show(TBS_NOTHING);
-            }
-
-            $content = base64_encode($tbs->Source);
-
-            $result = file_put_contents($pathToDocument, base64_decode($content));
-            if ($result !== false) {
-                $migrated++;
-            } else {
-                echo "Erreur lors de la migration du modèle : $pathToDocument\n";
-                $nonMigrated++;
-            }
-        }
-    }
-
-    printf("Migration de Modèles de documents (CUSTOM {$custom}) : " . $migrated . " Modèle(s) migré(s), $nonMigrated non migré(s).\n");
-}
diff --git a/migration/20.03/migrateThesaurus.php b/migration/20.03/migrateThesaurus.php
deleted file mode 100644
index 0d808e45041e86dd01dce07fe788eccc93987c54..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateThesaurus.php
+++ /dev/null
@@ -1,185 +0,0 @@
-<?php
-
-use SrcCore\models\DatabaseModel;
-use Tag\models\ResourceTagModel;
-use Tag\models\TagModel;
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs = scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    $migrated = 0;
-
-    $thesaurusList = \SrcCore\models\DatabaseModel::select([
-        'select' => ['*'],
-        'table'  => ['thesaurus']
-    ]);
-
-    $parents = [];
-    $links = [];
-
-    $thesaurusIds = [];
-
-    // Migrate elements in thesaurus
-    $tagId = DatabaseModel::getNextSequenceValue(['sequenceId' => 'tags_id_seq']);
-    foreach ($thesaurusList as $thesaurus) {
-        DatabaseModel::insert([
-            'table'         => 'tags',
-            'columnsValues' => [
-                'id'            => $tagId,
-                'label'         => $thesaurus['thesaurus_name'],
-                'description'   => $thesaurus['thesaurus_description'] ?? null,
-                'usage'         => $thesaurus['used_for'] ?? null,
-                'creation_date' => $thesaurus['creation_date'] ?? null
-            ]
-        ]);
-
-        if (!empty($thesaurus['thesaurus_parent_id'])) {
-            $parents[$tagId] = [
-                'parent_label'     => $thesaurus['thesaurus_parent_id'],
-                'tag_label'        => $thesaurus['thesaurus_name'],
-                'tag_id' => $tagId
-            ];
-        }
-        if (!empty($thesaurus['thesaurus_name_associate'])) {
-            $links[$tagId] = [
-                'name_association' => $thesaurus['thesaurus_name_associate'],
-                'tag_label'        => $thesaurus['thesaurus_name'],
-                'tag_id' => $tagId
-            ];
-        }
-
-        $thesaurusIds[$thesaurus['thesaurus_id']] = $tagId;
-
-        $migrated++;
-        $tagId++;
-    }
-
-    // Migrate elements parents
-    $parentMigrated = 0;
-    $parentNotMigrated = 0;
-    $linksMigrated = 0;
-    $linksNotMigrated = 0;
-    foreach ($parents as $tagId => $association) {
-        $parent = TagModel::get([
-            'where' => ['label = ?'],
-            'data'  => [$association['parent_label']]
-        ]);
-        if (empty($parent[0])) {
-            echo "[PARENT] Le tag '" . $association['parent_label'] . "', parent du tag '" . $association['tag_label'] . "' n'a pas été trouvé\n";
-            $parentNotMigrated++;
-        } else {
-            TagModel::update([
-                'set'   => [
-                    'parent_id' => $parent[0]['id'],
-                ],
-                'where' => ['id = ?'],
-                'data'  => [$tagId]
-            ]);
-            $parentMigrated++;
-        }
-    }
-
-    // Migrate elements links
-    foreach ($links as $link) {
-        $nameList = explode(",", $link['name_association']);
-
-        foreach ($nameList as $item) {
-            $linkedTag = TagModel::get([
-                'where' => ['label = ?'],
-                'data' => [$item]
-            ]);
-            if (empty($linkedTag[0])) {
-                echo "[LINK] Le tag '" . $item . "', associé au tag '" . $link['tag_label'] . "' n'a pas été trouvé\n";
-                $linksNotMigrated++;
-            } else {
-                TagModel::update([
-                    'postSet'   => ['links' => "jsonb_insert(links, '{0}', '\"{$linkedTag[0]['id']}\"')"],
-                    'where'     => ['id = ?', "(links @> ?) = false"],
-                    'data'      => [$tagId, "\"{$linkedTag[0]['id']}\""]
-                ]);
-                TagModel::update([
-                    'postSet'   => ['links' => "jsonb_insert(links, '{0}', '\"{$tagId}\"')"],
-                    'where'     => ['id = ?', "(links @> ?) = false"],
-                    'data'      => [$linkedTag[0]['id'], "\"{$tagId}\""]
-                ]);
-                $linksMigrated++;
-            }
-        }
-    }
-
-    $thesaurusResList = \SrcCore\models\DatabaseModel::select([
-        'select' => ['*'],
-        'table'  => ['thesaurus_res']
-    ]);
-
-    foreach ($thesaurusResList as $item) {
-        ResourceTagModel::create([
-            'res_id' => $item['res_id'],
-            'tag_id' => $thesaurusIds[$item['thesaurus_id']]
-        ]);
-    }
-
-    // Get all empty tags
-    $emptyTags = TagModel::get([
-        'select'  => ['id', 'links', 'parent_id'],
-        'where'   => ["replace(label, ' ', '') = ''"],
-        'orderBy' => ['id desc']
-    ]);
-
-    // Remove resources links + tag links
-    foreach ($emptyTags as $emptyTag) {
-        ResourceTagModel::delete([
-            'where' => ['tag_id = ?'],
-            'data'  => [$emptyTag['id']]
-        ]);
-
-        $links = json_decode($emptyTag['links'], true);
-        foreach ($links as $link) {
-            TagModel::update([
-                'postSet' => ['links' => "links - '{$emptyTag['id']}'"],
-                'where'   => ['id = ?'],
-                'data'    => [$link]
-            ]);
-            TagModel::update([
-                'postSet' => ['links' => "links - '{$link}'"],
-                'where'   => ['id = ?'],
-                'data'    => [$emptyTag['id']]
-            ]);
-        }
-
-        $parentId = TagModel::getById([
-            'select' => ['parent_id'],
-            'id'     => $emptyTag['id']
-        ]);
-        $parentId = $parentId['parent_id'];
-
-        TagModel::update([
-            'set'   => ['parent_id' => $parentId],
-            'where' => ['parent_id = ?'],
-            'data'  => [$emptyTag['id']]
-        ]);
-    }
-
-    // Delete tags
-    $emptyTags = array_column($emptyTags, 'id');
-    $nbEmptyTags = count($emptyTags);
-    if (!empty($emptyTags)) {
-        TagModel::delete([
-            'where' => ['id in (?)'],
-            'data'  => [$emptyTags]
-        ]);
-    }
-
-    printf("Migration du thesaurus dans la table tags (CUSTOM {$custom}) : " . $migrated . " termes migrés. ($parentMigrated liens de parentés migrés, $parentNotMigrated non migrés, $linksMigrated associations migrés, $linksNotMigrated non migrés, $nbEmptyTags tag(s) vide supprimé(s))\n");
-}
diff --git a/migration/20.03/migrateVersionAttachments.php b/migration/20.03/migrateVersionAttachments.php
deleted file mode 100644
index cb38380f09b81a75d41930ed820dd89e25b2a50c..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateVersionAttachments.php
+++ /dev/null
@@ -1,193 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$customs =  scandir('custom');
-
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    \SrcCore\models\DatabaseModel::delete([
-        'table' => 'res_attachments',
-        'where' => ['relation > 1']
-    ]);
-
-    $superadmin = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => 'superadmin']);
-    if (empty($superadmin)) {
-        $firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1]);
-        $masterOwnerId = $firstMan[0]['id'];
-    } else {
-        $masterOwnerId = $superadmin['id'];
-    }
-
-    $migrated = 0;
-    $attachmentsInfo = \SrcCore\models\DatabaseModel::select([
-        'select'   => ['res_id', 'title', 'format', 'typist', 'creation_date', 'fulltext_result', 'identifier', 'relation', 'doc_date', 'docserver_id', 'path', 'filename', 'fingerprint', 'filesize',
-                        'status', 'validation_date', 'effective_date', 'origin', 'dest_user', 'res_id_master', 'attachment_type', 'dest_contact_id', 'dest_address_id', 'updated_by', 'in_signature_book',
-                        'signatory_user_serial_id', 'in_send_attach', 'external_id', 'attachment_id_master'
-        ],
-        'table'    => ['res_version_attachments']
-    ]);
-
-    foreach ($attachmentsInfo as $attachmentInfo) {
-        $oldResId = $attachmentInfo['res_id'];
-        unset($attachmentInfo['res_id']);
-        $attachmentInfo['origin_id'] = $attachmentInfo['attachment_id_master'];
-        unset($attachmentInfo['attachment_id_master']);
-        $attachmentInfo['modification_date'] = $attachmentInfo['doc_date'];
-        unset($attachmentInfo['doc_date']);
-        if (!empty($attachmentInfo['updated_by'])) {
-            $userSerialId = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $attachmentInfo['updated_by']]);
-            $attachmentInfo['modified_by'] = $userSerialId['id'];
-        } else {
-            $attachmentInfo['modified_by'] = null;
-        }
-        unset($attachmentInfo['updated_by']);
-        $attachmentInfo['in_signature_book'] = empty($attachmentInfo['in_signature_book']) ?  'false' : 'true';
-        $attachmentInfo['in_send_attach']    = empty($attachmentInfo['in_send_attach']) ?  'false' : 'true';
-        $attachmentInfo['format']            = empty($attachmentInfo['format']) ?  pathinfo($attachmentInfo['filename'], PATHINFO_EXTENSION) : $attachmentInfo['format'];
-        if (empty($attachmentInfo['fingerprint'])) {
-            $docserver = \SrcCore\models\DatabaseModel::select([
-                'select' => ['path_template', 'docserver_type_id'],
-                'table'  => ['docservers'],
-                'where'  => ['docserver_id = ?'],
-                'data'   => [$attachmentInfo['docserver_id']]
-            ]);
-            $docserverType = \SrcCore\models\DatabaseModel::select([
-                'select' => ['fingerprint_mode'],
-                'table'  => ['docserver_types'],
-                'where'  => ['docserver_type_id = ?'],
-                'data'   => [$docserver[0]['docserver_type_id']]
-            ]);
-            $pathToDocument = $docserver[0]['path_template'] . str_replace('#', DIRECTORY_SEPARATOR, $attachmentInfo['path']) . $attachmentInfo['filename'];
-            if (file_exists($pathToDocument)) {
-                $fingerprint = \Resource\controllers\StoreController::getFingerPrint(['filePath' => $pathToDocument, 'mode' => $docserverType[0]['fingerprint_mode']]);
-                $attachmentInfo['fingerprint'] = $fingerprint;
-            } else {
-                $attachmentInfo['fingerprint'] = '1';
-            }
-        }
-
-        $newResId = \Attachment\models\AttachmentModel::create($attachmentInfo);
-
-        if ($attachmentInfo['fingerprint'] == 1) {
-            echo "Le document avec res_version_attachments.res_id = " . $oldResId
-                . " (nouveau res_id : res_attachment.res_id = " . $newResId . ") n'a pas été trouvé sur le docserver (path = '" . $pathToDocument . "')"
-                . ", le fingerprint du document est assigné à 1\n";
-        }
-
-        migrateOrigin(['oldResId' => $oldResId, 'newResId' => $newResId]);
-        migrateAdrVersionAttachments(['oldResId' => $oldResId, 'newResId' => $newResId]);
-        migrateHistoryVersion(['oldResId' => $oldResId, 'newResId' => $newResId]);
-        migrateEmailsVersion(['oldResId' => $oldResId, 'newResId' => $newResId]);
-        migrateMessageExchangeVersion(['oldResId' => $oldResId, 'newResId' => $newResId]);
-        migrateShippingVersion(['oldResId' => $oldResId, 'newResId' => $newResId]);
-        if (!in_array($attachmentInfo['status'], ['DEL', 'OBS', 'TMP'])) {
-            migrateFullText(['newResId' => $newResId, 'customId' => $custom, 'userId' => $masterOwnerId]);
-        }
-
-        $migrated++;
-    }
-
-    printf("Migration version attachement (CUSTOM {$custom}) : " . $migrated . " Version(s) trouvée(s) et migrée(s).\n");
-}
-
-function migrateOrigin($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['origin' => $args['newResId'] . ',res_attachments'],
-        'table' => 'res_attachments',
-        'where' => ['origin = ?'],
-        'data'  => [$args['oldResId'] . ',res_version_attachments']
-    ]);
-}
-
-function migrateAdrVersionAttachments($args = [])
-{
-    $adrInfos = \SrcCore\models\DatabaseModel::select(['select' => ['*'], 'table' => ['adr_attachments_version'], 'where' => ['res_id = ?'], 'data' => [$args['oldResId']]]);
-    foreach ($adrInfos as $value) {
-        unset($value['id']);
-        $value['res_id'] = $args['newResId'];
-        \SrcCore\models\DatabaseModel::insert([
-            'table'         => 'adr_attachments',
-            'columnsValues' => $value
-        ]);
-    }
-}
-
-function migrateHistoryVersion($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['table_name' => 'res_attachments', 'record_id' => $args['newResId']],
-        'postSet' => ['info' => "REPLACE(info, '{$args['oldResId']} (res_version_attachments)', '{$args['newResId']} (res_attachments)')"],
-        'table' => 'history',
-        'where' => ['table_name = ?', 'record_id = ?'],
-        'data'  => ['res_version_attachments', $args['oldResId']]
-    ]);
-}
-
-function migrateEmailsVersion($args = [])
-{
-    $emails = \SrcCore\models\DatabaseModel::select([
-        'select' => ['id', 'document'],
-        'table' => ['emails'],
-        'where' => ['document->\'attachments\' @> ?'],
-        'data' => ['[{"id":'.$args['oldResId'].', "isVersion":true}]']
-    ]);
-
-    foreach ($emails as $email) {
-        $document = json_decode($email['document'], true);
-        foreach ($document['attachments'] as $key => $attachment) {
-            if ($attachment['id'] == $args['oldResId'] && $attachment['isVersion']) {
-                $document['attachments'][$key]['id'] = $args['newResId'];
-                unset($document['attachments'][$key]['isVersion']);
-                break;
-            }
-        }
-        \SrcCore\models\DatabaseModel::update([
-            'set'   => ['document' => json_encode($document)],
-            'table' => 'emails',
-            'where' => ['id = ?'],
-            'data'  => [$email['id']]
-        ]);
-    }
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['document' => json_encode($document)],
-        'table' => 'emails',
-        'where' => ['id = ?'],
-        'data'  => [$email['id']]
-    ]);
-}
-
-function migrateMessageExchangeVersion($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['res_id' => $args['newResId'], 'tablename' => 'res_attachments'],
-        'table' => 'unit_identifier',
-        'where' => ['res_id = ?', 'tablename = ?'],
-        'data'  => [$args['oldResId'], 'res_version_attachments']
-    ]);
-}
-
-function migrateShippingVersion($args = [])
-{
-    \SrcCore\models\DatabaseModel::update([
-        'set'   => ['document_id' => $args['newResId'], 'is_version' => 'false'],
-        'table' => 'shippings',
-        'where' => ['document_id = ?', 'is_version = ?'],
-        'data'  => [$args['oldResId'], 'true']
-    ]);
-}
-
-function migrateFullText($args = [])
-{
-    $GLOBALS['id'] = $args['userId'];
-    exec("php src/app/convert/scripts/FullTextScript.php --customId {$args['customId']} --resId {$args['newResId']} --collId attachments_coll --userId {$GLOBALS['id']} > /dev/null");
-}
diff --git a/migration/20.03/migrateWorkingDays.php b/migration/20.03/migrateWorkingDays.php
deleted file mode 100644
index 770a80f515ee866efe26fe1e649893d400936249..0000000000000000000000000000000000000000
--- a/migration/20.03/migrateWorkingDays.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $workingDays = 1;
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/features.xml";
-    if (is_file($path)) {
-        $xmlfile = simplexml_load_file($path);
-
-        if ($xmlfile) {
-            $calendarType = $xmlfile->FEATURES->type_calendar;
-            if ($calendarType == 'calendar') {
-                $workingDays = 0;
-            } else {
-                $workingDays = 1;
-            }
-            unset($xmlfile->FEATURES->type_calendar);
-
-            $res = $xmlfile->asXML();
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-
-            $migrated++;
-        }
-    }
-
-    \SrcCore\models\DatabasePDO::reset();
-    new \SrcCore\models\DatabasePDO(['customId' => $custom]);
-
-    \Parameter\models\ParameterModel::delete(['id' => 'workingDays']);
-    \Parameter\models\ParameterModel::create([
-        'id'              => 'workingDays',
-        'description'     => 'Si activé (1), les délais de traitement sont calculés en jours ouvrés (Lundi à Vendredi). Sinon, en jours calendaire',
-        'param_value_int' => $workingDays
-    ]);
-}
-
-printf("Migration calendar type : " . $migrated . " custom(s) avec un fichier features.xml trouvé(s) et migré(s).\n");
diff --git a/migration/20.03/removeNatureFromPrint.php b/migration/20.03/removeNatureFromPrint.php
deleted file mode 100644
index d7c72ee11ec27337ca90fd3777a58a1c95177d2d..0000000000000000000000000000000000000000
--- a/migration/20.03/removeNatureFromPrint.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/print.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-
-        if ($xmlfile) {
-            $i = 0;
-            foreach ($xmlfile->letterbox_coll->FIELD as $field) {
-                if ($field->DATABASE_FIELD == 'nature_id') {
-                    unset($xmlfile->letterbox_coll->FIELD[$i]);
-                    break;
-                }
-                $i++;
-            }
-
-            $res = $xmlfile->asXML();
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-
-            $migrated++;
-        }
-    }
-}
-
-printf("Remove Nature : " . $migrated . " custom(s) avec un fichier print.xml trouvé(s) et migré(s).\n");
diff --git a/migration/20.03/removeProcessModes.php b/migration/20.03/removeProcessModes.php
deleted file mode 100644
index dbe55ba34d192478929d6433fbc8aad3861bd60c..0000000000000000000000000000000000000000
--- a/migration/20.03/removeProcessModes.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-require '../../vendor/autoload.php';
-
-chdir('../..');
-
-$migrated = 0;
-$customs =  scandir('custom');
-foreach ($customs as $custom) {
-    if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
-        continue;
-    }
-
-    $xmlfile = null;
-    $path = "custom/{$custom}/apps/maarch_entreprise/xml/entreprise.xml";
-    if (file_exists($path)) {
-        $xmlfile = simplexml_load_file($path);
-
-        if ($xmlfile) {
-            unset($xmlfile->process_modes);
-
-            $res = $xmlfile->asXML();
-            $fp = fopen($path, "w+");
-            if ($fp) {
-                fwrite($fp, $res);
-            }
-
-            $migrated++;
-        }
-    }
-}
-
-printf("Migration Process Mode : " . $migrated . " custom(s) avec un fichier entreprise.xml trouvé(s) et migré(s).\n");
diff --git a/modules/export_seda/Ajax_validation.php b/modules/export_seda/Ajax_validation.php
index f0a6e95822083c60ed7bc207c72e9c453ad38f05..009455411eaea7db8a8d245f4050f8df94c79cea 100755
--- a/modules/export_seda/Ajax_validation.php
+++ b/modules/export_seda/Ajax_validation.php
@@ -18,40 +18,13 @@
 *   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
 $status = 0;
 $error = $content = $res = '';
 
 if ($_REQUEST['reference']) {
-    $resIds = explode(',',$_REQUEST['reference']);
+    $resIds = explode(',', $_REQUEST['reference']);
     arsort($resIds);
-    if ($_REQUEST['type'] == 'acknowledgement') {
-        require_once __DIR__.'/CheckAcknowledgement.php';
-
-        $checkAcknowledgement = new CheckAcknowledgement();
-        foreach ($resIds as $id) {
-            $res = $checkAcknowledgement->checkAttachment($id);
-
-            if ($res === false) {
-                $status = 1;
-                $error = $_SESSION['error'];
-            }
-        }
-        $content = $res;
-    } else if ($_REQUEST['type'] == 'reply') {
-        require_once __DIR__.'/CheckReply.php';
-
-        $checkReply = new CheckReply();
-        foreach ($resIds as $id) {
-            $res = $checkReply->checkAttachment($id);
-
-            if ($res === false) {
-                $status = 1;
-                $error = $_SESSION['error'];
-            }
-        }
-        $content = $res;
-    } else if ($_REQUEST['type'] == 'purge') {
+    if ($_REQUEST['type'] == 'purge') {
         require_once __DIR__.'/Purge.php';
 
         $purge = new Purge();
@@ -64,7 +37,7 @@ if ($_REQUEST['reference']) {
             }
         }
         $content = $res;
-    } else if ($_REQUEST['type'] == 'reset') {
+    } elseif ($_REQUEST['type'] == 'reset') {
         require_once __DIR__.'/Reset.php';
 
         $reset = new Reset();
@@ -85,4 +58,4 @@ if ($_REQUEST['reference']) {
 }
 
 echo "{status : " . $status . ", content : '" . addslashes($content) . "', error : '" . addslashes($error) . "'}";
-exit ();
+exit();
diff --git a/modules/export_seda/CheckAcknowledgement.php b/modules/export_seda/CheckAcknowledgement.php
deleted file mode 100755
index bd0f87d6d0f39da14019df99d8f54396f7b6b236..0000000000000000000000000000000000000000
--- a/modules/export_seda/CheckAcknowledgement.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-require_once __DIR__ . '/RequestSeda.php';
-
-class CheckAcknowledgement
-{
-    private $db;
-    public function __construct()
-    {
-        $this->db = new RequestSeda();
-    }
-
-    public function checkAttachment($resId) {
-        $status = $this->db->getStatusLetter($resId);
-        if ($status != "SEND_SEDA") {
-            $_SESSION['error'] = _ERROR_STATUS_SEDA . $resId;
-            return false;
-        }
-
-        $acknowledgement = $this->db->getAcknowledgement($resId);
-        if (!$acknowledgement) {
-            $_SESSION['error'] = _ERROR_NO_ACKNOWLEDGEMENT . $resId;
-            return false;
-        }
-
-        $tabDir = explode('#',$acknowledgement->path);
-
-        $dir = '';
-        for ($i = 0; $i < count($tabDir); $i++) {
-            $dir .= $tabDir[$i] . DIRECTORY_SEPARATOR;
-        }
-
-        $docServer = $this->db->getDocServer($acknowledgement->docserver_id);
-        $fileName = $docServer->path_template. DIRECTORY_SEPARATOR . $dir . $acknowledgement->filename;
-        $xml = simplexml_load_file($fileName);
-
-        if (!$xml) {
-            $_SESSION['error'] = _ERROR_NO_XML_ACKNOWLEDGEMENT . $resId;
-            return false;
-        }
-
-        $message = $this->db->getMessageByReference($xml->MessageReceivedIdentifier);
-        if (!$message) {
-            $_SESSION['error'] = _ERROR_NO_REFERENCE_MESSAGE_ACKNOWLEDGEMENT . $resId;
-            return false;
-        }
-
-        $unitIdentifier = $this->db->getUnitIdentifierByResId($resId);
-
-        if ($unitIdentifier->message_id != $message->message_id) {
-            $_SESSION['error'] = _ERROR_WRONG_ACKNOWLEDGEMENT . $resId;
-            return false;
-        }
-
-        return $resId;
-    }
-}
diff --git a/modules/export_seda/CheckReply.php b/modules/export_seda/CheckReply.php
index e117cc59c399aca67fa399126551fb8d32a5da29..1484b2c038e7f98bb3e6d2a53330db2a7e61b72d 100755
--- a/modules/export_seda/CheckReply.php
+++ b/modules/export_seda/CheckReply.php
@@ -80,46 +80,6 @@ class CheckReply
         return true;
     }
 
-    public function checkAttachment($resId)
-    {
-        $reply = $this->db->getReply($resId);
-        if (!$reply) {
-            $_SESSION['error'] = _ERROR_NO_REPLY . $resId;
-            return false;
-        }
-
-        $tabDir = explode('#', $reply->path);
-
-        $dir = '';
-        for ($i = 0; $i < count($tabDir); $i++) {
-            $dir .= $tabDir[$i] . DIRECTORY_SEPARATOR;
-        }
-
-        $docServer = $this->db->getDocServer($reply->docserver_id);
-        $fileName = $docServer->path_template. DIRECTORY_SEPARATOR . $dir . $reply->filename;
-        $xml = simplexml_load_file($fileName);
-
-        if (!$xml) {
-            $_SESSION['error'] = _ERROR_NO_XML_REPLY . $resId;
-            return false;
-        }
-
-        $message = $this->db->getMessageByReference($xml->MessageRequestIdentifier);
-        if (!$message) {
-            $_SESSION['error'] = _ERROR_NO_REFERENCE_MESSAGE_REPLY . $resId;
-            return false;
-        }
-
-        $unitIdentifier = $this->db->getUnitIdentifierByResId($resId);
-
-        if ($unitIdentifier->message_id != $message->message_id) {
-            $_SESSION['error'] = _ERROR_WRONG_REPLY . $resId;
-            return false;
-        }
-
-        return $resId;
-    }
-
     public function getReply($reference)
     {
         $header = [
diff --git a/modules/export_seda/RequestSeda.php b/modules/export_seda/RequestSeda.php
index a62d7f012a83ca5a5a96fe267a46a029ebe80793..2cbd20cf072920bbf4e7ee2c5f42ff29315bd4b1 100755
--- a/modules/export_seda/RequestSeda.php
+++ b/modules/export_seda/RequestSeda.php
@@ -394,37 +394,6 @@ class RequestSeda
         return $attachments;
     }
 
-    public function getUseContact($orgIdentifier)
-    {
-        $queryParams = [];
-
-        $queryParams[] = $orgIdentifier;
-        $queryParams[] = $orgIdentifier;
-
-        $query = "SELECT COUNT(*) FROM message_exchange WHERE sender_org_identifier = ? OR recipient_org_identifier = ?";
-
-        $smtp = $this->db->query($query, $queryParams);
-
-        $res = $smtp->fetchObject();
-
-        return $res;
-    }
-
-    public function getAcknowledgement($resIdMaster)
-    {
-        $queryParams = [];
-
-        $queryParams[] = $resIdMaster;
-
-        $query = "SELECT * FROM res_attachments WHERE res_id_master = ? and type_id = 1 and status != 'DEL'";
-
-        $smtp = $this->db->query($query, $queryParams);
-
-        $res = $smtp->fetchObject();
-
-        return $res;
-    }
-
     public function getReply($resIdMaster)
     {
         $queryParams = [];
diff --git a/modules/export_seda/check_acknowledgement.php b/modules/export_seda/check_acknowledgement.php
deleted file mode 100755
index 945ef28e57ab0200d9f5aae37c2d575247e0eeff..0000000000000000000000000000000000000000
--- a/modules/export_seda/check_acknowledgement.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-/**
- * Copyright Maarch since 2008 under licence GPLv3.
- * See LICENCE.txt file at the root folder for more details.
- * This file is part of Maarch software.
- *
- */
-
-/**
- * @brief Acknowledgement letter
- * @author dev@maarch.org
- * @ingroup export seda
- */
-
-/**
- * $confirm  bool true
- */
-$confirm = true;
-
-/**
- * $etapes  array Contains only one etap, the status modification
- */
-
-$confirm = false;
-$etapes = array('form');
-$frm_width='285px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $res_id = $values[0];
-    $db = new Database();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("SELECT label_action FROM actions WHERE id = ?", array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i = 0; $i < count($values); $i++) {
-            $values_str .= $values[$i] . ', ';
-        }
-    } else {
-        for ($i = 0; $i < count($_SESSION['stockCheckbox']); $i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i] . ', ';
-        }
-    }
-    $path_to_script = $_SESSION['config']['businessappurl']."index.php?display=true&module=export_seda";
-
-    $values_str = preg_replace('/, $/', '', $values_str);
-    $frm_str ='<center style="font-size:15px;">'._ACTION_CONFIRM.'<br/><br/><b>'.$labelAction.' ?</b></center><br/>';
-    $frm_str .='<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="resIds" id="resIds" value="'. $values_str .'" />';
-    $frm_str .='</form>';
-    $frm_str .='</div>';
-    $frm_str .='<div align="center">';
-    $frm_str .=' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="actionValidation(\''.$path_to_script.'&page=Ajax_validation&type=acknowledgement&reference='.$values_str.'\', \''. $_SESSION['urlV2Basket']['userId'] .'\', \''. $_SESSION['urlV2Basket']['groupIdSer'] .'\', \''. $_SESSION['urlV2Basket']['basketId'] .'\');" />';
-    $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-
-    return addslashes($frm_str);
-}
diff --git a/modules/export_seda/check_reply.php b/modules/export_seda/check_reply.php
deleted file mode 100755
index 1bb340b5830db755cbf0bcb0adaad153d4db9bb4..0000000000000000000000000000000000000000
--- a/modules/export_seda/check_reply.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-
-/**
- * Copyright Maarch since 2008 under licence GPLv3.
- * See LICENCE.txt file at the root folder for more details.
- * This file is part of Maarch software.
- *
- */
-
-/**
- * @brief reply letter
- * @author dev@maarch.org
- * @ingroup export seda
- */
-
-/**
- * $confirm  bool true
- */
-$confirm = true;
-
-/**
- * $etapes  array Contains only one etap, the status modification
- */
-
-$confirm = false;
-$etapes = array('form');
-$frm_width='285px';
-$frm_height = 'auto';
-
-function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode)
-{
-    $res_id = $values[0];
-    $db = new Database();
-    $labelAction = '';
-    if ($id_action <> '') {
-        $stmt = $db->query("SELECT label_action FROM actions WHERE id = ?", array($id_action));
-        $resAction = $stmt->fetchObject();
-        $labelAction = functions::show_string($resAction->label_action);
-    }
-
-    $values_str = '';
-    if (empty($_SESSION['stockCheckbox'])) {
-        for ($i = 0; $i < count($values); $i++) {
-            $values_str .= $values[$i] . ', ';
-        }
-    } else {
-        for ($i = 0; $i < count($_SESSION['stockCheckbox']); $i++) {
-            $values_str .= $_SESSION['stockCheckbox'][$i] . ', ';
-        }
-    }
-    $path_to_script = $_SESSION['config']['businessappurl']."index.php?display=true&module=export_seda";
-
-    $values_str = preg_replace('/, $/', '', $values_str);
-    $frm_str ='<center style="font-size:15px;">'._ACTION_CONFIRM.'<br/><br/><b>'.$labelAction.' ?</b></center><br/>';
-    $frm_str .='<div id="form2" style="border:none;">';
-    $frm_str .= '<form name="frm_redirect_dep" id="frm_redirect_dep" method="post" class="forms" action="#">';
-    $frm_str .= '<input type="hidden" name="chosen_action" id="chosen_action" value="end_action" />';
-    $frm_str .= '<input type="hidden" name="resIds" id="resIds" value="'. $values_str .'" />';
-    $frm_str .='</form>';
-    $frm_str .='</div>';
-    $frm_str .='<div align="center">';
-    $frm_str .=' <input type="button" name="redirect_dep" value="'._VALIDATE.'" id="redirect_dep" class="button" onclick="actionValidation(\''.$path_to_script.'&page=Ajax_validation&type=reply&reference='.$values_str.'\', \''. $_SESSION['urlV2Basket']['userId'] .'\', \''. $_SESSION['urlV2Basket']['groupIdSer'] .'\', \''. $_SESSION['urlV2Basket']['basketId'] .'\');" />';
-    $frm_str .=' <input type="button" name="cancel" id="cancel" class="button"  value="'._CANCEL.'" onclick="pile_actions.action_pop();actions_status.action_pop();destroyModal(\'modal_'.$id_action.'\');"/>';
-    $frm_str .='</div>';
-
-    return addslashes($frm_str);
-}
diff --git a/modules/export_seda/xml/config.xml b/modules/export_seda/xml/config.xml
index ba452e0304e364f2b444afe335d15af36d39b81d..6cd347c7c2b14a1f54ae8cbc358ed7f8b2b6a0bf 100755
--- a/modules/export_seda/xml/config.xml
+++ b/modules/export_seda/xml/config.xml
@@ -3,24 +3,48 @@
     <CONFIG>
         <name>export_seda</name>
         <comment>_EXPORT_SEDA_COMMENT</comment>
-        <file_prefix>seda</file_prefix>
         <loaded>true</loaded>
         <sae>MaarchRM</sae>
-        <token>phdF9WkJuTKkDuPXoqDZuCFEQT7En7YqsVROsdD1HoNZV7jD5+XyCrrA61NWmmXVWU7AR5Sw+wq9eazIrIiGnLNDPB6BqMMum8fauclhcR2nklsEdTlveHjcGp/WIDlQ</token>
-        <urlSAEService>https://demo-ap.maarchrm.com</urlSAEService>
-        <urlSAE>https://demo-ap.maarchrm.com/transfer/sent</urlSAE>
-        <directoryMessage>/tmp/</directoryMessage>
+        <token>phdF9WkJuTKkDuPXoqDZuCFEQT7En7YqsVROsdD1HoNZV7jD5+XyCmlXwiQKoUdiii3QV4pIbPXC66kM8wxQUgL74LW6+dEf0buKoauGyVd8btoSWBK7M3Jx5T+SdRzp</token>
+        <urlSAEService>http://10.2.95.79:1506</urlSAEService>
         <senderOrgRegNumber>org_987654321_DGS_SA</senderOrgRegNumber>
         <accessRuleCode>AR039</accessRuleCode>
-        <deleteData>true</deleteData>
         <certificateSSL></certificateSSL>
+        <userAgent>service</userAgent>
     </CONFIG>
-    <TABLENAME/>
-    <HISTORY>
-        <sedaup>true</sedaup>
-        <sedaadd>true</sedaadd>
-        <sedadel>true</sedadel>
-    </HISTORY>
+    <externalSAE>
+        <id>otherSAE</id>
+        <retentionRules>
+            <retentionRule>
+                <id>id1</id>
+                <label>label1</label>
+            </retentionRule>
+            <retentionRule>
+                <id>id2</id>
+                <label>label2</label>
+            </retentionRule>
+        </retentionRules>
+        <archiveEntities>
+            <archiveEntity>
+                <id>id1</id>
+                <label>label1</label>
+            </archiveEntity>
+            <archiveEntity>
+                <id>id2</id>
+                <label>label2</label>
+            </archiveEntity>
+        </archiveEntities>
+        <archivalAgreements>
+            <archivalAgreement>
+                <id>id1</id>
+                <label>label1</label>
+            </archivalAgreement>
+            <archivalAgreement>
+                <id>id2</id>
+                <label>label2</label>
+            </archivalAgreement>
+        </archivalAgreements>
+    </externalSAE>
     <M2M>
         <gec>maarch_courrier</gec>
     </M2M>
diff --git a/sql/140_to_151.sql b/sql/140_to_151.sql
deleted file mode 100755
index c4a8266d64cecac843ad9ac628cbd7b2d8da7dd9..0000000000000000000000000000000000000000
--- a/sql/140_to_151.sql
+++ /dev/null
@@ -1,819 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
---        THIS SCRIPT IS USE TO PASS FROM MAARCH 1.4 TO MAARCH 1.5.1        --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
-
--- ************************************************************************* --
---                               ALL VIEWS DROP                              --
--- ************************************************************************* --
-
-DROP VIEW IF EXISTS view_postindexing;
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS res_view_business;
-DROP VIEW IF EXISTS res_view;
-DROP VIEW IF EXISTS view_contacts;
-DROP VIEW IF EXISTS res_view_attachments;
-
--- ************************************************************************* --
---                               MULTICONTACTS                               --
--- ************************************************************************* --
-
--- multicontacts
-DROP TABLE IF EXISTS contacts_res;
-CREATE TABLE contacts_res
-(
-  coll_id character varying(32) NOT NULL,
-  res_id bigint NOT NULL,
-  contact_id character varying(128) NOT NULL,
-  address_id bigint NOT NULL
-);
-
--- ************************************************************************* --
---                          NEW CONTACTS MANAGEMENTS                         --
--- ************************************************************************* --
-
--- Contact types
-DROP TABLE IF EXISTS contact_types;
-DROP SEQUENCE IF EXISTS contact_types_id_seq;
-
-CREATE SEQUENCE contact_types_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 100
-  CACHE 1;
-
-CREATE TABLE contact_types 
-(
-    id bigint NOT NULL DEFAULT nextval('contact_types_id_seq'::regclass),
-    label character varying(255) NOT NULL,
-    can_add_contact character varying(1) NOT NULL DEFAULT 'Y'::character varying,
-    contact_target character varying(50),
-    CONSTRAINT contact_types_pkey PRIMARY KEY  (id)
-) WITH (OIDS=FALSE);
-
--- Contacts v2
-DROP TABLE IF EXISTS contacts_v2;
-DROP SEQUENCE IF EXISTS contact_v2_id_seq;
-
-CREATE SEQUENCE contact_v2_id_seq
-  INCREMENT 1
-  MINVALUE 14
-  MAXVALUE 9223372036854775807
-  START 200
-  CACHE 1;
-
-CREATE TABLE contacts_v2 
-(
-    contact_id bigint NOT NULL DEFAULT nextval('contact_v2_id_seq'::regclass),
-    contact_type bigint NOT NULL,
-    is_corporate_person character(1) DEFAULT 'Y'::bpchar,
-    society character varying(255),
-    society_short character varying(32),
-    firstname character varying(255),
-    lastname character varying(255),
-    title character varying(255),
-    function character varying(255),
-    other_data text,
-    user_id character varying(255) NOT NULL,
-    entity_id character varying(32) NOT NULL,
-    creation_date timestamp without time zone NOT NULL,
-    update_date timestamp without time zone,
-    enabled character varying(1) NOT NULL DEFAULT 'Y'::bpchar,
-    CONSTRAINT contacts_v2_pkey PRIMARY KEY  (contact_id)
-) WITH (OIDS=FALSE);
-
--- Contact purposes
-DROP TABLE IF EXISTS contact_purposes;
-DROP SEQUENCE IF EXISTS contact_purposes_id_seq;
-
-CREATE SEQUENCE contact_purposes_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 100
-  CACHE 1;
-
-CREATE TABLE contact_purposes 
-(
-    id bigint NOT NULL DEFAULT nextval('contact_purposes_id_seq'::regclass),
-    label character varying(255) NOT NULL,
-    CONSTRAINT contact_purposes_pkey PRIMARY KEY  (id)
-) WITH (OIDS=FALSE);
-
--- Contact addresses
-DROP TABLE IF EXISTS contact_addresses;
-DROP SEQUENCE IF EXISTS contact_addresses_id_seq;
-
-CREATE SEQUENCE contact_addresses_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 100
-  CACHE 1;
-
-CREATE TABLE contact_addresses 
-(
-    id bigint NOT NULL DEFAULT nextval('contact_addresses_id_seq'::regclass),
-    contact_id bigint NOT NULL,
-    contact_purpose_id bigint DEFAULT 1,
-    departement character varying(255),
-    firstname character varying(255),
-    lastname character varying(255),
-    title character varying(255),
-    function character varying(255),
-    occupancy character varying(1024),
-    address_num character varying(32)  ,
-    address_street character varying(255),
-    address_complement character varying(255),
-    address_town character varying(255),
-    address_postal_code character varying(255),
-    address_country character varying(255),
-    phone character varying(20),
-    email character varying(255),
-    website character varying(255),
-    salutation_header character varying(255),
-    salutation_footer character varying(255),
-    other_data character varying(255),
-    user_id character varying(255) NOT NULL,
-    entity_id character varying(32) NOT NULL,
-    is_private character(1) NOT NULL DEFAULT 'N'::bpchar,
-    enabled character varying(1) NOT NULL DEFAULT 'Y'::bpchar,
-    CONSTRAINT contact_addresses_pkey PRIMARY KEY  (id)
-) WITH (OIDS=FALSE);
-
-
--- ************************************************************************* --
---                               ACTIONS IN RELATION WITH CATEGORIES         --
--- ************************************************************************* --
-
-
--- actions / category
-ALTER TABLE actions DROP COLUMN IF EXISTS category_id; 
---ALTER TABLE actions ADD category_id character varying(255);
-
-DROP TABLE IF EXISTS actions_categories;
-CREATE TABLE actions_categories
-(
-  action_id bigint NOT NULL,
-  category_id character varying(255) NOT NULL,
-  CONSTRAINT actions_categories_pkey PRIMARY KEY (action_id,category_id)
-);
-
--- ************************************************************************* --
---                  RELATION BETWEEN USERS AND BASKETS OF SECONDARY PROFILES --
--- ************************************************************************* --
-
-DROP TABLE IF EXISTS user_baskets_secondary;
-DROP SEQUENCE IF EXISTS user_baskets_secondary_seq;
-CREATE SEQUENCE user_baskets_secondary_seq
-INCREMENT 1
-MINVALUE 1
-MAXVALUE 9223372036854775807
-START 1
-CACHE 1;
-
-CREATE TABLE user_baskets_secondary
-(
-  system_id bigint NOT NULL DEFAULT nextval('user_baskets_secondary_seq'::regclass),
-  user_id character varying(128) NOT NULL,
-  group_id character varying(32) NOT NULL,
-  basket_id character varying(32) NOT NULL,
-  CONSTRAINT user_baskets_secondary_pkey PRIMARY KEY (system_id)
-);
-
--- ************************************************************************* --
---                                VIEWED MAIL                                --
--- ************************************************************************* --
-
-DROP TABLE IF EXISTS res_mark_as_read;
-CREATE TABLE res_mark_as_read
-(
-  coll_id character varying(32),
-  res_id bigint,
-  user_id character varying(32),
-  basket_id character varying(32)
-);
-
--- ************************************************************************* --
---                               NEW COLUMNS IN EXTENSIONS TABLE             --
--- ************************************************************************* --
-
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS address_id;
-ALTER TABLE mlb_coll_ext ADD address_id bigint;
-
-ALTER TABLE business_coll_ext DROP COLUMN IF EXISTS address_id;
-ALTER TABLE business_coll_ext ADD address_id bigint;
-
-
--- ************************************************************************* --
---                               NEW COLUMNS INTO TABLES                     --
--- ************************************************************************* --
-
-ALTER TABLE templates DROP COLUMN IF EXISTS template_target; 
-ALTER TABLE templates ADD template_target character varying(255);
-
-ALTER TABLE entities DROP COLUMN IF EXISTS entity_path;
-ALTER TABLE entities ADD entity_path character varying(2048);
-
-ALTER TABLE entities DROP COLUMN IF EXISTS ldap_id;
-ALTER TABLE entities ADD ldap_id character varying(255);
-
-ALTER TABLE baskets DROP COLUMN IF EXISTS basket_order;
-ALTER TABLE baskets ADD basket_order integer;
-
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS is_multicontacts; 
-ALTER TABLE mlb_coll_ext ADD is_multicontacts character(1);
-
-ALTER TABLE res_x DROP COLUMN IF EXISTS reference_number; 
-ALTER TABLE res_x ADD reference_number character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_x DROP COLUMN IF EXISTS locker_user_id; 
-ALTER TABLE res_x ADD locker_user_id character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_x DROP COLUMN IF EXISTS locker_time; 
-ALTER TABLE res_x ADD locker_time timestamp without time zone;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS reference_number; 
-ALTER TABLE res_letterbox ADD reference_number character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS locker_user_id; 
-ALTER TABLE res_letterbox ADD locker_user_id character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS locker_time; 
-ALTER TABLE res_letterbox ADD locker_time timestamp without time zone;
-
-ALTER TABLE res_business DROP COLUMN IF EXISTS reference_number; 
-ALTER TABLE res_business ADD reference_number character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_business DROP COLUMN IF EXISTS locker_user_id; 
-ALTER TABLE res_business ADD locker_user_id character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_business DROP COLUMN IF EXISTS locker_time; 
-ALTER TABLE res_business ADD locker_time timestamp without time zone;
-
-ALTER TABLE lc_stack DROP COLUMN IF EXISTS work_batch;
-ALTER TABLE lc_stack ADD COLUMN work_batch bigint;
-
-ALTER TABLE lc_stack DROP COLUMN IF EXISTS regex;
-ALTER TABLE lc_stack ADD COLUMN regex character varying(32);
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS confidentiality; 
-ALTER TABLE res_letterbox ADD confidentiality character(1);
-
-ALTER TABLE listinstance DROP COLUMN IF EXISTS process_comment;
-ALTER TABLE listinstance ADD process_comment character varying(255);
-
-ALTER TABLE listinstance DROP COLUMN IF EXISTS process_date;
-ALTER TABLE listinstance ADD process_date timestamp without time zone;
-
-ALTER TABLE listmodels DROP COLUMN IF EXISTS title;
-ALTER TABLE listmodels ADD COLUMN title varchar(255);
-
-ALTER TABLE sendmail DROP COLUMN IF EXISTS sender_email;
-ALTER TABLE sendmail ADD COLUMN sender_email varchar(255);
-
--- ALTER TABLE listmodels DROP COLUMN IF EXISTS description;
--- ALTER TABLE listmodels ADD COLUMN description varchar(255);
-
-ALTER TABLE listmodels DROP COLUMN IF EXISTS process_comment;
-ALTER TABLE listmodels ADD COLUMN process_comment varchar(255);
-
-DROP TABLE IF EXISTS listinstance_history;
-DROP SEQUENCE IF EXISTS listinstance_history_id_seq;
-CREATE SEQUENCE listinstance_history_id_seq
-INCREMENT 1
-MINVALUE 1
-MAXVALUE 9223372036854775807
-START 1
-CACHE 1;
-
-CREATE TABLE listinstance_history
-(
-listinstance_history_id bigint NOT NULL DEFAULT nextval('listinstance_history_id_seq'::regclass),
-coll_id character varying(50) NOT NULL,
-res_id bigint NOT NULL,
-updated_by_user character varying(128) NOT NULL,
-updated_date timestamp without time zone NOT NULL,
-CONSTRAINT listinstance_history_pkey PRIMARY KEY (listinstance_history_id)
-)
-WITH ( OIDS=FALSE );
-
-DROP TABLE IF EXISTS listinstance_history_details;
-DROP SEQUENCE IF EXISTS listinstance_history_details_id_seq;
-CREATE SEQUENCE listinstance_history_details_id_seq
-INCREMENT 1
-MINVALUE 1
-MAXVALUE 9223372036854775807
-START 1
-CACHE 1;
-
-CREATE TABLE listinstance_history_details
-(
-listinstance_history_details_id bigint NOT NULL DEFAULT nextval('listinstance_history_details_id_seq'::regclass),
-listinstance_history_id bigint NOT NULL,
-coll_id character varying(50) NOT NULL,
-res_id bigint NOT NULL,
-listinstance_type character varying(50) DEFAULT 'DOC'::character varying,
-sequence bigint NOT NULL,
-item_id character varying(128) NOT NULL,
-item_type character varying(255) NOT NULL,
-item_mode character varying(50) NOT NULL,
-added_by_user character varying(128) NOT NULL,
-added_by_entity character varying(50) NOT NULL,
-visible character varying(1) NOT NULL DEFAULT 'Y'::bpchar,
-viewed bigint,
-difflist_type character varying(50),
-process_date timestamp without time zone,
-process_comment character varying(255),
-CONSTRAINT listinstance_history_details_pkey PRIMARY KEY (listinstance_history_details_id)
-) WITH ( OIDS=FALSE );
-
- -- nouvelle gestion des pj
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS attachment_type; 
-ALTER TABLE res_attachments ADD attachment_type character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS dest_contact_id; 
-ALTER TABLE res_attachments ADD dest_contact_id bigint;
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS dest_address_id; 
-ALTER TABLE res_attachments ADD dest_address_id bigint;
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS updated_by; 
-ALTER TABLE res_attachments ADD updated_by character varying(128) DEFAULT NULL::character varying;
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_multicontacts; 
-ALTER TABLE res_attachments ADD is_multicontacts character(1);
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS is_multi_docservers; 
-ALTER TABLE res_attachments ADD is_multi_docservers character(1) NOT NULL DEFAULT 'N'::bpchar;
-
-ALTER TABLE templates DROP COLUMN IF EXISTS template_attachment_type; 
-ALTER TABLE templates ADD template_attachment_type character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE users DROP COLUMN IF EXISTS thumbprint;
-ALTER TABLE users ADD thumbprint text;
-
-ALTER TABLE users DROP COLUMN IF EXISTS signature_path;
-ALTER TABLE users ADD signature_path character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE users DROP COLUMN IF EXISTS signature_file_name;
-ALTER TABLE users ADD signature_file_name character varying(255) DEFAULT NULL::character varying;
-
-ALTER TABLE users DROP COLUMN IF EXISTS initials;
-ALTER TABLE users ADD COLUMN initials character varying(32);
-
-DELETE FROM status WHERE id = 'A_TRA';
-INSERT INTO status (id, label_status, is_system) VALUES ('A_TRA', 'A traiter', 'N');
-
-DELETE FROM status WHERE id = 'TRA';
-INSERT INTO status (id, label_status, is_system) VALUES ('TRA', 'Traité', 'N');
-
-DELETE FROM status WHERE id = 'OBS';
-INSERT INTO status (id, label_status, is_system) VALUES ('OBS', 'Obsolète', 'N');
-
-UPDATE status SET img_filename = 'fm-letter-status-inprogress' WHERE id = 'COU'; 
-UPDATE status SET img_filename = 'fm-letter-del' WHERE id = 'DEL'; 
-UPDATE status SET img_filename = 'fm-letter-status-end' WHERE id = 'END'; 
-UPDATE status SET img_filename = 'fm-letter-status-new' WHERE id = 'NEW'; 
-UPDATE status SET img_filename = 'fm-letter-status-rejected' WHERE id = 'RET'; 
-UPDATE status SET img_filename = 'fm-file-fingerprint' WHERE id = 'SIG'; 
-UPDATE status SET img_filename = 'fm-letter-status-rejected' WHERE id = 'UNS'; 
-UPDATE status SET img_filename = 'fm-letter-status-aval' WHERE id = 'VAL'; 
-UPDATE status SET img_filename = 'fm-letter-status-attr' WHERE id = 'INIT'; 
-UPDATE status SET img_filename = 'fm-letter-status-aval' WHERE id = 'VIS';
-
--- tumbnails
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_path;
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS tnl_filename;
-ALTER TABLE res_letterbox ADD tnl_path character varying(255) DEFAULT NULL::character varying;
-ALTER TABLE res_letterbox ADD tnl_filename character varying(255) DEFAULT NULL::character varying;
-ALTER TABLE res_business DROP COLUMN IF EXISTS tnl_path;
-ALTER TABLE res_business DROP COLUMN IF EXISTS tnl_filename;
-ALTER TABLE res_business ADD tnl_path character varying(255) DEFAULT NULL::character varying;
-ALTER TABLE res_business ADD tnl_filename character varying(255) DEFAULT NULL::character varying;
-ALTER TABLE res_x DROP COLUMN IF EXISTS tnl_path;
-ALTER TABLE res_x DROP COLUMN IF EXISTS tnl_filename;
-ALTER TABLE res_x ADD tnl_path character varying(255) DEFAULT NULL::character varying;
-ALTER TABLE res_x ADD tnl_filename character varying(255) DEFAULT NULL::character varying;
-
-DROP TABLE IF EXISTS res_version_attachments;
-DROP SEQUENCE IF EXISTS res_id_version_attachments_seq;
-
-CREATE SEQUENCE res_id_version_attachments_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 100
-  CACHE 1;
-
-CREATE TABLE res_version_attachments
-(
-  res_id bigint NOT NULL DEFAULT nextval('res_id_version_attachments_seq'::regclass),
-  title character varying(255) DEFAULT NULL::character varying,
-  subject text,
-  description text,
-  publisher character varying(255) DEFAULT NULL::character varying,
-  contributor character varying(255) DEFAULT NULL::character varying,
-  type_id bigint NOT NULL,
-  format character varying(50) NOT NULL,
-  typist character varying(128) NOT NULL,
-  creation_date timestamp without time zone NOT NULL,
-  fulltext_result character varying(10) DEFAULT NULL::character varying,
-  ocr_result character varying(10) DEFAULT NULL::character varying,
-  converter_result character varying(10) DEFAULT NULL::character varying,
-  author character varying(255) DEFAULT NULL::character varying,
-  author_name text,
-  identifier character varying(255) DEFAULT NULL::character varying,
-  source character varying(255) DEFAULT NULL::character varying,
-  doc_language character varying(50) DEFAULT NULL::character varying,
-  relation bigint,
-  coverage character varying(255) DEFAULT NULL::character varying,
-  doc_date timestamp without time zone,
-  docserver_id character varying(32) NOT NULL,
-  folders_system_id bigint,
-  arbox_id character varying(32) DEFAULT NULL::character varying,
-  path character varying(255) DEFAULT NULL::character varying,
-  filename character varying(255) DEFAULT NULL::character varying,
-  offset_doc character varying(255) DEFAULT NULL::character varying,
-  logical_adr character varying(255) DEFAULT NULL::character varying,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  filesize bigint,
-  is_paper character(1) DEFAULT NULL::bpchar,
-  page_count integer,
-  scan_date timestamp without time zone,
-  scan_user character varying(50) DEFAULT NULL::character varying,
-  scan_location character varying(255) DEFAULT NULL::character varying,
-  scan_wkstation character varying(255) DEFAULT NULL::character varying,
-  scan_batch character varying(50) DEFAULT NULL::character varying,
-  burn_batch character varying(50) DEFAULT NULL::character varying,
-  scan_postmark character varying(50) DEFAULT NULL::character varying,
-  envelop_id bigint,
-  status character varying(10) NOT NULL,
-  destination character varying(50) DEFAULT NULL::character varying,
-  approver character varying(50) DEFAULT NULL::character varying,
-  validation_date timestamp without time zone,
-  work_batch bigint,
-  origin character varying(50) DEFAULT NULL::character varying,
-  is_ingoing character(1) DEFAULT NULL::bpchar,
-  priority smallint,
-  arbatch_id bigint,
-  policy_id character varying(32),
-  cycle_id character varying(32),
-  is_multi_docservers character(1) NOT NULL DEFAULT 'N'::bpchar,
-  is_frozen character(1) NOT NULL DEFAULT 'N'::bpchar,
-  custom_t1 text,
-  custom_n1 bigint,
-  custom_f1 numeric,
-  custom_d1 timestamp without time zone,
-  custom_t2 character varying(255) DEFAULT NULL::character varying,
-  custom_n2 bigint,
-  custom_f2 numeric,
-  custom_d2 timestamp without time zone,
-  custom_t3 character varying(255) DEFAULT NULL::character varying,
-  custom_n3 bigint,
-  custom_f3 numeric,
-  custom_d3 timestamp without time zone,
-  custom_t4 character varying(255) DEFAULT NULL::character varying,
-  custom_n4 bigint,
-  custom_f4 numeric,
-  custom_d4 timestamp without time zone,
-  custom_t5 character varying(255) DEFAULT NULL::character varying,
-  custom_n5 bigint,
-  custom_f5 numeric,
-  custom_d5 timestamp without time zone,
-  custom_t6 character varying(255) DEFAULT NULL::character varying,
-  custom_d6 timestamp without time zone,
-  custom_t7 character varying(255) DEFAULT NULL::character varying,
-  custom_d7 timestamp without time zone,
-  custom_t8 character varying(255) DEFAULT NULL::character varying,
-  custom_d8 timestamp without time zone,
-  custom_t9 character varying(255) DEFAULT NULL::character varying,
-  custom_d9 timestamp without time zone,
-  custom_t10 character varying(255) DEFAULT NULL::character varying,
-  custom_d10 timestamp without time zone,
-  custom_t11 character varying(255) DEFAULT NULL::character varying,
-  custom_t12 character varying(255) DEFAULT NULL::character varying,
-  custom_t13 character varying(255) DEFAULT NULL::character varying,
-  custom_t14 character varying(255) DEFAULT NULL::character varying,
-  custom_t15 character varying(255) DEFAULT NULL::character varying,
-  tablename character varying(32) DEFAULT 'res_version_attachments'::character varying,
-  initiator character varying(50) DEFAULT NULL::character varying,
-  dest_user character varying(128) DEFAULT NULL::character varying,
-  video_batch integer,
-  video_time integer,
-  video_user character varying(128) DEFAULT NULL::character varying,
-  video_date timestamp without time zone,
-  cycle_date timestamp without time zone,
-  coll_id character varying(32) NOT NULL,
-  attachment_type character varying(255) DEFAULT NULL::character varying,
-  dest_contact_id bigint,
-  dest_address_id bigint,
-  updated_by character varying(128) DEFAULT NULL::character varying,
-  is_multicontacts character(1),
-  res_id_master bigint,
-  attachment_id_master bigint,
-  CONSTRAINT res_version_attachments_pkey PRIMARY KEY (res_id)
-)
-WITH (
-  OIDS=FALSE
-);
-
-
--- ************************************************************************* --
---                               RECREATE VIEWS                              --
--- ************************************************************************* --
-
-
--- view for letterbox
-CREATE VIEW res_view_letterbox AS
-    SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id, r.policy_id, r.cycle_id, 
-    d.description AS type_label, d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
-    d.doctypes_second_level_id, dsl.doctypes_second_level_label,
-    dsl.css_style as doctype_second_level_style, r.format, r.typist,
-    r.creation_date, r.relation, r.docserver_id, r.folders_system_id,
-    f.folder_id, f.destination as folder_destination, f.is_frozen as folder_is_frozen, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize,
-    r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
-    r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
-    r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
-    r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5, f.foldertype_id, ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
-    f.status AS fold_status, f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
-    f.creation_date AS fold_creation_date, r.initiator, r.destination,
-    r.dest_user, r.confidentiality, mlb.category_id, mlb.exp_contact_id, mlb.exp_user_id,
-    mlb.dest_user_id, mlb.dest_contact_id, mlb.address_id, mlb.nature_id, mlb.alt_identifier,
-    mlb.admission_date, mlb.answer_type_bitmask, mlb.other_answer_desc,
-    mlb.process_limit_date, mlb.closing_date, mlb.alarm1_date, mlb.alarm2_date,
-    mlb.flag_notif, mlb.flag_alarm1, mlb.flag_alarm2, mlb.is_multicontacts, r.video_user, r.video_time,
-    r.video_batch, r.subject, r.identifier, r.title, r.priority, mlb.process_notes,
-	r.locker_user_id, r.locker_time,
-    ca.case_id, ca.case_label, ca.case_description, en.entity_label, en.entity_type AS entityType,
-    cont.contact_id AS contact_id,
-    cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
-    cont.society AS contact_society, u.lastname AS user_lastname,
-    u.firstname AS user_firstname, list.item_id AS dest_user_from_listinstance, list.viewed, 
-    r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment 
-    FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl,
-    (((((((((((ar_batch a RIGHT JOIN res_letterbox r ON ((r.arbatch_id = a.arbatch_id)))
-    LEFT JOIN (SELECT res_attachments.res_id_master, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master) att ON (r.res_id = att.res_id_master))
-    LEFT JOIN entities en ON (((r.destination)::text = (en.entity_id)::text)))
-    LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id)))
-    LEFT JOIN cases_res cr ON ((r.res_id = cr.res_id)))
-    LEFT JOIN mlb_coll_ext mlb ON ((mlb.res_id = r.res_id)))
-    LEFT JOIN foldertypes ft ON (((f.foldertype_id = ft.foldertype_id)
-        AND ((f.status)::text <> 'DEL'::text))))
-    LEFT JOIN cases ca ON ((cr.case_id = ca.case_id)))
-    LEFT JOIN contacts_v2 cont ON (((mlb.exp_contact_id = cont.contact_id)
-        OR (mlb.dest_contact_id = cont.contact_id))))
-    LEFT JOIN users u ON ((((mlb.exp_user_id)::text = (u.user_id)::text)
-        OR ((mlb.dest_user_id)::text = (u.user_id)::text))))
-    LEFT JOIN listinstance list ON (((r.res_id = list.res_id)
-        AND ((list.item_mode)::text = 'dest'::text))))
-    WHERE (((r.type_id = d.type_id) AND
-    (d.doctypes_first_level_id = dfl.doctypes_first_level_id))
-    AND (d.doctypes_second_level_id = dsl.doctypes_second_level_id));
-
--- view for business
-CREATE VIEW res_view_business AS
-    SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id,
-    d.description AS type_label, d.doctypes_first_level_id,
-    d.doctypes_second_level_id, dfl.doctypes_first_level_label, 
-    dfl.css_style as doctype_first_level_style,
-    dsl.doctypes_second_level_label,
-    dsl.css_style as doctype_second_level_style, r.format, r.typist,
-    r.creation_date, r.relation, r.docserver_id, r.folders_system_id,
-    f.folder_id, f.is_frozen as folder_is_frozen, r.path, r.filename, 
-    r.fingerprint, r.offset_doc, r.filesize,
-    r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
-    r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
-    r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
-    r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5, f.foldertype_id,
-    f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
-    f.status AS fold_status, f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
-    f.creation_date AS fold_creation_date, r.initiator, r.destination,
-    r.dest_user, busi.category_id, busi.contact_id, busi.address_id, busi.currency,
-	r.locker_user_id, r.locker_time,	
-    busi.net_sum, busi.tax_sum, busi.total_sum, 
-    busi.process_limit_date, busi.closing_date, busi.alarm1_date, busi.alarm2_date,
-    busi.flag_notif, busi.flag_alarm1, busi.flag_alarm2, r.video_user, r.video_time,
-    r.video_batch, r.subject, r.identifier, r.title, r.priority,
-    en.entity_label,
-    cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
-    cont.society AS contact_society, list.item_id AS dest_user_from_listinstance,  list.viewed, 
-    r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment 
-    FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_business r
-    LEFT JOIN (SELECT res_attachments.res_id_master, coll_id, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master, coll_id) att ON (r.res_id = att.res_id_master and att.coll_id = 'business_coll')
-    LEFT JOIN entities en ON ((r.destination)::text = (en.entity_id)::text)
-    LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id))
-    LEFT JOIN business_coll_ext busi ON (busi.res_id = r.res_id)
-    LEFT JOIN contacts_v2 cont ON (busi.contact_id = cont.contact_id)
-    LEFT JOIN listinstance list ON ((r.res_id = list.res_id)
-        AND ((list.item_mode)::text = 'dest'::text))
-    WHERE r.type_id = d.type_id 
-    AND d.doctypes_first_level_id = dfl.doctypes_first_level_id
-    AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-
-CREATE VIEW res_view AS
- SELECT r.tablename, r.is_multi_docservers, r.res_id, r.title, r.subject, r.page_count, r.identifier, r.doc_date, r.type_id,
- d.description AS type_label, d.doctypes_first_level_id, dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
- d.doctypes_second_level_id, dsl.doctypes_second_level_label, dsl.css_style as doctype_second_level_style,
- r.format, r.typist, r.creation_date, r.relation, r.docserver_id,
- r.folders_system_id, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize, r.status,
- r.work_batch, r.arbatch_id, r.arbox_id,  r.is_paper, r.scan_date, r.scan_user,r.scan_location,r.scan_wkstation,
- r.scan_batch,r.doc_language,r.description,r.source,r.initiator,r.destination,r.dest_user,r.policy_id,r.cycle_id,r.cycle_date,
- r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2, r.custom_t3 AS doc_custom_t3,
- r.custom_t4 AS doc_custom_t4, r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
- r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8, r.custom_t9 AS doc_custom_t9,
- r.custom_t10 AS doc_custom_t10, r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
- r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14, r.custom_t15 AS doc_custom_t15,
- r.custom_d1 AS doc_custom_d1, r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
- r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5, r.custom_d6 AS doc_custom_d6,
- r.custom_d7 AS doc_custom_d7, r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
- r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1, r.custom_n2 AS doc_custom_n2,
- r.custom_n3 AS doc_custom_n3, r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
- r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2, r.custom_f3 AS doc_custom_f3,
- r.custom_f4 AS doc_custom_f4, r.custom_f5 AS doc_custom_f5, r.is_frozen as res_is_frozen,  
- r.reference_number, r.locker_user_id, r.locker_time
-   FROM  doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_x r
-   WHERE r.type_id = d.type_id
-   AND d.doctypes_first_level_id = dfl.doctypes_first_level_id
-   AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-
---view for postindexing
-CREATE VIEW view_postindexing AS
-SELECT res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text AS user_name, res_view_letterbox.video_batch, res_view_letterbox.video_time, count(res_view_letterbox.res_id) AS count_documents, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text AS folder_full_label, folders.video_status
-FROM res_view_letterbox
-LEFT JOIN users ON res_view_letterbox.video_user::text = users.user_id::text
-LEFT JOIN folders ON folders.folders_system_id = res_view_letterbox.folders_system_id
-WHERE res_view_letterbox.video_batch IS NOT NULL
-GROUP BY res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text, res_view_letterbox.video_batch, res_view_letterbox.video_time, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text, folders.video_status;
-
-
---view for contacts_v2
-CREATE VIEW view_contacts AS 
- SELECT c.contact_id, c.contact_type, c.is_corporate_person, c.society, c.society_short, c.firstname AS contact_firstname
-, c.lastname AS contact_lastname, c.title AS contact_title, c.function AS contact_function, c.other_data AS contact_other_data
-, c.user_id AS contact_user_id, c.entity_id AS contact_entity_id, c.creation_date, c.update_date, c.enabled AS contact_enabled, ca.id AS ca_id
-, ca.contact_purpose_id, ca.departement, ca.firstname, ca.lastname, ca.title, ca.function, ca.occupancy
-, ca.address_num, ca.address_street, ca.address_complement, ca.address_town, ca.address_postal_code, ca.address_country
-, ca.phone, ca.email, ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private, ca.enabled
-, cp.label as contact_purpose_label, ct.label as contact_type_label
-   FROM contacts_v2 c
-   RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id
-   LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id
-   LEFT JOIN contact_types ct ON c.contact_type = ct.id;
-
--- view for attachments
-CREATE VIEW res_view_attachments AS
-  SELECT '0' as res_id, res_id as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-  creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-  doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-  filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-  scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-  envelop_id, status, destination, approver, validation_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master
-  FROM res_version_attachments
-  UNION ALL
-  SELECT res_id, '0' as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-  creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-  doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-  filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-  scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-  envelop_id, status, destination, approver, validation_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0'
-  FROM res_attachments;
-
-   
-
--- ************************************************************************* --
---                               DATABASE VERSION                            --
--- ************************************************************************* --
-
-
-
-UPDATE parameters SET param_value_int = 151 where id='database_version';
-
-
-
--- ************************************************************************* --
---                               DATA MIGRATION                              --
--- ************************************************************************* --
-
--- confidentiality
-UPDATE res_letterbox SET confidentiality = 'N';
-
--- contacts_v2
-INSERT INTO contacts_v2 (contact_id, contact_type, is_corporate_person, society, society_short,firstname,lastname,title,function,other_data,user_id,entity_id,creation_date,update_date,enabled)
-SELECT contact_id, '1', is_corporate_person, society, '', firstname, lastname, title,function, other_data,'superadmin','',CURRENT_DATE,CURRENT_DATE,enabled FROM contacts;
-
-INSERT INTO contact_addresses (contact_id, contact_purpose_id, departement,firstname,lastname,title,function,occupancy,address_num,address_street, address_complement, address_town, address_postal_code,address_country,phone,email,website,salutation_header,salutation_footer,other_data,user_id,entity_id,is_private, enabled)
-SELECT contact_id,'1','','','','','','',address_num,address_street,address_complement,address_town,address_postal_code,address_country,phone,email,'','','','','superadmin','',is_private,enabled from contacts;
-
-INSERT INTO contact_purposes (id,label) VALUES ('1','Adresse Principale');
-
-INSERT INTO contact_types (id,label,can_add_contact,contact_target) VALUES ('1','Courriers', 'Y', 'both');
-
-UPDATE mlb_coll_ext m SET address_id = adr.id FROM contact_addresses adr WHERE m.exp_contact_id = adr.contact_id OR m.dest_contact_id = adr.contact_id;
-
--- attachments
-UPDATE res_attachments SET relation = 1, attachment_type='response_project';
-
-
--- templates
-UPDATE templates SET template_target = 'attachments', template_attachment_type = 'response_project';
-
-UPDATE templates SET template_target = 'notifications', template_attachment_type = NULL WHERE lower(template_label) LIKE '%notification%';
-
--- listmodels
-UPDATE listmodels SET title=description, description='';
-
--- passwords SHA512
-UPDATE users SET password = '65d1d802c2c5e7e9035c5cef3cfc0902b6d0b591bfa85977055290736bbfcdd7e19cb7cfc9f980d0c815bbf7fe329a4efd8da880515ba520b22c0aa3a96514cc', change_password = 'Y' WHERE user_id != 'superadmin';
-UPDATE users SET password = '964a5502faec7a27f63ab5f7bddbe1bd8a685616a90ffcba633b5ad404569bd8fed4693cc00474a4881f636f3831a3e5a36bda049c568a89cfe54b1285b0c13e' WHERE user_id = 'superadmin';
-
--- Docservers for thumbnails
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled, is_container, container_max_number, is_compressed, compression_mode, is_meta, meta_template, is_logged, log_template, is_signed, fingerprint_mode) VALUES ('TNL', 'Thumbnails', 'Y', 'N', 0, 'N', 'NONE', 'N', 'NONE', 'N', 'NONE', 'Y', 'NONE');
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) VALUES ('TNL', 'TNL', 'Server for thumbnails of documents', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/thumbnails_mlb/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'letterbox_coll', 11, 'NANTERRE', 3);
-
---Add service associate_folder by default
-INSERT INTO usergroups_services(group_id,service_id)
-SELECT group_id,'associate_folder' from usergroups;
diff --git a/sql/151.sql b/sql/151.sql
deleted file mode 100755
index 473268771254284acd4c4537dd58f24a95364142..0000000000000000000000000000000000000000
--- a/sql/151.sql
+++ /dev/null
@@ -1,317 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
---        THIS SCRIPT IS USE TO PASS FROM MAARCH 1.5 TO MAARCH 1.5.1        --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
-
--- ************************************************************************* --
---                               ALL VIEWS DROP                              --
--- ************************************************************************* --
-
-DROP VIEW IF EXISTS view_postindexing;
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS res_view_business;
-DROP VIEW IF EXISTS res_view;
-DROP VIEW IF EXISTS view_contacts;
-DROP VIEW IF EXISTS res_view_attachments;
-
-
-ALTER TABLE contact_types DROP COLUMN IF EXISTS can_add_contact;
-ALTER TABLE contact_types DROP COLUMN IF EXISTS contact_target;
-ALTER TABLE contact_types ADD COLUMN can_add_contact character varying(1) NOT NULL DEFAULT 'Y'::character varying, 
-ADD COLUMN contact_target character varying(50);
-
--- ************************************************************************* --
---                                VIEWED MAIL                                --
--- ************************************************************************* --
-
-DROP TABLE IF EXISTS res_mark_as_read;
-CREATE TABLE res_mark_as_read
-(
-  coll_id character varying(32),
-  res_id bigint,
-  user_id character varying(32),
-  basket_id character varying(32)
-);
-
-
-ALTER TABLE entities DROP COLUMN IF EXISTS ldap_id;
-ALTER TABLE entities ADD ldap_id character varying(255);
-
-ALTER TABLE baskets DROP COLUMN IF EXISTS basket_order;
-ALTER TABLE baskets ADD basket_order integer;
-
-ALTER TABLE sendmail DROP COLUMN IF EXISTS sender_email;
-ALTER TABLE sendmail ADD COLUMN sender_email varchar(255);
-
-ALTER TABLE users DROP COLUMN IF EXISTS initials;
-ALTER TABLE users ADD COLUMN initials character varying(32);
-
-
--- ************************************************************************* --
---                               RECREATE VIEWS                              --
--- ************************************************************************* --
-
--- view for letterbox
-CREATE VIEW res_view_letterbox AS
-    SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id, r.policy_id, r.cycle_id, 
-    d.description AS type_label, d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
-    d.doctypes_second_level_id, dsl.doctypes_second_level_label,
-    dsl.css_style as doctype_second_level_style, r.format, r.typist,
-    r.creation_date, r.relation, r.docserver_id, r.folders_system_id,
-    f.folder_id, f.destination as folder_destination, f.is_frozen as folder_is_frozen, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize,
-    r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
-    r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
-    r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
-    r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5, f.foldertype_id, ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
-    f.status AS fold_status, f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
-    f.creation_date AS fold_creation_date, r.initiator, r.destination,
-    r.dest_user, r.confidentiality, mlb.category_id, mlb.exp_contact_id, mlb.exp_user_id,
-    mlb.dest_user_id, mlb.dest_contact_id, mlb.address_id, mlb.nature_id, mlb.alt_identifier,
-    mlb.admission_date, mlb.answer_type_bitmask, mlb.other_answer_desc,
-    mlb.process_limit_date, mlb.closing_date, mlb.alarm1_date, mlb.alarm2_date,
-    mlb.flag_notif, mlb.flag_alarm1, mlb.flag_alarm2, mlb.is_multicontacts, r.video_user, r.video_time,
-    r.video_batch, r.subject, r.identifier, r.title, r.priority, mlb.process_notes,
-	r.locker_user_id, r.locker_time,
-    ca.case_id, ca.case_label, ca.case_description, en.entity_label, en.entity_type AS entityType,
-    cont.contact_id AS contact_id,
-    cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
-    cont.society AS contact_society, u.lastname AS user_lastname,
-    u.firstname AS user_firstname, list.item_id AS dest_user_from_listinstance, list.viewed, 
-    r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment 
-    FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl,
-    (((((((((((ar_batch a RIGHT JOIN res_letterbox r ON ((r.arbatch_id = a.arbatch_id)))
-    LEFT JOIN (SELECT res_attachments.res_id_master, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master) att ON (r.res_id = att.res_id_master))
-    LEFT JOIN entities en ON (((r.destination)::text = (en.entity_id)::text)))
-    LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id)))
-    LEFT JOIN cases_res cr ON ((r.res_id = cr.res_id)))
-    LEFT JOIN mlb_coll_ext mlb ON ((mlb.res_id = r.res_id)))
-    LEFT JOIN foldertypes ft ON (((f.foldertype_id = ft.foldertype_id)
-        AND ((f.status)::text <> 'DEL'::text))))
-    LEFT JOIN cases ca ON ((cr.case_id = ca.case_id)))
-    LEFT JOIN contacts_v2 cont ON (((mlb.exp_contact_id = cont.contact_id)
-        OR (mlb.dest_contact_id = cont.contact_id))))
-    LEFT JOIN users u ON ((((mlb.exp_user_id)::text = (u.user_id)::text)
-        OR ((mlb.dest_user_id)::text = (u.user_id)::text))))
-    LEFT JOIN listinstance list ON (((r.res_id = list.res_id)
-        AND ((list.item_mode)::text = 'dest'::text))))
-    WHERE (((r.type_id = d.type_id) AND
-    (d.doctypes_first_level_id = dfl.doctypes_first_level_id))
-    AND (d.doctypes_second_level_id = dsl.doctypes_second_level_id));
-
--- view for business
-CREATE VIEW res_view_business AS
-    SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id,
-    d.description AS type_label, d.doctypes_first_level_id,
-    d.doctypes_second_level_id, dfl.doctypes_first_level_label, 
-    dfl.css_style as doctype_first_level_style,
-    dsl.doctypes_second_level_label,
-    dsl.css_style as doctype_second_level_style, r.format, r.typist,
-    r.creation_date, r.relation, r.docserver_id, r.folders_system_id,
-    f.folder_id, f.is_frozen as folder_is_frozen, r.path, r.filename, 
-    r.fingerprint, r.offset_doc, r.filesize,
-    r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
-    r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
-    r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
-    r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5, f.foldertype_id,
-    f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
-    f.status AS fold_status, f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
-    f.creation_date AS fold_creation_date, r.initiator, r.destination,
-    r.dest_user, busi.category_id, busi.contact_id, busi.address_id, busi.currency,
-	r.locker_user_id, r.locker_time,	
-    busi.net_sum, busi.tax_sum, busi.total_sum, 
-    busi.process_limit_date, busi.closing_date, busi.alarm1_date, busi.alarm2_date,
-    busi.flag_notif, busi.flag_alarm1, busi.flag_alarm2, r.video_user, r.video_time,
-    r.video_batch, r.subject, r.identifier, r.title, r.priority,
-    en.entity_label,
-    cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
-    cont.society AS contact_society, list.item_id AS dest_user_from_listinstance,  list.viewed, 
-    r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment 
-    FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_business r
-    LEFT JOIN (SELECT res_attachments.res_id_master, coll_id, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master, coll_id) att ON (r.res_id = att.res_id_master and att.coll_id = 'business_coll')
-    LEFT JOIN entities en ON ((r.destination)::text = (en.entity_id)::text)
-    LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id))
-    LEFT JOIN business_coll_ext busi ON (busi.res_id = r.res_id)
-    LEFT JOIN contacts_v2 cont ON (busi.contact_id = cont.contact_id)
-    LEFT JOIN listinstance list ON ((r.res_id = list.res_id)
-        AND ((list.item_mode)::text = 'dest'::text))
-    WHERE r.type_id = d.type_id 
-    AND d.doctypes_first_level_id = dfl.doctypes_first_level_id
-    AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-
-CREATE VIEW res_view AS
- SELECT r.tablename, r.is_multi_docservers, r.res_id, r.title, r.subject, r.page_count, r.identifier, r.doc_date, r.type_id,
- d.description AS type_label, d.doctypes_first_level_id, dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
- d.doctypes_second_level_id, dsl.doctypes_second_level_label, dsl.css_style as doctype_second_level_style,
- r.format, r.typist, r.creation_date, r.relation, r.docserver_id,
- r.folders_system_id, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize, r.status,
- r.work_batch, r.arbatch_id, r.arbox_id,  r.is_paper, r.scan_date, r.scan_user,r.scan_location,r.scan_wkstation,
- r.scan_batch,r.doc_language,r.description,r.source,r.initiator,r.destination,r.dest_user,r.policy_id,r.cycle_id,r.cycle_date,
- r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2, r.custom_t3 AS doc_custom_t3,
- r.custom_t4 AS doc_custom_t4, r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
- r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8, r.custom_t9 AS doc_custom_t9,
- r.custom_t10 AS doc_custom_t10, r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
- r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14, r.custom_t15 AS doc_custom_t15,
- r.custom_d1 AS doc_custom_d1, r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
- r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5, r.custom_d6 AS doc_custom_d6,
- r.custom_d7 AS doc_custom_d7, r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
- r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1, r.custom_n2 AS doc_custom_n2,
- r.custom_n3 AS doc_custom_n3, r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
- r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2, r.custom_f3 AS doc_custom_f3,
- r.custom_f4 AS doc_custom_f4, r.custom_f5 AS doc_custom_f5, r.is_frozen as res_is_frozen,  
- r.reference_number, r.locker_user_id, r.locker_time
-   FROM  doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_x r
-   WHERE r.type_id = d.type_id
-   AND d.doctypes_first_level_id = dfl.doctypes_first_level_id
-   AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-
---view for postindexing
-CREATE VIEW view_postindexing AS
-SELECT res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text AS user_name, res_view_letterbox.video_batch, res_view_letterbox.video_time, count(res_view_letterbox.res_id) AS count_documents, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text AS folder_full_label, folders.video_status
-FROM res_view_letterbox
-LEFT JOIN users ON res_view_letterbox.video_user::text = users.user_id::text
-LEFT JOIN folders ON folders.folders_system_id = res_view_letterbox.folders_system_id
-WHERE res_view_letterbox.video_batch IS NOT NULL
-GROUP BY res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text, res_view_letterbox.video_batch, res_view_letterbox.video_time, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text, folders.video_status;
-
-
---view for contacts_v2
-CREATE VIEW view_contacts AS 
- SELECT c.contact_id, c.contact_type, c.is_corporate_person, c.society, c.society_short, c.firstname AS contact_firstname
-, c.lastname AS contact_lastname, c.title AS contact_title, c.function AS contact_function, c.other_data AS contact_other_data
-, c.user_id AS contact_user_id, c.entity_id AS contact_entity_id, c.creation_date, c.update_date, c.enabled AS contact_enabled, ca.id AS ca_id
-, ca.contact_purpose_id, ca.departement, ca.firstname, ca.lastname, ca.title, ca.function, ca.occupancy
-, ca.address_num, ca.address_street, ca.address_complement, ca.address_town, ca.address_postal_code, ca.address_country
-, ca.phone, ca.email, ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private, ca.enabled
-, cp.label as contact_purpose_label, ct.label as contact_type_label
-   FROM contacts_v2 c
-   RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id
-   LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id
-   LEFT JOIN contact_types ct ON c.contact_type = ct.id;
-
--- view for attachments
-CREATE VIEW res_view_attachments AS
-  SELECT '0' as res_id, res_id as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-  creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-  doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-  filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-  scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-  envelop_id, status, destination, approver, validation_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master
-  FROM res_version_attachments
-  UNION ALL
-  SELECT res_id, '0' as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-  creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-  doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-  filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-  scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-  envelop_id, status, destination, approver, validation_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0'
-  FROM res_attachments;
-
-   
-
-
--- ************************************************************************* --
---                               DATABASE VERSION                            --
--- ************************************************************************* --
-
-
-
-UPDATE parameters SET param_value_int = 151 where id='database_version';
-
-
-UPDATE contact_types set can_add_contact = 'Y' where id = '1';
-UPDATE contact_types set contact_target = 'both' where id = '1';
-
-
--- passwords SHA512
-UPDATE users SET password = '65d1d802c2c5e7e9035c5cef3cfc0902b6d0b591bfa85977055290736bbfcdd7e19cb7cfc9f980d0c815bbf7fe329a4efd8da880515ba520b22c0aa3a96514cc', change_password = 'Y' WHERE user_id != 'superadmin';
-UPDATE users SET password = '964a5502faec7a27f63ab5f7bddbe1bd8a685616a90ffcba633b5ad404569bd8fed4693cc00474a4881f636f3831a3e5a36bda049c568a89cfe54b1285b0c13e' WHERE user_id = 'superadmin';
-
--- Docservers for thumbnails
-INSERT INTO docserver_types (docserver_type_id, docserver_type_label, enabled, is_container, container_max_number, is_compressed, compression_mode, is_meta, meta_template, is_logged, log_template, is_signed, fingerprint_mode) VALUES ('TNL', 'Thumbnails', 'Y', 'N', 0, 'N', 'NONE', 'N', 'NONE', 'N', 'NONE', 'Y', 'NONE');
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) VALUES ('TNL', 'TNL', 'Server for thumbnails of documents', 'N', 'Y', 50000000000, 0, '/opt/maarch/docservers/thumbnails_mlb/', NULL, NULL, NULL, '2015-03-16 14:47:49.197164', NULL, 'letterbox_coll', 11, 'NANTERRE', 3);
-
---Add service associate_folder by default
-INSERT INTO usergroups_services(group_id,service_id)
-SELECT group_id,'associate_folder' from usergroups;
\ No newline at end of file
diff --git a/sql/160.sql b/sql/160.sql
deleted file mode 100755
index ad76cd61b9112f851d64ce11e38d5813b3b5ec82..0000000000000000000000000000000000000000
--- a/sql/160.sql
+++ /dev/null
@@ -1,447 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
---        THIS SCRIPT IS USE TO PASS FROM MAARCH 1.5.1 TO MAARCH 1.6        --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
--- ************************************************************************* --
---                               ALL VIEWS DROP                              --
--- ************************************************************************* --
-
-DROP VIEW IF EXISTS view_postindexing;
-DROP VIEW IF EXISTS res_view_letterbox;
-DROP VIEW IF EXISTS res_view_business;
-DROP VIEW IF EXISTS res_view;
-DROP VIEW IF EXISTS view_contacts;
-DROP VIEW IF EXISTS res_view_attachments;
-
-
--- ************************************************************************* --
---                      NEW TABLE FOR SIGNATURE TEMPLATE                     --
--- ************************************************************************* --
-DROP TABLE IF EXISTS users_email_signatures;
-DROP SEQUENCE IF EXISTS email_signatures_id_seq;
-
-CREATE SEQUENCE email_signatures_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 7
-  CACHE 1;
-
-CREATE TABLE users_email_signatures
-(
-  id bigint NOT NULL DEFAULT nextval('email_signatures_id_seq'::regclass),
-  user_id character varying(255) NOT NULL,
-  html_body text NOT NULL,
-  title character varying NOT NULL,
-  CONSTRAINT email_signatures_pkey PRIMARY KEY (id)
-)
-WITH (
-  OIDS=FALSE
-);
-
-
--- ************************************************************************* --
---                          NEW TABLE FOR FULL TEXT PJ                       --
--- ************************************************************************* --
-DROP TABLE IF EXISTS adr_attachments;
-CREATE TABLE adr_attachments
-(
-  res_id bigint NOT NULL,
-  docserver_id character varying(32) NOT NULL,
-  path character varying(255) DEFAULT NULL::character varying,
-  filename character varying(255) DEFAULT NULL::character varying,
-  offset_doc character varying(255) DEFAULT NULL::character varying,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  adr_priority integer NOT NULL,
-  adr_type character varying(32) NOT NULL DEFAULT 'DOC'::character varying,
-  CONSTRAINT adr_attachments_pkey PRIMARY KEY (res_id, docserver_id)
-)
-WITH (OIDS=FALSE);
-
-
--- ************************************************************************* --
---                       NEW TABLE FOR THESAURUS MODULE                      --
--- ************************************************************************* --
-DROP TABLE IF EXISTS thesaurus;
-DROP TABLE IF EXISTS thesaurus_res;
-DROP SEQUENCE IF EXISTS thesaurus_id_seq;
-
-CREATE SEQUENCE thesaurus_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 1
-  CACHE 1;
-
-CREATE TABLE thesaurus
-(
-  thesaurus_id bigint NOT NULL DEFAULT nextval('thesaurus_id_seq'::regclass),
-  thesaurus_name character varying(255) NOT NULL,
-  thesaurus_description text,
-  thesaurus_name_associate character varying(255),
-  thesaurus_parent_id character varying(255),
-  creation_date timestamp without time zone,
-  used_for text,
-  CONSTRAINT thesaurus_pkey PRIMARY KEY (thesaurus_id)
-)
-WITH (
-  OIDS=FALSE
-);
-
-CREATE TABLE thesaurus_res
-(
-  res_id bigint NOT NULL,
-  thesaurus_id bigint NOT NULL
-)
-WITH (
-  OIDS=FALSE
-);
-
-
--- ************************************************************************* --
---                          NEW COLUMNS FOR NOTIFICATION                     --
--- ************************************************************************* --
-
-ALTER TABLE baskets DROP COLUMN IF EXISTS except_notif;
-ALTER TABLE baskets ADD COLUMN except_notif text default NULL;
-
-ALTER TABLE baskets DROP COLUMN IF EXISTS flag_notif;
-ALTER TABLE baskets ADD flag_notif character varying(1);
-
-
--- ************************************************************************* --
---                          NEW COLUMNS FOR MODIFICATION                     --
--- ************************************************************************* --
-
-ALTER TABLE res_letterbox DROP COLUMN IF EXISTS modification_date;
-ALTER TABLE res_letterbox ADD modification_date timestamp without time zone DEFAULT NOW();
-
-
--- ************************************************************************* --
---                     NEW COLUMNS FOR FULL AVIS MODULE                       --
--- ************************************************************************* --
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS recommendation_limit_date;
-ALTER TABLE mlb_coll_ext ADD COLUMN recommendation_limit_date timestamp without time zone default NULL;
-
-
--- ************************************************************************* --
---                           NEW COLUMNS FOR PJ                              --
--- ************************************************************************* --
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS effective_date;
-ALTER TABLE res_attachments ADD effective_date timestamp without time zone;
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_path;
-ALTER TABLE res_attachments ADD tnl_path character varying(255);
-
-ALTER TABLE res_attachments DROP COLUMN IF EXISTS tnl_filename;
-ALTER TABLE res_attachments ADD tnl_filename character varying(255);
-
-ALTER TABLE res_version_attachments DROP COLUMN IF EXISTS effective_date;
-ALTER TABLE res_version_attachments ADD effective_date timestamp without time zone;
-
-
--- ************************************************************************* --
---                           NEW COLUMNS FOR SVE                             --
--- ************************************************************************* --
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS sve_start_date;
-ALTER TABLE mlb_coll_ext ADD sve_start_date timestamp without time zone;
-
-ALTER TABLE mlb_coll_ext DROP COLUMN IF EXISTS sve_identifier;
-ALTER TABLE mlb_coll_ext ADD sve_identifier character varying(255);
-
--- ************************************************************************* --
---                               sve mlb_doctype_ext                         --
--- ************************************************************************* --
-
-ALTER TABLE mlb_doctype_ext DROP COLUMN IF EXISTS process_mode;
-ALTER TABLE mlb_doctype_ext ADD process_mode character varying(255);
-
--- ************************************************************************* --
---                           NEW COLUMNS FOR CONTACTS                        --
--- ************************************************************************* --
-
-ALTER TABLE contacts_res DROP COLUMN IF EXISTS mode;
-ALTER TABLE contacts_res ADD mode character varying NOT NULL DEFAULT 'multi'::character varying;
-
-
--- ************************************************************************* --
---                      CHANGE COLUMNS TYPE FOR NOTE                         --
--- ************************************************************************* --
-ALTER TABLE notes ALTER COLUMN date_note TYPE timestamp without time zone;
-
--- ************************************************************************* --
---                      CHANGE COLUMNS TYPE FOR SENDMAIL                     --
--- ************************************************************************* --
-ALTER TABLE sendmail ALTER COLUMN to_list TYPE text;
-ALTER TABLE sendmail ALTER COLUMN cc_list TYPE text;
-ALTER TABLE sendmail ALTER COLUMN cci_list TYPE text;
-
--- ************************************************************************* --
---                   CHANGE COLUMNS TYPE FOR NOTIFICATIONS                   --
--- ************************************************************************* --
-ALTER TABLE notifications ALTER COLUMN diffusion_properties TYPE text;
-
--- ************************************************************************* --
---                   CHANGE COLUMNS TYPE FOR CONTACTS_V2                   --
--- ************************************************************************* --
-ALTER TABLE contacts_v2 ALTER COLUMN other_data TYPE text;
-
-
--- ************************************************************************* --
---                      NOUVEAU STATUS TRANSMISSION                          --
--- ************************************************************************* --
-DELETE FROM STATUS where id ='EXP_RTURN';
-INSERT INTO status (id, label_status, is_system, is_folder_status, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES('EXP_RTURN', 'Retour attendu', 'N', 'N', '', 'apps','Y', 'Y');
-DELETE FROM STATUS where id ='NO_RTURN';
-INSERT INTO status (id, label_status, is_system, is_folder_status, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES('NO_RTURN', 'Pas de retour', 'N', 'N', '', 'apps','Y', 'Y');
-DELETE FROM STATUS where id ='RTURN';
-INSERT INTO status (id, label_status, is_system, is_folder_status, img_filename, maarch_module, can_be_searched, can_be_modified) VALUES('RTURN', 'Retourné', 'N', 'N', '', 'apps','Y', 'Y');
-
--- view for letterbox
-CREATE VIEW res_view_letterbox AS
-    SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id, r.policy_id, r.cycle_id, 
-    d.description AS type_label, d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
-    d.doctypes_second_level_id, dsl.doctypes_second_level_label,
-    dsl.css_style as doctype_second_level_style, r.format, r.typist,
-    r.creation_date, r.modification_date, r.relation, r.docserver_id, r.folders_system_id,
-    f.folder_id, f.destination as folder_destination, f.is_frozen as folder_is_frozen, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize,
-    r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
-    r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
-    r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
-    r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5, f.foldertype_id, ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
-    f.status AS fold_status, f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
-    f.creation_date AS fold_creation_date, r.initiator, r.destination,
-    r.dest_user, r.confidentiality, mlb.category_id, mlb.exp_contact_id, mlb.exp_user_id,
-    mlb.dest_user_id, mlb.dest_contact_id, mlb.address_id, mlb.nature_id, mlb.alt_identifier,
-    mlb.admission_date, mlb.answer_type_bitmask, mlb.other_answer_desc,
-    mlb.process_limit_date, mlb.closing_date, mlb.alarm1_date, mlb.alarm2_date,
-    mlb.flag_notif, mlb.flag_alarm1, mlb.flag_alarm2, mlb.is_multicontacts, r.video_user, r.video_time,
-    r.video_batch, r.subject, r.identifier, r.title, r.priority, mlb.process_notes,
-    mlb.sve_start_date, mlb.sve_identifier,
-    r.locker_user_id, r.locker_time,
-    ca.case_id, ca.case_label, ca.case_description, en.entity_label, en.entity_type AS entityType,
-    cont.contact_id AS contact_id,
-    cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
-    cont.society AS contact_society, u.lastname AS user_lastname,
-    u.firstname AS user_firstname, list.item_id AS dest_user_from_listinstance, list.viewed, 
-    r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment 
-    FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl,
-    (((((((((((ar_batch a RIGHT JOIN res_letterbox r ON ((r.arbatch_id = a.arbatch_id)))
-    LEFT JOIN (SELECT res_attachments.res_id_master, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master) att ON (r.res_id = att.res_id_master))
-    LEFT JOIN entities en ON (((r.destination)::text = (en.entity_id)::text)))
-    LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id)))
-    LEFT JOIN cases_res cr ON ((r.res_id = cr.res_id)))
-    LEFT JOIN mlb_coll_ext mlb ON ((mlb.res_id = r.res_id)))
-    LEFT JOIN foldertypes ft ON (((f.foldertype_id = ft.foldertype_id)
-        AND ((f.status)::text <> 'DEL'::text))))
-    LEFT JOIN cases ca ON ((cr.case_id = ca.case_id)))
-    LEFT JOIN contacts_v2 cont ON (((mlb.exp_contact_id = cont.contact_id)
-        OR (mlb.dest_contact_id = cont.contact_id))))
-    LEFT JOIN users u ON ((((mlb.exp_user_id)::text = (u.user_id)::text)
-        OR ((mlb.dest_user_id)::text = (u.user_id)::text))))
-    LEFT JOIN listinstance list ON (((r.res_id = list.res_id)
-        AND ((list.item_mode)::text = 'dest'::text))))
-    WHERE (((r.type_id = d.type_id) AND
-    (d.doctypes_first_level_id = dfl.doctypes_first_level_id))
-    AND (d.doctypes_second_level_id = dsl.doctypes_second_level_id));
-
--- view for business
-CREATE VIEW res_view_business AS
-    SELECT r.tablename, r.is_multi_docservers, r.res_id, r.type_id,
-    d.description AS type_label, d.doctypes_first_level_id,
-    d.doctypes_second_level_id, dfl.doctypes_first_level_label, 
-    dfl.css_style as doctype_first_level_style,
-    dsl.doctypes_second_level_label,
-    dsl.css_style as doctype_second_level_style, r.format, r.typist,
-    r.creation_date, r.relation, r.docserver_id, r.folders_system_id,
-    f.folder_id, f.is_frozen as folder_is_frozen, r.path, r.filename, 
-    r.fingerprint, r.offset_doc, r.filesize,
-    r.status, r.work_batch, r.arbatch_id, r.arbox_id, r.page_count, r.is_paper,
-    r.doc_date, r.scan_date, r.scan_user, r.scan_location, r.scan_wkstation,
-    r.scan_batch, r.doc_language, r.description, r.source, r.author, r.reference_number,
-    r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3, r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9, r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15, r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6, r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2, r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3, r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5, f.foldertype_id,
-    f.custom_t1 AS fold_custom_t1, f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3, f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5, f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7, f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9, f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11, f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13, f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15, f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2, f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4, f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6, f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8, f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10, f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2, f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4, f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1, f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3, f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5, f.is_complete AS fold_complete,
-    f.status AS fold_status, f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id, f.folder_level, f.folder_name,
-    f.creation_date AS fold_creation_date, r.initiator, r.destination,
-    r.dest_user, busi.category_id, busi.contact_id, busi.address_id, busi.currency,
-    r.locker_user_id, r.locker_time,  
-    busi.net_sum, busi.tax_sum, busi.total_sum, 
-    busi.process_limit_date, busi.closing_date, busi.alarm1_date, busi.alarm2_date,
-    busi.flag_notif, busi.flag_alarm1, busi.flag_alarm2, r.video_user, r.video_time,
-    r.video_batch, r.subject, r.identifier, r.title, r.priority,
-    en.entity_label,
-    cont.firstname AS contact_firstname, cont.lastname AS contact_lastname,
-    cont.society AS contact_society, list.item_id AS dest_user_from_listinstance,  list.viewed, 
-    r.is_frozen as res_is_frozen, COALESCE(att.count_attachment, 0::bigint) AS count_attachment 
-    FROM doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_business r
-    LEFT JOIN (SELECT res_attachments.res_id_master, coll_id, count(res_attachments.res_id_master) AS count_attachment
-        FROM res_attachments WHERE res_attachments.status <> 'DEL' GROUP BY res_attachments.res_id_master, coll_id) att ON (r.res_id = att.res_id_master and att.coll_id = 'business_coll')
-    LEFT JOIN entities en ON ((r.destination)::text = (en.entity_id)::text)
-    LEFT JOIN folders f ON ((r.folders_system_id = f.folders_system_id))
-    LEFT JOIN business_coll_ext busi ON (busi.res_id = r.res_id)
-    LEFT JOIN contacts_v2 cont ON (busi.contact_id = cont.contact_id)
-    LEFT JOIN listinstance list ON ((r.res_id = list.res_id)
-        AND ((list.item_mode)::text = 'dest'::text))
-    WHERE r.type_id = d.type_id 
-    AND d.doctypes_first_level_id = dfl.doctypes_first_level_id
-    AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
---view for res_view
-CREATE VIEW res_view AS
- SELECT r.tablename, r.is_multi_docservers, r.res_id, r.title, r.subject, r.page_count, r.identifier, r.doc_date, r.type_id,
- d.description AS type_label, d.doctypes_first_level_id, dfl.doctypes_first_level_label, dfl.css_style as doctype_first_level_style,
- d.doctypes_second_level_id, dsl.doctypes_second_level_label, dsl.css_style as doctype_second_level_style,
- r.format, r.typist, r.creation_date, r.relation, r.docserver_id,
- r.folders_system_id, r.path, r.filename, r.fingerprint, r.offset_doc, r.filesize, r.status,
- r.work_batch, r.arbatch_id, r.arbox_id,  r.is_paper, r.scan_date, r.scan_user,r.scan_location,r.scan_wkstation,
- r.scan_batch,r.doc_language,r.description,r.source,r.initiator,r.destination,r.dest_user,r.policy_id,r.cycle_id,r.cycle_date,
- r.custom_t1 AS doc_custom_t1, r.custom_t2 AS doc_custom_t2, r.custom_t3 AS doc_custom_t3,
- r.custom_t4 AS doc_custom_t4, r.custom_t5 AS doc_custom_t5, r.custom_t6 AS doc_custom_t6,
- r.custom_t7 AS doc_custom_t7, r.custom_t8 AS doc_custom_t8, r.custom_t9 AS doc_custom_t9,
- r.custom_t10 AS doc_custom_t10, r.custom_t11 AS doc_custom_t11, r.custom_t12 AS doc_custom_t12,
- r.custom_t13 AS doc_custom_t13, r.custom_t14 AS doc_custom_t14, r.custom_t15 AS doc_custom_t15,
- r.custom_d1 AS doc_custom_d1, r.custom_d2 AS doc_custom_d2, r.custom_d3 AS doc_custom_d3,
- r.custom_d4 AS doc_custom_d4, r.custom_d5 AS doc_custom_d5, r.custom_d6 AS doc_custom_d6,
- r.custom_d7 AS doc_custom_d7, r.custom_d8 AS doc_custom_d8, r.custom_d9 AS doc_custom_d9,
- r.custom_d10 AS doc_custom_d10, r.custom_n1 AS doc_custom_n1, r.custom_n2 AS doc_custom_n2,
- r.custom_n3 AS doc_custom_n3, r.custom_n4 AS doc_custom_n4, r.custom_n5 AS doc_custom_n5,
- r.custom_f1 AS doc_custom_f1, r.custom_f2 AS doc_custom_f2, r.custom_f3 AS doc_custom_f3,
- r.custom_f4 AS doc_custom_f4, r.custom_f5 AS doc_custom_f5, r.is_frozen as res_is_frozen,  
- r.reference_number, r.locker_user_id, r.locker_time
-   FROM  doctypes d, doctypes_first_level dfl, doctypes_second_level dsl, res_x r
-   WHERE r.type_id = d.type_id
-   AND d.doctypes_first_level_id = dfl.doctypes_first_level_id
-   AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-
---view for postindexing
-CREATE VIEW view_postindexing AS
-SELECT res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text AS user_name, res_view_letterbox.video_batch, res_view_letterbox.video_time, count(res_view_letterbox.res_id) AS count_documents, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text AS folder_full_label, folders.video_status
-FROM res_view_letterbox
-LEFT JOIN users ON res_view_letterbox.video_user::text = users.user_id::text
-LEFT JOIN folders ON folders.folders_system_id = res_view_letterbox.folders_system_id
-WHERE res_view_letterbox.video_batch IS NOT NULL
-GROUP BY res_view_letterbox.video_user, (users.firstname::text || ' '::text) || users.lastname::text, res_view_letterbox.video_batch, res_view_letterbox.video_time, res_view_letterbox.folders_system_id, (folders.folder_id::text || ' / '::text) || folders.folder_name::text, folders.video_status;
-
-
---view for contacts_v2
-CREATE VIEW view_contacts AS 
- SELECT c.contact_id, c.contact_type, c.is_corporate_person, c.society, c.society_short, c.firstname AS contact_firstname
-, c.lastname AS contact_lastname, c.title AS contact_title, c.function AS contact_function, c.other_data AS contact_other_data
-, c.user_id AS contact_user_id, c.entity_id AS contact_entity_id, c.creation_date, c.update_date, c.enabled AS contact_enabled, ca.id AS ca_id
-, ca.contact_purpose_id, ca.departement, ca.firstname, ca.lastname, ca.title, ca.function, ca.occupancy
-, ca.address_num, ca.address_street, ca.address_complement, ca.address_town, ca.address_postal_code, ca.address_country
-, ca.phone, ca.email, ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private, ca.enabled
-, cp.label as contact_purpose_label, ct.label as contact_type_label
-   FROM contacts_v2 c
-   RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id
-   LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id
-   LEFT JOIN contact_types ct ON c.contact_type = ct.id;
-
--- view for attachments
-CREATE VIEW res_view_attachments AS
-  SELECT '0' as res_id, res_id as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-  creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-  doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-  filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-  scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-  envelop_id, status, destination, approver, validation_date, effective_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, attachment_id_master
-  FROM res_version_attachments
-  UNION ALL
-  SELECT res_id, '0' as res_id_version, title, subject, description, publisher, contributor, type_id, format, typist,
-  creation_date, fulltext_result, ocr_result, author, author_name, identifier, source,
-  doc_language, relation, coverage, doc_date, docserver_id, folders_system_id, arbox_id, path,
-  filename, offset_doc, logical_adr, fingerprint, filesize, is_paper, page_count,
-  scan_date, scan_user, scan_location, scan_wkstation, scan_batch, burn_batch, scan_postmark,
-  envelop_id, status, destination, approver, validation_date, effective_date, work_batch, origin, is_ingoing, priority, initiator, dest_user,
-  coll_id, dest_contact_id, dest_address_id, updated_by, is_multicontacts, is_multi_docservers, res_id_master, attachment_type, '0'
-  FROM res_attachments;
-
-   
-
--- ************************************************************************* --
---                               DATABASE VERSION                            --
--- ************************************************************************* --
-UPDATE parameters SET param_value_int = 160 where id='database_version';
-
-
-
diff --git a/sql/1706.sql b/sql/1706.sql
deleted file mode 100755
index 4cd46cd60b790f0bb5d29739bbbee17f722d779f..0000000000000000000000000000000000000000
--- a/sql/1706.sql
+++ /dev/null
@@ -1,548 +0,0 @@
--- *************************************************************************--
---                                                                          --
---                                                                          --
--- Model migration script - 1.6 to 17.06          --
---                                                                          --
---                                                                          --
--- *************************************************************************--
-
-DROP VIEW IF EXISTS view_postindexing;
-
---perfs on res_view_letterbox
-DROP VIEW IF EXISTS res_view_letterbox;
-CREATE OR REPLACE VIEW res_view_letterbox AS 
- SELECT r.tablename,
-    r.is_multi_docservers,
-    r.res_id,
-    r.type_id,
-    r.policy_id,
-    r.cycle_id,
-    d.description AS type_label,
-    d.doctypes_first_level_id,
-    dfl.doctypes_first_level_label,
-    dfl.css_style AS doctype_first_level_style,
-    d.doctypes_second_level_id,
-    dsl.doctypes_second_level_label,
-    dsl.css_style AS doctype_second_level_style,
-    r.format,
-    r.typist,
-    r.creation_date,
-    r.modification_date,
-    r.relation,
-    r.docserver_id,
-    r.folders_system_id,
-    f.folder_id,
-    f.destination AS folder_destination,
-    f.is_frozen AS folder_is_frozen,
-    r.path,
-    r.filename,
-    r.fingerprint,
-    r.offset_doc,
-    r.filesize,
-    r.status,
-    r.work_batch,
-    r.arbatch_id,
-    r.arbox_id,
-    r.page_count,
-    r.is_paper,
-    r.doc_date,
-    r.scan_date,
-    r.scan_user,
-    r.scan_location,
-    r.scan_wkstation,
-    r.scan_batch,
-    r.doc_language,
-    r.description,
-    r.source,
-    r.author,
-    r.reference_number,
-    r.custom_t1 AS doc_custom_t1,
-    r.custom_t2 AS doc_custom_t2,
-    r.custom_t3 AS doc_custom_t3,
-    r.custom_t4 AS doc_custom_t4,
-    r.custom_t5 AS doc_custom_t5,
-    r.custom_t6 AS doc_custom_t6,
-    r.custom_t7 AS doc_custom_t7,
-    r.custom_t8 AS doc_custom_t8,
-    r.custom_t9 AS doc_custom_t9,
-    r.custom_t10 AS doc_custom_t10,
-    r.custom_t11 AS doc_custom_t11,
-    r.custom_t12 AS doc_custom_t12,
-    r.custom_t13 AS doc_custom_t13,
-    r.custom_t14 AS doc_custom_t14,
-    r.custom_t15 AS doc_custom_t15,
-    r.custom_d1 AS doc_custom_d1,
-    r.custom_d2 AS doc_custom_d2,
-    r.custom_d3 AS doc_custom_d3,
-    r.custom_d4 AS doc_custom_d4,
-    r.custom_d5 AS doc_custom_d5,
-    r.custom_d6 AS doc_custom_d6,
-    r.custom_d7 AS doc_custom_d7,
-    r.custom_d8 AS doc_custom_d8,
-    r.custom_d9 AS doc_custom_d9,
-    r.custom_d10 AS doc_custom_d10,
-    r.custom_n1 AS doc_custom_n1,
-    r.custom_n2 AS doc_custom_n2,
-    r.custom_n3 AS doc_custom_n3,
-    r.custom_n4 AS doc_custom_n4,
-    r.custom_n5 AS doc_custom_n5,
-    r.custom_f1 AS doc_custom_f1,
-    r.custom_f2 AS doc_custom_f2,
-    r.custom_f3 AS doc_custom_f3,
-    r.custom_f4 AS doc_custom_f4,
-    r.custom_f5 AS doc_custom_f5,
-    f.foldertype_id,
-    ft.foldertype_label,
-    f.custom_t1 AS fold_custom_t1,
-    f.custom_t2 AS fold_custom_t2,
-    f.custom_t3 AS fold_custom_t3,
-    f.custom_t4 AS fold_custom_t4,
-    f.custom_t5 AS fold_custom_t5,
-    f.custom_t6 AS fold_custom_t6,
-    f.custom_t7 AS fold_custom_t7,
-    f.custom_t8 AS fold_custom_t8,
-    f.custom_t9 AS fold_custom_t9,
-    f.custom_t10 AS fold_custom_t10,
-    f.custom_t11 AS fold_custom_t11,
-    f.custom_t12 AS fold_custom_t12,
-    f.custom_t13 AS fold_custom_t13,
-    f.custom_t14 AS fold_custom_t14,
-    f.custom_t15 AS fold_custom_t15,
-    f.custom_d1 AS fold_custom_d1,
-    f.custom_d2 AS fold_custom_d2,
-    f.custom_d3 AS fold_custom_d3,
-    f.custom_d4 AS fold_custom_d4,
-    f.custom_d5 AS fold_custom_d5,
-    f.custom_d6 AS fold_custom_d6,
-    f.custom_d7 AS fold_custom_d7,
-    f.custom_d8 AS fold_custom_d8,
-    f.custom_d9 AS fold_custom_d9,
-    f.custom_d10 AS fold_custom_d10,
-    f.custom_n1 AS fold_custom_n1,
-    f.custom_n2 AS fold_custom_n2,
-    f.custom_n3 AS fold_custom_n3,
-    f.custom_n4 AS fold_custom_n4,
-    f.custom_n5 AS fold_custom_n5,
-    f.custom_f1 AS fold_custom_f1,
-    f.custom_f2 AS fold_custom_f2,
-    f.custom_f3 AS fold_custom_f3,
-    f.custom_f4 AS fold_custom_f4,
-    f.custom_f5 AS fold_custom_f5,
-    f.is_complete AS fold_complete,
-    f.status AS fold_status,
-    f.subject AS fold_subject,
-    f.parent_id AS fold_parent_id,
-    f.folder_level,
-    f.folder_name,
-    f.creation_date AS fold_creation_date,
-    r.initiator,
-    r.destination,
-    r.dest_user,
-    r.confidentiality,
-    mlb.category_id,
-    mlb.exp_contact_id,
-    mlb.exp_user_id,
-    mlb.dest_user_id,
-    mlb.dest_contact_id,
-    mlb.address_id,
-    mlb.nature_id,
-    mlb.alt_identifier,
-    mlb.admission_date,
-    mlb.answer_type_bitmask,
-    mlb.other_answer_desc,
-    mlb.sve_start_date,
-    mlb.sve_identifier,
-    mlb.process_limit_date,
-    mlb.recommendation_limit_date,
-    mlb.closing_date,
-    mlb.alarm1_date,
-    mlb.alarm2_date,
-    mlb.flag_notif,
-    mlb.flag_alarm1,
-    mlb.flag_alarm2,
-    mlb.is_multicontacts,
-    r.video_user,
-    r.video_time,
-    r.video_batch,
-    r.subject,
-    r.identifier,
-    r.title,
-    r.priority,
-    mlb.process_notes,
-    r.locker_user_id,
-    r.locker_time,
-    ca.case_id,
-    ca.case_label,
-    ca.case_description,
-    en.entity_label,
-    en.entity_type AS entitytype,
-    cont.contact_id,
-    cont.firstname AS contact_firstname,
-    cont.lastname AS contact_lastname,
-    cont.society AS contact_society,
-    u.lastname AS user_lastname,
-    u.firstname AS user_firstname,
-    r.is_frozen AS res_is_frozen
-   FROM doctypes d,
-    doctypes_first_level dfl,
-    doctypes_second_level dsl,
-    res_letterbox r
-     LEFT JOIN entities en ON r.destination::text = en.entity_id::text
-     LEFT JOIN folders f ON r.folders_system_id = f.folders_system_id
-     LEFT JOIN cases_res cr ON r.res_id = cr.res_id
-     LEFT JOIN mlb_coll_ext mlb ON mlb.res_id = r.res_id
-     LEFT JOIN foldertypes ft ON f.foldertype_id = ft.foldertype_id AND f.status::text <> 'DEL'::text
-     LEFT JOIN cases ca ON cr.case_id = ca.case_id
-     LEFT JOIN contacts_v2 cont ON mlb.exp_contact_id = cont.contact_id OR mlb.dest_contact_id = cont.contact_id
-     LEFT JOIN users u ON mlb.exp_user_id::text = u.user_id::text OR mlb.dest_user_id::text = u.user_id::text
-  WHERE r.type_id = d.type_id AND d.doctypes_first_level_id = dfl.doctypes_first_level_id AND d.doctypes_second_level_id = dsl.doctypes_second_level_id;
-
-CREATE OR REPLACE FUNCTION order_alphanum(text) RETURNS text AS $$
-  SELECT regexp_replace(regexp_replace(regexp_replace(regexp_replace($1,
-    E'(^|\\D)(\\d{1,3}($|\\D))', E'\\1000\\2', 'g'),
-      E'(^|\\D)(\\d{4,6}($|\\D))', E'\\1000\\2', 'g'),
-        E'(^|\\D)(\\d{7}($|\\D))', E'\\100\\2', 'g'),
-          E'(^|\\D)(\\d{8}($|\\D))', E'\\10\\2', 'g');
-$$ LANGUAGE SQL;
-
-
-
-
-/* MIGRATION NOUVEL STRUCT MOTS CLES*/
-DROP SEQUENCE IF EXISTS tag_id_seq CASCADE;
-CREATE SEQUENCE tag_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 7
-  CACHE 1;
-
-ALTER TABLE tags DROP COLUMN IF EXISTS tag_id;
-ALTER TABLE tags ADD tag_id bigint NOT NULL DEFAULT nextval('tag_id_seq'::regclass);
-
-ALTER TABLE tags DROP COLUMN IF EXISTS entity_id_owner;
-ALTER TABLE tags ADD entity_id_owner character varying(32);
-
-DROP SEQUENCE IF EXISTS tmp_tag_id_seq;
-CREATE SEQUENCE tmp_tag_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 7
-  CACHE 1;
-
-DROP TABLE IF EXISTS tmp_tags;
-CREATE TABLE tmp_tags
-(
-  tag_id bigint NOT NULL DEFAULT nextval('tmp_tag_id_seq'::regclass),
-  tag_label character varying(255) NOT NULL
-)
-WITH (
-  OIDS=FALSE
-);
-
-INSERT INTO tmp_tags (tag_label)
-SELECT distinct(lower(tag_label)) from tags;
-
-DROP TABLE IF EXISTS tag_res;
-CREATE TABLE tag_res
-(
-  res_id bigint NOT NULL,
-  tag_id bigint NOT NULL,
-  CONSTRAINT tag_res_pkey PRIMARY KEY (res_id,tag_id)
-)
-WITH (
-  OIDS=FALSE
-);
-
-DO $$ 
-    BEGIN
-        BEGIN
-            ALTER TABLE tags ADD res_id bigint;
-        EXCEPTION
-            WHEN duplicate_column THEN RAISE NOTICE 'column res_id already exists in tags. skipping...';
-        END;
-    END;
-$$;
-INSERT INTO tag_res (res_id,tag_id)
-SELECT tags.res_id, tmp_tags.tag_id FROM tags, tmp_tags WHERE tmp_tags.tag_label = lower(tags.tag_label) AND tags.res_id IS NOT NULL;
-
-TRUNCATE TABLE tags;
-
-ALTER TABLE tags DROP CONSTRAINT IF EXISTS tagsjoin_pkey;
-ALTER TABLE tags DROP COLUMN IF EXISTS res_id;
-
-INSERT INTO tags (tag_label, coll_id, tag_id)
-SELECT tag_label, 'letterbox_coll', tag_id FROM tmp_tags;
-
-
-DROP TABLE IF EXISTS tmp_tags;
-DROP SEQUENCE IF EXISTS tmp_tag_id_seq;
-
-DROP TABLE IF EXISTS tags_entities;
-CREATE TABLE tags_entities
-(
-  tag_id bigint,
-  entity_id character varying(32),
-  CONSTRAINT tags_entities_pkey PRIMARY KEY (tag_id,entity_id)
-)
-WITH (
-  OIDS=FALSE
-);
-
-DROP TABLE IF EXISTS seda;
-
-CREATE TABLE seda
-(
-  "message_id" text NOT NULL,
-  "schema" text,
-  "type" text NOT NULL,
-  "status" text NOT NULL,
-  
-  "date" timestamp NOT NULL,
-  "reference" text NOT NULL,
-  
-  "account_id" text,
-  "sender_org_identifier" text NOT NULL,
-  "sender_org_name" text,
-  "recipient_org_identifier" text NOT NULL,
-  "recipient_org_name" text,
-
-  "archival_agreement_reference" text,
-  "reply_code" text,
-  "operation_date" timestamp,
-  "reception_date" timestamp,
-  
-  "related_reference" text,
-  "request_reference" text,
-  "reply_reference" text,
-  "derogation" boolean,
-  
-  "data_object_count" integer,
-  "size" numeric,
-  
-  "data" text,
-  
-  "active" boolean,
-  "archived" boolean,
-
-  PRIMARY KEY ("message_id")
-)
-WITH (
-  OIDS=FALSE
-);
-
-DROP TABLE IF EXISTS unit_identifier;
-
-CREATE TABLE unit_identifier
-(
-  "message_id" text NOT NULL,
-  "tablename" text NOT NULL,
-  "res_id" text NOT NULL
-);
-
-
-ALTER TABLE doctypes DROP COLUMN IF EXISTS retention_final_disposition;
-ALTER TABLE doctypes ADD COLUMN retention_final_disposition character varying(255) NOT NULL DEFAULT 'destruction';
-
-ALTER TABLE doctypes DROP COLUMN IF EXISTS retention_rule;
-ALTER TABLE doctypes ADD COLUMN retention_rule character varying(15) NOT NULL DEFAULT 'compta_3_03';
-
-ALTER TABLE doctypes DROP COLUMN IF EXISTS duration_current_use;
-ALTER TABLE doctypes ADD COLUMN duration_current_use integer DEFAULT '12';
-
-ALTER TABLE entities DROP COLUMN IF EXISTS archival_agency;
-ALTER TABLE entities ADD COLUMN archival_agency character varying(255) DEFAULT 'org_123456789_Archives';
-
-ALTER TABLE entities DROP COLUMN IF EXISTS archival_agreement;
-ALTER TABLE entities ADD COLUMN archival_agreement character varying(255) DEFAULT 'MAARCH_LES_BAINS_ACTES';
-
-UPDATE entities SET business_id = 'org_987654321_Versant';
-
-DELETE FROM docservers where docserver_id = 'FASTHD_ATTACH';
-INSERT INTO docservers (docserver_id, docserver_type_id, device_label, is_readonly, enabled, size_limit_number, actual_size_number, path_template, ext_docserver_info, chain_before, chain_after, creation_date, closing_date, coll_id, priority_number, docserver_location_id, adr_priority_number) 
-VALUES ('FASTHD_ATTACH', 'FASTHD', 'Fast internal disc bay for attachments', 'N', 'Y', 50000000000, 1, '/opt/maarch/docservers/manual_attachments/', NULL, NULL, NULL, '2011-01-13 14:47:49.197164', NULL, 'attachments_coll', 2, 'NANTERRE', 3);
-
-ALTER TABLE basket_persistent_mode ALTER COLUMN user_id TYPE character varying(128);
-ALTER TABLE res_mark_as_read ALTER COLUMN user_id TYPE character varying(128);
-
--- ************************************************************************* --
---                   CHANGE COLUMNS TYPE FOR CONTACTS_V2                   --
--- ************************************************************************* --
-DROP VIEW IF EXISTS view_contacts;
-
-ALTER TABLE contacts_v2 ALTER COLUMN other_data TYPE text;
-
-CREATE OR REPLACE VIEW view_contacts AS 
- SELECT c.contact_id, c.contact_type, c.is_corporate_person, c.society, c.society_short, c.firstname AS contact_firstname
-, c.lastname AS contact_lastname, c.title AS contact_title, c.function AS contact_function, c.other_data AS contact_other_data
-, c.user_id AS contact_user_id, c.entity_id AS contact_entity_id, c.creation_date, c.update_date, c.enabled AS contact_enabled, ca.id AS ca_id
-, ca.contact_purpose_id, ca.departement, ca.firstname, ca.lastname, ca.title, ca.function, ca.occupancy
-, ca.address_num, ca.address_street, ca.address_complement, ca.address_town, ca.address_postal_code, ca.address_country
-, ca.phone, ca.email, ca.website, ca.salutation_header, ca.salutation_footer, ca.other_data, ca.user_id, ca.entity_id, ca.is_private, ca.enabled
-, cp.label as contact_purpose_label, ct.label as contact_type_label
-   FROM contacts_v2 c
-   RIGHT JOIN contact_addresses ca ON c.contact_id = ca.contact_id
-   LEFT JOIN contact_purposes cp ON ca.contact_purpose_id = cp.id
-   LEFT JOIN contact_types ct ON c.contact_type = ct.id;
-
-
--- EXPORT SEDA
-DROP TABLE IF EXISTS seda;
-CREATE TABLE seda
-(
-  "message_id" character varying(255) NOT NULL,
-  "schema" character varying(16),
-  "type" character varying(128) NOT NULL,
-  "status" character varying(128) NOT NULL,
-
-  "date" timestamp NOT NULL,
-  "reference" character varying(255) NOT NULL,
-
-  "account_id" character varying(128),
-  "sender_org_identifier" character varying(255) NOT NULL,
-  "sender_org_name" character varying(255),
-  "recipient_org_identifier" character varying(255) NOT NULL,
-  "recipient_org_name" character varying(255),
-
-  "archival_agreement_reference" character varying(255),
-  "reply_code" character varying(255),
-  "operation_date" timestamp,
-  "reception_date" timestamp,
-
-  "related_reference" character varying(255),
-  "request_reference" character varying(255),
-  "reply_reference" character varying(255),
-  "derogation" character(1),
-
-  "data_object_count" integer,
-  "size" numeric,
-
-  "data" text,
-
-  "active" character(1),
-  "archived" character(1),
-
-  PRIMARY KEY ("message_id")
-)
-WITH (
-  OIDS=FALSE
-);
-
-DROP TABLE IF EXISTS unit_identifier;
-CREATE TABLE unit_identifier
-(
-  "message_id" character varying(255) NOT NULL,
-  "tablename" character varying(255) NOT NULL,
-  "res_id" character varying(255) NOT NULL
-);
-
-/*************DIS UPDATE***************/
-DROP SEQUENCE IF EXISTS allowed_ip_id_seq CASCADE;
-CREATE SEQUENCE allowed_ip_id_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 1
-  CACHE 1;
-
-DROP TABLE IF EXISTS allowed_ip;
-CREATE TABLE allowed_ip
-(
-  id integer NOT NULL DEFAULT nextval('allowed_ip_id_seq'::regclass),
-  ip character varying(50) NOT NULL,
-  CONSTRAINT allowed_ip_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-DROP SEQUENCE IF EXISTS user_signatures_seq CASCADE;
-CREATE SEQUENCE user_signatures_seq
-  INCREMENT 1
-  MINVALUE 1
-  MAXVALUE 9223372036854775807
-  START 1
-  CACHE 1;
-
-DROP TABLE IF EXISTS user_signatures;
-CREATE TABLE user_signatures
-(
-  id bigint NOT NULL DEFAULT nextval('user_signatures_seq'::regclass),
-  user_id character varying(128) NOT NULL,
-  signature_label character varying(255) DEFAULT NULL::character varying,
-  signature_path character varying(255) DEFAULT NULL::character varying,
-  signature_file_name character varying(255) DEFAULT NULL::character varying,
-  fingerprint character varying(255) DEFAULT NULL::character varying,
-  CONSTRAINT user_signatures_pkey PRIMARY KEY (id)
-)
-WITH (OIDS=FALSE);
-
-ALTER TABLE users DROP COLUMN IF EXISTS ra_code;
-ALTER TABLE users ADD ra_code character varying(255);
-ALTER TABLE users DROP COLUMN IF EXISTS ra_expiration_date;
-ALTER TABLE users ADD ra_expiration_date timestamp without time zone;
-
-/** Add new service for group which have view_doc_history service **/
-DELETE FROM usergroups_services where service_id = 'view_full_history';
-INSERT INTO usergroups_services SELECT group_id, 'view_full_history' FROM usergroups_services WHERE service_id = 'view_doc_history';
-
-/** Add new service by default for view graphic in report **/
-DELETE FROM usergroups_services where service_id = 'graphics_reports';
-INSERT INTO usergroups_services SELECT group_id, 'graphics_reports' FROM usergroups;
-
-/** Migrate signatures to the new table **/
-TRUNCATE TABLE user_signatures;
-INSERT INTO user_signatures (user_id, signature_label, signature_path, signature_file_name) SELECT user_id, '', signature_path, signature_file_name FROM users WHERE signature_path is not null and signature_file_name is not null;
-
-UPDATE parameters SET param_value_int = '1706' WHERE id = 'database_version';
-
-/** ADD NEW COLUMN FOR ORDER RES IN BASKETS **/
-ALTER TABLE baskets DROP COLUMN IF EXISTS basket_res_order;
-ALTER TABLE baskets ADD COLUMN basket_res_order character varying(255);
-
-/** DELETES OLD TABLES **/
-DROP TABLE IF EXISTS adr_business;
-DROP TABLE IF EXISTS adr_log;
-DROP TABLE IF EXISTS adr_rm;
-DROP TABLE IF EXISTS ar_boxes;
-DROP TABLE IF EXISTS ar_containers;
-DROP TABLE IF EXISTS ar_container_types;
-DROP TABLE IF EXISTS ar_deposits;
-DROP TABLE IF EXISTS ar_header;
-DROP TABLE IF EXISTS ar_natures;
-DROP TABLE IF EXISTS ar_positions;
-DROP TABLE IF EXISTS ar_sites;
-DROP TABLE IF EXISTS ext_docserver;
-DROP TABLE IF EXISTS folders_out;
-DROP TABLE IF EXISTS fulltext;
-DROP TABLE IF EXISTS groupsecurity;
-DROP TABLE IF EXISTS invoice_types;
-DROP VIEW  IF EXISTS res_view_log;
-DROP TABLE IF EXISTS res_log;
-DROP TABLE IF EXISTS resgroup_content;
-DROP TABLE IF EXISTS resgroups;
-
-DROP TABLE IF EXISTS rm_access_restriction_rules CASCADE;
-DROP VIEW  IF EXISTS rm_documents_view;
-DROP TABLE IF EXISTS rm_addresses CASCADE;
-DROP TABLE IF EXISTS rm_agreements CASCADE;
-DROP TABLE IF EXISTS rm_appraisal_rules CASCADE;
-DROP TABLE IF EXISTS rm_comments CASCADE; 
-DROP VIEW  IF EXISTS rm_ios_view;
-DROP TABLE IF EXISTS rm_contacts CASCADE;
-DROP TABLE IF EXISTS rm_content_descriptions CASCADE;
-DROP TABLE IF EXISTS rm_custodial_history CASCADE;
-DROP TABLE IF EXISTS rm_documents CASCADE;
-DROP TABLE IF EXISTS rm_entities CASCADE;
-DROP VIEW  IF EXISTS rm_ref_organizations CASCADE;
-DROP TABLE IF EXISTS rm_io_archives_relations CASCADE;
-DROP TABLE IF EXISTS rm_ios CASCADE;
-DROP TABLE IF EXISTS rm_items CASCADE;
-DROP TABLE IF EXISTS rm_keywords CASCADE;
-DROP TABLE IF EXISTS rm_organizations CASCADE;
-DROP TABLE IF EXISTS rm_schedule CASCADE;
-
-DROP TABLE IF EXISTS rp_history;
-
-DROP VIEW IF EXISTS res_view_apa;
-DROP VIEW IF EXISTS rm_ref_addresses CASCADE;
-DROP VIEW IF EXISTS rm_ref_contacts;
diff --git a/src/app/external/exportSeda/controllers/AdapterEmailController.php b/src/app/external/exportSeda/controllers/AdapterEmailController.php
index fae12601acc4f4068ca573c4d5bc72ec668364c2..5c687f88fa1154ba3650c97fcc359d463484633a 100755
--- a/src/app/external/exportSeda/controllers/AdapterEmailController.php
+++ b/src/app/external/exportSeda/controllers/AdapterEmailController.php
@@ -26,8 +26,8 @@ class AdapterEmailController
         $res['status'] = 0;
         $res['content'] = '';
 
-        $xml = CoreConfigModel::getXmlLoaded(['path' => 'modules/export_seda/xml/config.xml']);
-        $gec = strtolower($xml->M2M->gec);
+        $config = CoreConfigModel::getJsonLoaded(['path' => 'apps/maarch_entreprise/xml/config.json']);
+        $gec    = strtolower($config['exportSeda']['M2M']['gec']);
 
         if ($gec == 'maarch_courrier') {
             $document = ['id' => $messageObject->DataObjectPackage->DescriptiveMetadata->ArchiveUnit[0]->Content->OriginatingSystemId, 'isLinked' => false, 'original' => false];
diff --git a/src/app/external/exportSeda/controllers/SedaController.php b/src/app/external/exportSeda/controllers/SedaController.php
index db454c3382a78774e4b6b83d611b53c98ea9a9fe..86a353c2a8b2776770656cdb9f8bada10d19545d 100755
--- a/src/app/external/exportSeda/controllers/SedaController.php
+++ b/src/app/external/exportSeda/controllers/SedaController.php
@@ -69,9 +69,9 @@ class SedaController
             return $response->withStatus(400)->withJson(['errors' => 'producer_service is empty for this entity', 'lang' => 'noProducerService']);
         }
 
-        $sedaXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/export_seda/xml/config.xml']);
-        if (empty($sedaXml->CONFIG->senderOrgRegNumber)) {
-            return $response->withStatus(400)->withJson(['errors' => 'No senderOrgRegNumber found in config.xml (export_seda)', 'lang' => 'noSenderOrgRegNumber']);
+        $config = CoreConfigModel::getJsonLoaded(['path' => 'apps/maarch_entreprise/xml/config.json']);
+        if (empty($config['exportSeda']['senderOrgRegNumber'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'No senderOrgRegNumber found in config.json', 'lang' => 'noSenderOrgRegNumber']);
         }
 
         $date = new \DateTime();
@@ -81,7 +81,7 @@ class SedaController
                 'entity' => [
                     'label'               => $entity['entity_label'],
                     'producerService'     => $entity['producer_service'],
-                    'senderArchiveEntity' => (string)$sedaXml->CONFIG->senderOrgRegNumber
+                    'senderArchiveEntity' => $config['exportSeda']['senderOrgRegNumber']
                 ],
                 'doctype' => [
                     'label'                     => $doctype['description'],
@@ -183,14 +183,14 @@ class SedaController
         }
 
         $archivalAgreements = SedaController::getArchivalAgreements([
-            'configXml'           => $sedaXml,
-            'senderArchiveEntity' => (string)$sedaXml->CONFIG->senderOrgRegNumber,
+            'config'              => $config,
+            'senderArchiveEntity' => $config['exportSeda']['senderOrgRegNumber'],
             'producerService'     => $entity['producer_service']
         ]);
         if (!empty($archivalAgreements['errors'])) {
             return $response->withStatus(400)->withJson($archivalAgreements);
         }
-        $recipientArchiveEntities = SedaController::getRecipientArchiveEntities(['configXml' => $sedaXml, 'archivalAgreements' => $archivalAgreements['archivalAgreements']]);
+        $recipientArchiveEntities = SedaController::getRecipientArchiveEntities(['config' => $config, 'archivalAgreements' => $archivalAgreements['archivalAgreements']]);
         if (!empty($recipientArchiveEntities['errors'])) {
             return $response->withStatus(400)->withJson($recipientArchiveEntities);
         }
@@ -204,15 +204,15 @@ class SedaController
     public function getRecipientArchiveEntities($args = [])
     {
         $archiveEntities = [];
-        if (strtolower((string)$args['configXml']->CONFIG->sae) == 'maarchrm') {
+        if (strtolower($args['config']['exportSeda']['sae']) == 'maarchrm') {
             $curlResponse = CurlModel::execSimple([
-                'url'     => rtrim((string)$args['configXml']->CONFIG->urlSAEService, '/') . '/organization/organization/Byrole/archiver',
+                'url'     => rtrim($args['config']['exportSeda']['urlSAEService'], '/') . '/organization/organization/Byrole/archiver',
                 'method'  => 'GET',
-                'cookie'  => 'LAABS-AUTH=' . urlencode((string)$args['configXml']->CONFIG->token),
+                'cookie'  => 'LAABS-AUTH=' . urlencode($args['config']['exportSeda']['token']),
                 'headers' => [
                     'Accept: application/json',
                     'Content-Type: application/json',
-                    'User-Agent: ' . (string)$args['configXml']->CONFIG->userAgent
+                    'User-Agent: ' . $args['config']['exportSeda']['userAgent']
                 ]
             ]);
 
@@ -237,15 +237,12 @@ class SedaController
                 }
             }
         } else {
-            foreach ($args['configXml']->externalSAE as $value) {
-                if ((string)$value->id == (string)$args['configXml']->CONFIG->sae) {
-                    foreach ($value->archiveEntities->archiveEntity as $rule) {
-                        $archiveEntities[] = [
-                            'id'    => (string)$rule->id,
-                            'label' => (string)$rule->label
+            if (is_array($args['config']['exportSeda']['externalSAE']['archiveEntities'])) {
+                foreach ($args['config']['exportSeda']['externalSAE']['archiveEntities'] as $archiveEntity) {
+                    $archiveEntities[] = [
+                            'id'    => $archiveEntity['id'],
+                            'label' => $archiveEntity['label']
                         ];
-                    }
-                    break;
                 }
             }
         }
@@ -256,15 +253,15 @@ class SedaController
     public function getArchivalAgreements($args = [])
     {
         $archivalAgreements = [];
-        if (strtolower((string)$args['configXml']->CONFIG->sae) == 'maarchrm') {
+        if (strtolower($args['config']['exportSeda']['sae']) == 'maarchrm') {
             $curlResponse = CurlModel::execSimple([
-                'url'     => rtrim((string)$args['configXml']->CONFIG->urlSAEService, '/') . '/medona/archivalAgreement/Index',
+                'url'     => rtrim($args['config']['exportSeda']['urlSAEService'], '/') . '/medona/archivalAgreement/Index',
                 'method'  => 'GET',
-                'cookie'  => 'LAABS-AUTH=' . urlencode((string)$args['configXml']->CONFIG->token),
+                'cookie'  => 'LAABS-AUTH=' . urlencode($args['config']['exportSeda']['token']),
                 'headers' => [
                     'Accept: application/json',
                     'Content-Type: application/json',
-                    'User-Agent: ' . (string)$args['configXml']->CONFIG->userAgent
+                    'User-Agent: ' . $args['config']['exportSeda']['userAgent']
                 ]
             ]);
 
@@ -274,7 +271,7 @@ class SedaController
                 return ['errors' => 'Error returned by the route /medona/archivalAgreement/Index : ' . $curlResponse['response']['message']];
             }
 
-            $producerService = SedaController::getProducerServiceInfo(['configXml' => $args['configXml'], 'producerServiceName' => $args['producerService']]);
+            $producerService = SedaController::getProducerServiceInfo(['config' => $args['config'], 'producerServiceName' => $args['producerService']]);
             if (!empty($producerService['errors'])) {
                 return ['errors' => $curlResponse['errors']];
             } elseif (empty($producerService['producerServiceInfo'])) {
@@ -295,15 +292,12 @@ class SedaController
                 }
             }
         } else {
-            foreach ($args['configXml']->externalSAE as $value) {
-                if ((string)$value->id == (string)$args['configXml']->CONFIG->sae) {
-                    foreach ($value->archivalAgreements->archivalAgreement as $rule) {
-                        $archivalAgreements[] = [
-                            'id'    => (string)$rule->id,
-                            'label' => (string)$rule->label
-                        ];
-                    }
-                    break;
+            if (is_array($args['config']['exportSeda']['externalSAE']['archivalAgreements'])) {
+                foreach ($args['config']['exportSeda']['externalSAE']['archivalAgreements'] as $archivalAgreement) {
+                    $archivalAgreements[] = [
+                        'id'    => $archivalAgreement['id'],
+                        'label' => $archivalAgreement['label']
+                    ];
                 }
             }
         }
@@ -314,13 +308,13 @@ class SedaController
     public function getProducerServiceInfo($args = [])
     {
         $curlResponse = CurlModel::execSimple([
-            'url'     => rtrim((string)$args['configXml']->CONFIG->urlSAEService, '/') . '/organization/organization/Search?term=' . $args['producerServiceName'],
+            'url'     => rtrim($args['config']['exportSeda']['urlSAEService'], '/') . '/organization/organization/Search?term=' . $args['producerServiceName'],
             'method'  => 'GET',
-            'cookie'  => 'LAABS-AUTH=' . urlencode((string)$args['configXml']->CONFIG->token),
+            'cookie'  => 'LAABS-AUTH=' . urlencode($args['config']['exportSeda']['token']),
             'headers' => [
                 'Accept: application/json',
                 'Content-Type: application/json',
-                'User-Agent: ' . (string)$args['configXml']->CONFIG->userAgent
+                'User-Agent: ' . $args['config']['exportSeda']['userAgent']
             ]
         ]);
 
@@ -339,21 +333,21 @@ class SedaController
             return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
         }
 
-        $sedaXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/export_seda/xml/config.xml']);
-        if (empty($sedaXml->CONFIG->sae)) {
-            return $response->withStatus(400)->withJson(['errors' => 'No SAE found in config.xml (export_seda)']);
+        $config = CoreConfigModel::getJsonLoaded(['path' => 'apps/maarch_entreprise/xml/config.json']);
+        if (empty($config['exportSeda']['sae'])) {
+            return $response->withStatus(400)->withJson(['errors' => 'No SAE found in config.json']);
         }
 
         $retentionRules = [];
-        if (strtolower((string)$sedaXml->CONFIG->sae) == 'maarchrm') {
+        if (strtolower($config['exportSeda']['sae']) == 'maarchrm') {
             $curlResponse = CurlModel::execSimple([
-                'url'     => rtrim((string)$sedaXml->CONFIG->urlSAEService, '/') . '/recordsManagement/retentionRule/Index',
+                'url'     => rtrim($config['exportSeda']['urlSAEService'], '/') . '/recordsManagement/retentionRule/Index',
                 'method'  => 'GET',
-                'cookie'  => 'LAABS-AUTH=' . urlencode((string)$sedaXml->CONFIG->token),
+                'cookie'  => 'LAABS-AUTH=' . urlencode($config['exportSeda']['token']),
                 'headers' => [
                     'Accept: application/json',
                     'Content-Type: application/json',
-                    'User-Agent: ' . (string)$sedaXml->CONFIG->userAgent
+                    'User-Agent: ' . $config['exportSeda']['userAgent']
                 ]
             ]);
 
@@ -374,15 +368,12 @@ class SedaController
                 ];
             }
         } else {
-            foreach ($sedaXml->externalSAE as $value) {
-                if ((string)$value->id == (string)$sedaXml->CONFIG->sae) {
-                    foreach ($value->retentionRules->retentionRule as $rule) {
-                        $retentionRules[] = [
-                            'id'    => (string)$rule->id,
-                            'label' => (string)$rule->label
-                        ];
-                    }
-                    break;
+            if (is_array($config['exportSeda']['externalSAE']['retentionRules'])) {
+                foreach ($config['exportSeda']['externalSAE']['retentionRules'] as $rule) {
+                    $retentionRules[] = [
+                        'id'    => $rule['id'],
+                        'label' => $rule['label']
+                    ];
                 }
             }
         }
diff --git a/src/app/external/exportSeda/controllers/TransferController.php b/src/app/external/exportSeda/controllers/TransferController.php
index 6d45bc7f8aaa256cc903470c2fa0f9a62cc5ee08..71a806083845e51933406a2195110e4a82e167a3 100755
--- a/src/app/external/exportSeda/controllers/TransferController.php
+++ b/src/app/external/exportSeda/controllers/TransferController.php
@@ -20,7 +20,7 @@ class TransferController
 {
     public static function transfer($target, $messageId, $type = null)
     {
-        $xml            = CoreConfigModel::getXmlLoaded(['path' => 'modules/export_seda/xml/config.xml']);
+        $config         = CoreConfigModel::getJsonLoaded(['path' => 'apps/maarch_entreprise/xml/config.json']);
         $adapter        = '';
         $res['status']  = 0;
         $res['content'] = '';
@@ -53,13 +53,13 @@ class TransferController
             curl_setopt($curl, CURLOPT_POSTFIELDS, $param[3]);
             curl_setopt($curl, CURLOPT_FAILONERROR, false);
 
-            if (empty($xml->CONFIG->certificateSSL)) {
+            if (empty($config['exportSeda']['certificateSSL'])) {
                 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
             } else {
                 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
                 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
 
-                $certificateSSL = $xml->CONFIG->certificateSSL;
+                $certificateSSL = $config['exportSeda']['certificateSSL'];
                 if (is_file($certificateSSL)) {
                     $ext = ['.crt','.pem'];
 
diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json
index 3b33450aa5759bcb941cad96c192a1ada06ff2a3..d53979b670895d261637a75a6d39a5e2670cdd49 100644
--- a/src/lang/lang-fr.json
+++ b/src/lang/lang-fr.json
@@ -2081,7 +2081,7 @@
     "noDestination": "Le courrier n'a pas d'entité traitante",
     "noRetentionInfo": "Le type de courrier n'a pas de règle de conservation ou de sort final",
     "noProducerService": "L'entité traitante n'a pas d'identifiant de service producteur",
-    "noSenderOrgRegNumber": "Aucun service versant défini (Balise senderOrgRegNumber dans config.xml)",
+    "noSenderOrgRegNumber": "Aucun service versant défini (senderOrgRegNumber dans config.json)",
     "producerServiceDoesNotExists": "Le service producteur n'existe pas dans MaarchRM",
     "nextPage": "Page suivante",
     "prevPage": "Page précédente",