Open cheebamba opened 7 years ago
I get the same error. :\
I get the same issue also.
same errore Please help
Have the same issue please help
As said in https://github.com/antonioribeiro/tracker/issues/250, should be fixed now.
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'
Seems to be related to this issue: https://github.com/laravel/framework/issues/3602
I was able to get pass this, but then i get error in last migration:
Illuminate\Database\QueryException {#675
#sql: "alter table `tracker_agents` add unique `tracker_agents_name_unique`(`name`)"
#bindings: []
#message: "SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'name' used in key specification without a key length (SQL: alter table `tracker_agents` add unique `
tracker_agents_name_unique`(`name`))"
#code: "42000"
So i did this migration manually by changing sql to:
alter table tracker_agents
add unique tracker_agents_name_unique
(name
(255))
I'm able to confirm the tracker migrations breaking on Laravel 5.4 install.
It breaks at the point where I'm migrating the tables.
Screenshot as follows.
It's probably related to the changes made to MySQL new uft8 charset.
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:
Posted and answered it on StackOverflow:
This is due to sql mode [STRICT_TRANS_TABLES][1], so you have three options:
1) Fix your migrations.
2) Change strict to false in your mysql connection:
'mysql' => $database = [
...
'strict' => false,
...
],
Which will disable all those sql modes:
set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
3) Set custom modes, removing STRICT_TRANS_TABLES
'mysql' => $database = [
...
'modes' => "set session sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'",
...
],
So, we should investigate it and probably do nr 1) on Tracker, right?
`Illuminate\Database\QueryException {#896
tracker_agents
drop index tracker_agents_name_unique
"tracker_agents
drop index tracker_agents_name_unique
)"-previous: PDOException {#895
#code: "42000"
#file: "/home/nipun/Documents/Projects/cs_web/vendor/laravel/framework/src/Illuminate/Database/Connection.php"
#line: 457
+errorInfo: array:3 [
0 => "42000"
1 => 1091
2 => "Can't DROP 'tracker_agents_name_unique'; check that column/key exists"
]
-trace: {
25. PDOStatement->execute() ==> new PDOException(): {
src: {
/home/nipun/Documents/Projects/cs_web/vendor/laravel/framework/src/Illuminate/Database/Connection.php:457: """
\n
return $me->getPdo()->prepare($query)->execute($bindings);\n
});\n
"""
}
}
24. Illuminate\Database\Connection->Illuminate\Database\{closure}() ==> PDOStatement->execute(): {
src: {
/home/nipun/Documents/Projects/cs_web/vendor/laravel/framework/src/Illuminate/Database/Connection.php:457: """
\n
return $me->getPdo()->prepare($query)->execute($bindings);\n
});\n
"""
}
args: array:1 [
0 => []
]
}
23. Illuminate\Database\Connection->runQueryCallback() ==> Illuminate\Database\Connection->Illuminate\Database\{closure}(): {
src: {
/home/nipun/Documents/Projects/cs_web/vendor/laravel/framework/src/Illuminate/Database/Connection.php:722: """
try {\n
$result = $callback($this, $query, $bindings);\n
}\n
"""
}
args: array:3 [
0 => Illuminate\Database\MySqlConnection {#907
#pdo: PDO {#899
inTransaction: true
attributes: {
CASE: NATURAL
ERRMODE: EXCEPTION
AUTOCOMMIT: 1
PERSISTENT: false
DRIVER_NAME: "mysql"
SERVER_INFO: "Uptime: 262557 Threads: 6 Questions: 2389 Slow queries: 0 Opens: 721 Flush tables: 1 Open tables: 89 Queries per second avg: 0.009"
ORACLE_NULLS: NATURAL
CLIENT_VERSION: "mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $"
SERVER_VERSION: "5.7.11"
STATEMENT_CLASS: array:1 [
0 => "PDOStatement"
]
`
Is this the same issue ? I am getting this output when trying to migrate.
and also I am using,
'strict' => false,
Any idea what went wrong ?
Same as @nipun5perera. Tried it again, fresh pull of the latest Tracker. Set strict to false. Still getting the 42000 error.
Any luck trying to solve this ?
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.
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();
Not sure if this is related, but I am having issues with migrating. When I run php artisan migrate:refresh
it removes all my existing tables and only populates with the tracker, reset password, and users tables. I've spent a few hours trying to debug why it only pulls in those tables, but haven't had any luck.
I just removed the 'fix_agent_name' migration and everything worked as intented
Thanxs for update,
Also have already done the same adn everything is alright now
On Wed, Mar 22, 2017 at 8:22 AM, Austin Teague notifications@github.com wrote:
I just removed the 'fix_agent_name' migration and everything worked as intented
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/antonioribeiro/tracker/issues/249#issuecomment-288301660, or mute the thread https://github.com/notifications/unsubscribe-auth/ATRlDcZX5akn8OFEiqLFYfjSLlEB8y3mks5roLARgaJpZM4MBj1U .
Solved it.
2017_01_31_311101_fix_agent_name.php
.2015_03_07_311076_create_tracker_agents_table.php
, change line 26
from
$table->string('name')->unique();
to
$table->name('name', 255)->unique();
Or you could change 2017_01_31_311101_fix_agent_name.php
replacing
$table->mediumText('name')->unique()->change();
with
$table->string('name', 1024)->unique()->change();
I used database prefix which was an issue. Solution is replacing
$table->dropUnique('tracker_agents_name_unique');
with
$table->dropUnique(['name']);
When installing tracker on fresh Laravel 5.4 i get this error: