Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

MariaDB – Invalid default value for 'created'

I use MariaDB 5.5.68 and I get an error when I try to import database to server

#1067 - Invalid default value for 'created'

Code part

CREATE TABLE `wp_payments` (
  `id` int(10) UNSIGNED NOT NULL,
  `order_id` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `amount` int(10) UNSIGNED DEFAULT '0',
  `phone_number` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `payment_id` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `failed_reason` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `salt` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `status` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT 'pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

How to solve this problem?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to change the type of column created from datetime to TIMESTAMP

CREATE TABLE `wp_payments` (
  `id` int(10) UNSIGNED NOT NULL,
  `order_id` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `amount` int(10) UNSIGNED DEFAULT '0',
  `phone_number` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `payment_id` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `failed_reason` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `salt` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT '',
  `status` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT 'pending'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

DB Fiddle Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading