Delimiter //
/**
 *  Table for import of Phones
 */
Drop Procedure if exists LOADER_CREATE_TABLE_CONTACTS_PHONES//

Create Procedure LOADER_CREATE_TABLE_CONTACTS_PHONES()
Begin

    Drop Table If Exists LOADER_CONTACTS_PHONES;

    Create Table LOADER_CONTACTS_PHONES (

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

		LOADER_CONTACTS_ID_LOADER_CONTACTS Int Unsigned Not Null,
        `ID_NEW_CONTACTS_PHONES` int(10) unsigned Not Null Auto_Increment,
        `DF_PHONE_TYP_ID_DF_PHONE_TYP` int(10) unsigned Null,
        `DF_CHECK_STAT_ID_DF_CHECK_STAT` int(10) unsigned Null,
        `CONTACTS_PHONE_NUMBER` varchar(25) Null,
        `CONTACTS_PHONE_NUMERIC_ONLY` varchar(15) Null,
        `CONTACTS_PHONE_PREFERENCE` smallint(6) Null Default '0',
        `CONTACTS_PHONES_TRASHED` smallint(6) Null Default '0',
        `CONTACTS_PHONES_LAST_UPDATE` datetime Null,

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

        Primary Key (`ID_NEW_CONTACTS_PHONES`)
        , Index (LOADER_STATUS_ID_LOADER_STATUS)
		, Index (LOADER_CONTACTS_ID_LOADER_CONTACTS)
		, Index (CONTACTS_PHONE_NUMERIC_ONLY)

    ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;


End//
Delimiter ;
CALL LOADER_CREATE_TABLE_CONTACTS_PHONES();
