Delimiter //
/*
*
*/
Drop Procedure if exists LOADER_CREATE_TABLE_MEMBERSACCRED//
Create Procedure LOADER_CREATE_TABLE_MEMBERSACCRED ()
Begin
    Drop Table If Exists LOADER_MEMBERSACCRED;
    
    Create Table LOADER_MEMBERSACCRED (
        ID_LOADER_MEMBERSACCRED Int Unsigned Not Null Auto_increment Primary Key
        -- champs pour le traitements de l'import
        , LOADER_STATUS_ID_LOADER_STATUS Int Unsigned Not Null
-- 
--         -- champ de références
        , MEMBERS_LOGIN Varchar(255) Null
        , ID_MEMBERS Int Unsigned Null -- id du membre existant. Issu de la normalisation

		, CONTACTS_REF VARCHAR(40) Null -- not null
--         , ID_CONTACTS Int Unsigned Null -- id du contact issu normalisation.
        -- id contact inutil pour le moment

        -- vue avec Olivier : Utilisation de la fonction lié au profile 
        -- Function
        , DF_FUNCTIONS_SHORT_LABEL varchar(10) Null
        , DF_FUNCTIONS_ID_DF_FUNCTIONS Int Unsigned Null -- issu normalisation.


        -- profile
        , DF_ACCESS_PROFILES_CODE varchar(10) Null
        , DF_ACCESS_PROFILES_ID_DF_ACCESS_PROFILES Int Unsigned Null -- issu normalisation.


        , ID_ENTITIES_has_MEMBERS Int Unsigned Null -- issu normalisation.
        , ID_ENTITIES_has_MEMBERS_NEW Int Unsigned Null -- issu normalisation.


        -- référence d'accreditations
		, ACCRED_CODE_1 varchar(20) Null
        , ID_ENTITIES_REF_1 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_1 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_1_NEW Int Unsigned Null -- issu normalisation

		, ACCRED_CODE_2 varchar(20) Null
        , ID_ENTITIES_REF_2 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_2 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_2_NEW Int Unsigned Null -- issu normalisation

		, ACCRED_CODE_3 varchar(20) Null
        , ID_ENTITIES_REF_3 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_3 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_3_NEW Int Unsigned Null -- issu normalisation

		, ACCRED_CODE_4 varchar(20) Null
        , ID_ENTITIES_REF_4 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_4 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_4_NEW Int Unsigned Null -- issu normalisation

		, ACCRED_CODE_5 varchar(20) Null
        , ID_ENTITIES_REF_5 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_5 Int Unsigned Null -- issu normalisation
        , ID_ENTITIES_REF_DATAS_5_NEW Int Unsigned Null -- issu normalisation


-- ACCRED_ACCOUNTS
--         , ENTITIES_REF_ID_ENTITIES_REF_1 Int Unsigned Null -- issu normalisation.
-- 
        -- contraintes et indexes
--         , Primary Key (ID_LOADER_RECLAIMS)
        , Index (LOADER_STATUS_ID_LOADER_STATUS)
        , Index (CONTACTS_REF)
        , Index (MEMBERS_LOGIN)
--         , Index (ACCRED_CODE_1)
--         , Index (ACCRED_CODE_2)
--         , Index (ACCRED_CODE_3)
--         , Index (ACCRED_CODE_4)
--         , Index (ACCRED_CODE_5)

    ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
End //
Delimiter ;
call LOADER_CREATE_TABLE_MEMBERSACCRED();
