ALTER TABLE `core_customer`   
  CHANGE `customer_code` `customer_code` INT(40) NOT NULL AUTO_INCREMENT;



SET @counter := 0;

UPDATE core_customer AS c
JOIN (
    SELECT customer_id, (@counter := @counter + 1) AS new_customer_code
    FROM core_customer
    ORDER BY created_at ASC
) AS sorted_customers ON c.customer_id = sorted_customers.customer_id
SET c.customer_code = sorted_customers.new_customer_code;