EDIT: Saat memperbarui basis data yang ada dari mysql 5.6 dan menjalankan:
UPDATE phppos_register_log SET shift_end = '2015-01-01 00:00:00' WHERE shift_end = '0000-00-00 00:00:00';
Ini menghasilkan:
#1292 - Incorrect datetime value: '0000-00-00 00:00:00' for column 'shift_end' at row 1
#1067 - Invalid default value for 'shift_start'
Ini berfungsi di mysql <= 5.7. Saya tidak dapat menemukan dokumentasi tentang ini ... Apa masalah dengan ini?
CREATE TABLE `phppos_register_log` (
`register_log_id` int(10) NOT NULL AUTO_INCREMENT,
`employee_id_open` int(10) NOT NULL,
`employee_id_close` int(11) DEFAULT NULL,
`register_id` int(11) DEFAULT NULL,
`shift_start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`shift_end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`open_amount` decimal(23,10) NOT NULL,
`close_amount` decimal(23,10) NOT NULL,
`cash_sales_amount` decimal(23,10) NOT NULL,
`total_cash_additions` decimal(23,10) NOT NULL DEFAULT '0.0000000000',
`total_cash_subtractions` decimal(23,10) NOT NULL DEFAULT '0.0000000000',
`notes` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`deleted` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`register_log_id`),
KEY `phppos_register_log_ibfk_1` (`employee_id_open`),
KEY `phppos_register_log_ibfk_2` (`register_id`),
KEY `phppos_register_log_ibfk_3` (`employee_id_close`),
CONSTRAINT `phppos_register_log_ibfk_1` FOREIGN KEY (`employee_id_open`) REFERENCES `phppos_employees` (`person_id`),
CONSTRAINT `phppos_register_log_ibfk_2` FOREIGN KEY (`register_id`) REFERENCES `phppos_registers` (`register_id`),
CONSTRAINT `phppos_register_log_ibfk_3` FOREIGN KEY (`employee_id_close`) REFERENCES `phppos_employees` (`person_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
NO_ZERO_DATE
, yang sekarang merupakan bagian dari konfigurasi default. Bisakah kamu mengkonfirmasi? TolongSELECT @@SQL_MODE;
.Jawaban:
sejak mysql 5.7,
SQL_MODE
nilai standarnya adalahstrict
, silakan lihat halaman ini: /programming/9192027/invalid-default-value-for-create-date-timestamp-fieldsumber