我已经使用 Brew 在我的 mac 上安装了 percona-server 用于本地开发
┌─(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)
我正在尝试运行此查询
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
当它必须创建 updated_at
列时它会窒息,因为 timestamp default 0
。 sql stmt 是在我的 Laravel 4.2 PHP 应用程序中创建的。
有没有办法放宽这些限制以使其发挥作用?
这是准确的错误
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'
当我们在我的同事数据库上尝试这个时,我们没有遇到这个问题。他在运行:
mysql Ver 14.14 Distrib 5.5.38,适用于使用 readline 6.2 的 debian-linux-gnu (x86_64)
最佳答案
必须从我的 /etc/my.cnf
(或您的 MySQL 配置所在的任何位置)中删除两个 sql-mode
以允许 laravel 迁移正常工作。
NO_ZERO_DATE
和 NO_ZERO_IN_DATE
关于mysql - percona 时间戳默认 0 不为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25650395/