Skip to content

Migration SQL ERROR 1062 (23000) Duplicate entry ‘NULL’

I’m trying to move a live site to a dev server. Export SQL has been done with phpmyadmin. When importing via CLI;
mysql -u “user” -p “name_new_database” < bupsqlfile.sql

I get this error:
ERROR 1062 (23000) at line 4659855: Duplicate entry ‘NULL’ for key ‘sales_order_grid.SALES_ORDER_GRID_PICKUP_LOCATION_CODE’

The part where the line number refers to :

-- -- Indexes for table sales_order_grid-- ALTER TABLEsales_order_grid ADD PRIMARY KEY (entity_id), ADD UNIQUE KEY SALES_ORDER_GRID_INCREMENT_ID_STORE_ID (increment_id,store_id), ADD KEY SALES_ORDER_GRID_STATUS (status), ADD KEY SALES_ORDER_GRID_STORE_ID (store_id), ADD KEY SALES_ORDER_GRID_BASE_GRAND_TOTAL (base_grand_total), ADD KEY SALES_ORDER_GRID_BASE_TOTAL_PAID (base_total_paid), ADD KEY SALES_ORDER_GRID_GRAND_TOTAL (grand_total), ADD KEY SALES_ORDER_GRID_TOTAL_PAID (total_paid), ADD KEY SALES_ORDER_GRID_SHIPPING_NAME (shipping_name), ADD KEY SALES_ORDER_GRID_BILLING_NAME (billing_name), ADD KEY SALES_ORDER_GRID_CREATED_AT (created_at), ADD KEY SALES_ORDER_GRID_CUSTOMER_ID (customer_id), ADD KEY SALES_ORDER_GRID_UPDATED_AT (updated_at), ADD KEY SALES_ORDER_GRID_PICKUP_LOCATION_CODE (pickup_location_code); ALTER TABLE sales_order_gridADD FULLTEXT KEYFTI_randomkeygoeshere (increment_id,billing_name,shipping_name,shipping_address,billing_address,customer_name,customer_email);

When I look in the table “sales_order_grid” most records have the value “null” in the key “pickup_location_code”

What can I do to go ahead with the import?

I’ve tried disabling the foreign key check, but without success.