-
Couldn't load subscription status.
- Fork 20
Description
Hi,
I've use: mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper
at migrate command have errors:
.Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'survey_stat_started_at'
you have to add default value for TIMESTAMP fieltds, e.g.:
'survey_stat_assigned_at' => $this->timestamp()->defaultExpression('CURRENT_TIMESTAMP'),
'survey_stat_started_at' => $this->timestamp()->defaultExpression('CURRENT_TIMESTAMP'),
'survey_stat_updated_at' => $this->timestamp()->defaultExpression('CURRENT_TIMESTAMP'),
'survey_stat_ended_at' => $this->timestamp()->defaultExpression('CURRENT_TIMESTAMP'),
in file:
m181018_070730_create_table_survey.php
m181018_070730_create_table_survey_stat.php
FULL error logs:
./yii migrate --migrationPath=@vendor/onmotion/yii2-survey/migrations
Yii Migration Tool (based on Yii v2.0.17)
Total 7 new migrations to be applied:
m181018_070730_create_table_survey
m181018_070730_create_table_survey_answer
m181018_070730_create_table_survey_question
m181018_070730_create_table_survey_stat
m181018_070730_create_table_survey_type
m181018_070730_create_table_survey_user_answer
m181018_070730_foreign_keys
Apply the above migrations? (yes|no) [no]:yes
*** applying m181018_070730_create_table_survey
> create table {{%survey}} ... done (time: 0.189s)
> create index fk_survey_created_by_idx on {{%survey}} (survey_created_by) ... done (time: 0.185s)
*** applied m181018_070730_create_table_survey (time: 0.416s)
*** applying m181018_070730_create_table_survey_answer
> create table {{%survey_answer}} ... done (time: 0.278s)
> create index fk_survey_answer_to_question_idx on {{%survey_answer}} (survey_answer_question_id) ... done (time: 0.227s)
*** applied m181018_070730_create_table_survey_answer (time: 0.531s)
*** applying m181018_070730_create_table_survey_question
> create table {{%survey_question}} ... done (time: 0.192s)
> create index fk_survey_question_to_survey_idx on {{%survey_question}} (survey_question_survey_id) ... done (time: 0.176s)
> create index fk_survey_question_to_type_idx on {{%survey_question}} (survey_question_type) ... done (time: 0.203s)
*** applied m181018_070730_create_table_survey_question (time: 0.607s)
*** applying m181018_070730_create_table_survey_stat
> create table {{%survey_stat}} ...Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'survey_stat_started_at'
The SQL being executed was: CREATE TABLE survey_stat (
survey_stat_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
survey_stat_survey_id int(11) UNSIGNED,
survey_stat_user_id int(11),
survey_stat_assigned_at timestamp(0),
survey_stat_started_at timestamp(0),
survey_stat_updated_at timestamp(0),
survey_stat_ended_at timestamp(0),
survey_stat_ip varchar(255),
survey_stat_is_done tinyint(1) DEFAULT '0',
survey_stat_hash char(32)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'
in /var/www/www.z.pl/vendor/yiisoft/yii2/db/Schema.php:664
Error Info:
Array
(
[0] => 42000
[1] => 1067
[2] => Invalid default value for 'survey_stat_started_at'
)
Stack trace:
#0 /var/www/www.cocos.pl/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE s...') #1 /var/www/www.cocos.pl/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('CREATE TABLE s...')
#2 /var/www/www.cocos.pl/vendor/yiisoft/yii2/db/Migration.php(323): yii\db\Command->execute()
#3 /var/www/www.cocos.pl/vendor/onmotion/yii2-survey/migrations/m181018_070730_create_table_survey_stat.php(14): yii\db\Migration->createTable('{{%survey_stat}...', Array, 'CHARACTER SET u...')
#4 /var/www/www.cocos.pl/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(725): m181018_070730_create_table_survey_stat->up()
#5 /var/www/www.cocos.pl/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m181018_070730_...')
#6 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#7 /var/www/www.cocos.pl/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#8 /var/www/www.cocos.pl/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#9 /var/www/www.cocos.pl/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('', Array)
#10 /var/www/www.cocos.pl/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#11 /var/www/www.cocos.pl/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#12 /var/www/www.cocos.pl/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#13 /var/www/www.cocos.pl/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#14 /var/www/www.cocos.pl/yii(20): yii\base\Application->run()
#15 {main}