Delimiter //
/**
 *  Table for import of Entries has Accounts
 */
Drop Procedure if exists LOADER_CREATE_TABLE_ENTRIES_ENTRIES_HAS_ACCOUNTS//

Create Procedure LOADER_CREATE_TABLE_ENTRIES_ENTRIES_HAS_ACCOUNTS()
Begin

    DROP TABLE IF EXISTS LOADER_ENTRIES_ENTRIES_has_ACCOUNTS;

    CREATE TABLE IF NOT EXISTS LOADER_ENTRIES_ENTRIES_has_ACCOUNTS (

        -- champs pour le traitements de l'import
        LOADER_STATUS_ID_LOADER_STATUS Int Not Null,
		LOADER_ENTRIES_ID_LOADER_ENTRIES Int Unsigned Not Null, 
        ID_ENTRIES_has_ACCOUNTS int(10) unsigned NOT NULL AUTO_INCREMENT,
        -- ENTRIES_ID_ENTRIES int(10) unsigned NOT NULL, -- Faire le lien via LOADER_STATUS
        ACCOUNTS_ID_ACCOUNTS int(10) unsigned NOT NULL,
        ENTRIES_ACC_EXT_REF varchar(45) NOT NULL,
        ENTRIES_PERMANENT_ATTACHEMENT smallint(6) NOT NULL DEFAULT '1',

        PRIMARY KEY (ID_ENTRIES_has_ACCOUNTS)
        , Index (LOADER_STATUS_ID_LOADER_STATUS)
		, Index (LOADER_ENTRIES_ID_LOADER_ENTRIES)

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

End//
Delimiter ;
CALL LOADER_CREATE_TABLE_ENTRIES_ENTRIES_HAS_ACCOUNTS();