Delimiter //
/**
 *  Table for import of Emails
 */
Drop Procedure if exists LOADER_CREATE_TABLE_CONTACTS_EMAILS//

Create Procedure LOADER_CREATE_TABLE_CONTACTS_EMAILS()
Begin

    Drop Table If Exists LOADER_CONTACTS_EMAILS;

    Create Table LOADER_CONTACTS_EMAILS (

        -- champs pour le traitements de l'import
        LOADER_STATUS_ID_LOADER_STATUS Int Not Null,

        ID_CONTACTS_EMAILS int(10) Unsigned Not Null Auto_Increment,
		-- 
        -- CONTACTS_ID_CONTACTS int(10) unsigned Not Null, -- Faire le lien via LOADER_STATUS -- OBSOLET
		LOADER_CONTACTS_ID_LOADER_CONTACTS Int Unsigned Not Null, -- en multicible faire le lien avec ID_LOADER_CONTACTS !!!!!


        DF_CHECK_STAT_ID_DF_CHECK_STAT int(10) Unsigned Not Null,
        CONTACTS_EMAILS_EMAIL varchar(255) Not Null,
        CONTACTS_EMAILS_PREFERENCE smallint(6) Not Null Default '0',
        CONTACTS_EMAILS_TRASHED smallint(6) Not Null Default '0',
        CONTACTS_EMAILS_LAST_UPDATE datetime Not Null,

        CONTACTS_EMAILS_ORIGIN smallint(5) Not Null Default 2, -- origine = import 
        

        Primary Key (ID_CONTACTS_EMAILS)
        , Index (LOADER_STATUS_ID_LOADER_STATUS)
		, Index (LOADER_CONTACTS_ID_LOADER_CONTACTS)

    ) ENGINE = InnoDB AUTO_INCREMENT = 0 Default CHARSET=utf8 Collate = utf8_general_ci;

End//
Delimiter ;
Call LOADER_CREATE_TABLE_CONTACTS_EMAILS();