tracker: Laravel 5.4 migration problem

When installing tracker on fresh Laravel 5.4 i get this error:

PHP Fatal error:  Call to a member function getCode() on null in D:\_Instal\xampp\htdocs\cheebamba\vendor\laravel\framework\src\Illuminate\Database\QueryException.php on line 38


  [Symfony\Component\Debug\Exception\FatalErrorException]
  Call to a member function getCode() on null

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 23 (5 by maintainers)

Most upvoted comments

For those having SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at', you have to set strict => false on your database connection:

image

I did edit create_tracker_agents_table.php and changed ,

$table->string('name')->unique();

to

$table->string('name',255);

and then added

$table->unique('name');

so my create would look like this,

$table->bigIncrements('id'); $table->string('name',255); $table->string('browser')->index(); $table->string('browser_version'); $table->timestamp('created_at')->index(); $table->timestamp('updated_at')->index(); $table->unique('name');

and then edited fix_agent_name.php and changed

$table->mediumText('name')->unique()->change();

to

$table->string('name',255)->unique()->change();

for me this solved that key length problem and everything migrated successfully.

Solved it.

  1. Remove 2017_01_31_311101_fix_agent_name.php.
  2. On 2015_03_07_311076_create_tracker_agents_table.php, change line 26 from
$table->string('name')->unique();

to

$table->name('name', 255)->unique();

I just removed the ‘fix_agent_name’ migration and everything worked as intented

Yes, this error got fixed, but now im getting on newest Laravel and newest xampp and easyphp this error:

[Illuminate\Database\QueryException]
  SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at' (SQL: create table `tracker_paths` (`id` bigint unsigned not null auto_increment primar
  y key, `path` varchar(255) not null, `created_at` timestamp not null, `updated_at` timestamp not null) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB ROW_FO
  RMAT=DYNAMIC) (SQL: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at' (SQL: create table `tracker_paths` (`id` bigint unsigned not null a
  uto_increment primary key, `path` varchar(255) not null, `created_at` timestamp not null, `updated_at` timestamp not null) default character set utf8mb4 collate utf8mb4_unicode_ci en
  gine = InnoDB ROW_FORMAT=DYNAMIC))

[Illuminate\Database\QueryException]
  SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at' (SQL: create table `tracker_paths` (`id` bigint unsigned not null auto_increment primar
  y key, `path` varchar(255) not null, `created_at` timestamp not null, `updated_at` timestamp not null) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB ROW_FO
  RMAT=DYNAMIC)

[PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'updated_at'

Laravel’s default $table->timestamps() migration method calls nullable() on created_at and updated_at, so why aren’t we doing this when calling timestamp(‘created_at’)->index() ? Why not do this in each of the migrations:


                $table->timestamp('created_at')->nullable()->index();
                $table->timestamp('updated_at')->nullable()->index();