Hallo,
ich habe in Laravel folgendes Migrations Script:
Wenn ich die Migration nun ausführe, kommt der Fehler:
Kopiere ich das SQL Statement und führe es von Hand aus (phpMyAdmin oder MySQL Console) dann geht es ohne Probleme. Jemand eine Idee?
Lieben Gruß
Kerstel
ich habe in Laravel folgendes Migrations Script:
PHP-Code:
$tableName = 'oxacceptedterms';
Schema::dropIfExists($tableName);
Schema::create($tableName, function (Blueprint $table) {
$table->engine = 'MyISAM';
$table->char('OXUSERID', 32)->charset('latin1')->collation('latin1_general_ci')->comment('User id (oxuser)');
$table->char('OXSHOPID', 32)->charset('latin1')->collation('latin1_general_ci')->default('')->comment('Shop id (oxshops)');
$table->char('OXTERMVERSION', 32)->charset('latin1')->collation('latin1_general_ci')->default('')->comment('Terms version');
$table->dateTime('OXACCEPTEDTIME')->default('0000-00-00 00:00:00')->comment('Time, when terms were accepted');
$table->timestamp('OXTIMESTAMP')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'))->comment('Timestamp');
$table->primary(['OXUSERID', 'OXSHOPID']);
});
DB::statement("ALTER TABLE `{$tableName}` comment 'Shows which users has accepted shop terms'");
Code:
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'OXACCEPTEDTIME' (SQL: create table `oxacceptedterms` (`OXUSERID` char(32) character set latin1 collate latin1_general_ci not null comment 'User id (oxuser)', `OXSHOPID` char(32) character set latin1 collate latin1_general_ci not null default '' comment 'Shop id (oxshops)', `OXTERMVERSION` char(32) character set latin1 collate latin1_general_ci not null default '' comment 'Terms version', `OXACCEPTEDTIME` datetime not null default '0000-00-00 00:00:00' comment 'Time, when terms were accepted', `OXTIMESTAMP` timestamp not null default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'Timestamp') default character set utf8 collate utf8_unicode_ci engine = MyISAM)
Lieben Gruß
Kerstel
Kommentar