Sql error 1364 Field doesn't have a default value

Hi,
Could someone explain what this blocking error on step 7 means ? and how I can fix that ? 
Regards,
 

var/www/html/…./magento$ php bin/ubdatamigration run --step=7
Processing in step #7…
Status: fail
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field ‘custom_discount’ doesn’t have a default value. The SQL statement executed was: INSERT INTO `sales_order` (`total_item_count`, `paypal_ipn_customer_notified`, `order_approval_status`, `state`, `status`, `protect_code`, `shipping_description`, `is_virtual`, `store_id`, `customer_id`, `base_discount_amount`, `base_discount_canceled`, `base_grand_total`, `base_shipping_amount`, `base_shipping_canceled`, `base_shipping_tax_amount`, `base_subtotal`, `base_subtotal_canceled`, `base_tax_amount`, `base_tax_canceled`, `base_to_global_rate`, `base_to_order_rate`, `base_total_canceled`, `discount_amount`, `discount_canceled`, `grand_total`, `shipping_amount`, `shipping_canceled`, `shipping_tax_amount`, `store_to_base_rate`, `store_to_order_rate`, `subtotal`, `subtotal_canceled`, `tax_amount`, `tax_canceled`, `total_canceled`, `total_qty_ordered`, `customer_is_guest`, `customer_note_notify`, `billing_address_id`, `customer_group_id`, `quote_id`, `shipping_address_id`, `base_shipping_discount_amount`, `base_subtotal_incl_tax`, `base_total_due`, `shipping_discount_amount`, `subtotal_incl_tax`, `total_due`, `weight`, `increment_id`, `base_currency_code`, `customer_email`, `customer_firstname`, `customer_lastname`, `global_currency_code`, `order_currency_code`, `remote_ip`, `shipping_method`, `store_currency_code`, `store_name`, `created_at`, `updated_at`, `shipping_incl_tax`, `base_shipping_incl_tax`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10, :yp11, :yp12, :yp13, :yp14, :yp15, :yp16, :yp17, :yp18, :yp19, :yp20, :yp21, :yp22, :yp23, :yp24, :yp25, :yp26, :yp27, :yp28, :yp29, :yp30, :yp31, :yp32, :yp33, :yp34, :yp35, :yp36, :yp37, :yp38, :yp39, :yp40, :yp41, :yp42, :yp43, :yp44, :yp45, :yp46, :yp47, :yp48, :yp49, :yp50, :yp51, :yp52, :yp53, :yp54, :yp55, :yp56, :yp57, :yp58, :yp59, :yp60, :yp61, :yp62, :yp63, :yp64)

 

3 answers

Profile photo of Mall Staff 184060.00 $tone September 6, 2018
Public

Hi Fabrice,

Message: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field ‘custom_discount’ doesn’t have a default value. The SQL statement executed was: INSERT INTO `sales_order` (`total_item_count`, `paypal_ipn_customer_notified`, 

That issue related to a custom field named ‘custom_discount’ in the table sales_order. It seems this field was added by a third-party extension you are using in your M2 instance or you had created that manually at your end.

To solve that issue, you need to set a default value for that field.
Regards,
Mall.
 

#1
Profile photo of Fabrice Fetsch 100.00 $tone September 6, 2018
Public

Hi Mall,
done that. i had to fix a couple of tables now it’s running. thankx
for the record I also facing this error
Message: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1364 Field ‘custom_discount’ doesn’t have a default value. The SQL statement executed was: INSERT INTO `quote_address` (`quote_id`, `updated_at`, `save_in_address_book`, `same_as_billing`, `collect_shipping_rates`, `weight`, `subtotal`, `base_subtotal`, `subtotal_with_discount`, `base_subtotal_with_discount`, `tax_amount`, `base_tax_amount`, `shipping_amount`, `base_shipping_amount`, `discount_amount`, `base_discount_amount`, `grand_total`, `base_grand_total`, `free_shipping`, `created_at`, `customer_id`, `customer_address_id`, `address_type`, `email`, `firstname`, `lastname`, `street`, `city`, `region`, `region_id`, `postcode`, `country_id`, `telephone`, `shipping_tax_amount`, `base_shipping_tax_amount`, `applied_taxes`, `shipping_discount_amount`, `base_shipping_discount_amount`, `subtotal_incl_tax`, `shipping_incl_tax`, `base_shipping_incl_tax`) VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8, :yp9, :yp10, :yp11, :yp12, :yp13, :yp14, :yp15, :yp16, :yp17, :yp18, :yp19, :yp20, :yp21, :yp22, :yp23, :yp24, :yp25, :yp26, :yp27, :yp28, :yp29, :yp30, :yp31, :yp32, :yp33, :yp34, :yp35, :yp36, :yp37, :yp38, :yp39, :yp40)
 
that seems to be a Magento 2 mistake in database, solved by using
ALTER TABLE `quote_address` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘Updated At’; 

#2
Profile photo of Mall Staff 184060.00 $tone September 6, 2018
Public

Hi there,

done that. i had to fix a couple of tables now it’s running. thankx

Yes, please continue with data migration at your end and let me know if you need any further assistance.

that seems to be a Magento 2 mistake in database, solved by using
ALTER TABLE `quote_address` CHANGE `updated_at` `updated_at` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘Updated At’; 

The SQL you mentioned does not associate with the error related to the ‘custom_discount’ field though.
Regards,
Mall.
 

#3

Please login or Register to Submit Answer

Written By

Comments