Percona timestamp default 0 is not null

I used Brew to install a percona server on my mac for local development

┌─(veilig@Jamies-MacBook-Air:s018)──────────────(~/api.foo.com)─┐
└─(13:25:%)── brew info percona-server                                                      ──(Wed,Sep03 - feature/users)─┘
percona-server: stable 5.6.19-67.0 (bottled)

      

I am trying to run this query

create table `courses` (
   `id` varchar(36) not null,
   `title` varchar(255) not null,
   `created_at` timestamp default 0 not null,
   `updated_at` timestamp default 0 not null,
   `tokens` int not null default '0',
   `product_id` int null,
   `track_id` varchar(36) not null
) default character set utf8 collate utf8_unicode_ci

      

and his gasp when he needs to create a column updated_at

because timestamp default 0

. Sql stmt is generated from my Laravel 4.2 PHP application.

Is there some way to relax these restrictions to make this work?

This is the exact error

veilig@localhost (api_foo_com) > create table `courses` (`id` varchar(36) not null, `title` varchar(255) not null, `created_at` timestamp default 0 not null, `updated_at` timestamp default 0 not null, `tokens` int not null default '0', `product_id` int null, `track_id` varchar(36) not null) default character set utf8 collate utf8_unicode_ci;
ERROR 1067 (42000): Invalid default value for 'created_at'

      

When we try this on my colleagues' database, we don't run into this problem. He works:

mysql Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (x86_64) using readline 6.2

+3


source to share


1 answer


You will have to remove two sql-mode

from mine /etc/my.cnf

(or wherever your MySQL configurator is located) to allow larvel migrations to work correctly.



NO_ZERO_DATE

and NO_ZERO_IN_DATE

0


source







All Articles