Delimiter $$
/**
 * Author:  armen
 * Created: 21 déc. 2023
 */
# Delimiter $$
Drop Procedure if exists LOADER_CREATE_TABLE_TMP_ACC_HAS_MBR_SAVE$$
Create Procedure LOADER_CREATE_TABLE_TMP_ACC_HAS_MBR_SAVE ()
Begin
    -- cette table doit être persistance
    -- elle ne doit donc pas être supprimée et recréée
    CREATE TABLE IF NOT EXISTS `TMP_ACCOUNTS_has_MEMBERS_SAVE` (
       `ID_TMP_ACCOUNTS_has_MEMBERS_SAVE` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
        , `ACCOUNTS_ID_ACCOUNTS` INT(10) UNSIGNED NULL
        , `MEMBERS_ID_MEMBERS` INT(10) UNSIGNED NOT NULL
        , `ENTITIES_ID_ENTITIES` INT(10) UNSIGNED NOT NULL
        , `TMP_ACCOUNTS_has_MEMBERS_SEQUENCE` SMALLINT(6) NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_1` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_2` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_3` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_4` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_5` INT(10) UNSIGNED NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_1` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_2` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_3` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_4` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_5` VARCHAR(20) NULL DEFAULT NULL
        , `DF_ACCESS_PROFILES_ID_DF_ACCESS_PROFILES` INT(10) UNSIGNED NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_PROFILE_CODE` VARCHAR(10) NULL DEFAULT NULL
        , `ENT_AC_ATTC_MBRS_PRFLS_ID_ENT_AC_ATTC_MBRS_PRFLS` INT(10) UNSIGNED NULL
        , `TMP_ACCOUNTS_has_MEMBERS_REF` VARCHAR(40) NULL
        , `TMP_ACCOUNTS_has_MEMBERS_SAVE_TIMESTAMP` TIMESTAMP NOT NULL
        , PRIMARY KEY (`ID_TMP_ACCOUNTS_has_MEMBERS_SAVE`)
        , INDEX (`TMP_ACCOUNTS_has_MEMBERS_SEQUENCE` ASC)
        , INDEX (`ACCOUNTS_ID_ACCOUNTS` ASC)
        , INDEX (`TMP_ACCOUNTS_has_MEMBERS_REF` ASC)
        , INDEX (`ENTITIES_ID_ENTITIES` ASC)

    )
        ENGINE = InnoDB
        DEFAULT CHARACTER SET = utf8
        COLLATE = utf8_general_ci
        COMMENT = 'table pour permettre la persistance des règles des derniers import de membres attachés'
    ;
    -- cette table à la même structure que la précédente, doit mais données non persistant
    Drop TABLE IF EXISTS `TMP_ACCOUNTS_has_MEMBERS_PRCSS`;
    CREATE TABLE IF NOT EXISTS `TMP_ACCOUNTS_has_MEMBERS_PRCSS` (
       `ID_TMP_ACCOUNTS_has_MEMBERS_SAVE` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT
        , `ACCOUNTS_ID_ACCOUNTS` INT(10) UNSIGNED NULL
        , `MEMBERS_ID_MEMBERS` INT(10) UNSIGNED NOT NULL
        , `ENTITIES_ID_ENTITIES` INT(10) UNSIGNED NOT NULL
        , `TMP_ACCOUNTS_has_MEMBERS_SEQUENCE` SMALLINT(6) NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_1` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_2` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_3` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_4` INT(10) UNSIGNED NULL DEFAULT NULL
        , `ENT_REF_DATA_ID_ENT_REF_DATAS_5` INT(10) UNSIGNED NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_1` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_2` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_3` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_4` VARCHAR(20) NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_ACCRED_CODE_5` VARCHAR(20) NULL DEFAULT NULL
        , `DF_ACCESS_PROFILES_ID_DF_ACCESS_PROFILES` INT(10) UNSIGNED NULL DEFAULT NULL
#         , `TMP_ACCOUNTS_has_MEMBERS_PROFILE_CODE` VARCHAR(10) NULL DEFAULT NULL
        , `ENT_AC_ATTC_MBRS_PRFLS_ID_ENT_AC_ATTC_MBRS_PRFLS` INT(10) UNSIGNED NULL
        , `TMP_ACCOUNTS_has_MEMBERS_REF` VARCHAR(40) NULL
        , `TMP_ACCOUNTS_has_MEMBERS_SAVE_TIMESTAMP` TIMESTAMP NOT NULL
        , PRIMARY KEY (`ID_TMP_ACCOUNTS_has_MEMBERS_SAVE`)
        , INDEX (`TMP_ACCOUNTS_has_MEMBERS_SEQUENCE` ASC)
        , INDEX (`ACCOUNTS_ID_ACCOUNTS` ASC)
        , INDEX (`TMP_ACCOUNTS_has_MEMBERS_REF` ASC)
        , INDEX (`ENTITIES_ID_ENTITIES` ASC)

    )
        ENGINE = InnoDB
        DEFAULT CHARACTER SET = utf8
        COLLATE = utf8_general_ci
        COMMENT = 'table des données en cours de traitement.'
    ;

End $$
Delimiter ;
call LOADER_CREATE_TABLE_TMP_ACC_HAS_MBR_SAVE();
