Open dersonsena opened 6 years ago
Are you able to reproduce it on clean basic application template?
Firstly, thanks for your answer @samdark ! In a clean basic template application is working. However, a few days ago I used the migrations tools and was working normally. I dont changed nothing in the core, I only running yesterday and appears this error.
What would this "version" that is returning? I tried fix, but, not successful. Can you help me?
Sorry! The single thing that I changed was the composer.json
requirements. See below:
PS: I dont know if this has anything to do with the error, but, was the single modification.
{
"name": "yiisoft/yii2-app-advanced",
"description": "Cadimo WEB",
"authors": [
{
"name": "Kilderson Sena",
"email": "kilderson@imobsoft.com.br"
},
{
"name": "Diego Pedrosa",
"email": "diego@imobsoft.com.br"
}
],
"homepage": "http://www.cadimoweb.com.br",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"require": {
"php": ">=7",
"ext-intl": "*",
"ext-mbstring": "*",
"ext-soap": "*",
"yiisoft/yii2": "~2.0.11",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-swiftmailer": "~2.0.0",
"yiisoft/yii2-jui": "~2.0.0",
"kartik-v/yii2-widget-growl": "*",
"kartik-v/yii2-widget-activeform": "^1.4",
"kartik-v/yii2-widget-select2": "2.0.8",
"kartik-v/yii2-widget-datepicker": "@dev",
"kartik-v/bootstrap-fileinput": "dev-master",
"yiibr/yii2-br-validator": "*",
"mpdf/mpdf": "^6.1",
"kartik-v/yii2-widget-fileinput": "@dev",
"bower-asset/jquery-numeric_input": "@dev",
"bower-asset/bootstrap-datepicker": "@dev",
"bower-asset/lightbox2": "*",
"bower-asset/jquery-maskmoney": "^3.0.2",
"bower-asset/bootstrap-toggle": "^2.2",
"bower-asset/select2": "^4.0",
"bower-asset/bootstrap-fileinput": "^4.4",
"bower-asset/summernote": "^0.8.6",
"dersonsena/yii2-widget-inputsaddon": "@dev",
"dersonsena/cadimoweb-gii": "^1"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",
"yiisoft/yii2-gii": "~2.0.0",
"yiisoft/yii2-faker": "~2.0.0",
"codeception/base": "^2.2.3",
"codeception/verify": "~0.3.1",
"codeception/codeception": "^2.3",
"deployer/deployer": "^6.0"
},
"config": {
"process-timeout": 1800
}
}
How does your migration table look like? Did you accidentally create a migration
table with a wrong structure manually?
Hi @schmunk42 ! In fact, when I execute the command it already issues this error. Since it is something version related, I will put another version of my postgresql.
I just discovered the problem! I had a similar issue with this issue https://github.com/yiisoft/yii2/issues/13229 by commit #8f5f5
The error is giving in the method below:
protected function getMigrationNameLimit()
{
if ($this->_migrationNameLimit !== null) {
return $this->_migrationNameLimit;
}
$tableSchema = $this->db->schema ? $this->db->schema->getTableSchema($this->migrationTable, true) : null;
if ($tableSchema !== null) {
// The error happens in the line below...
return $this->_migrationNameLimit = $tableSchema->columns['version']->size;
}
return static::MAX_NAME_LENGTH;
}
If run the print_r($tableSchema->columns)
returns:
Array
(
[VERSION] => yii\db\ColumnSchema Object
(
[name] => VERSION
[allowNull] =>
[type] => string
[phpType] => string
[dbType] => varchar
[defaultValue] =>
[enumValues] =>
[size] => 180
[precision] =>
[scale] =>
[isPrimaryKey] => 1
[autoIncrement] =>
[unsigned] =>
[comment] =>
)
[APPLY_TIME] => yii\db\ColumnSchema Object
(
[name] => APPLY_TIME
[allowNull] => 1
[type] => integer
[phpType] => integer
[dbType] => int4
[defaultValue] =>
[enumValues] =>
[size] =>
[precision] => 32
[scale] => 0
[isPrimaryKey] =>
[autoIncrement] =>
[unsigned] =>
[comment] =>
)
)
All the fields in my database are in the uppercase, so it is necessary to make the same correction that was made in the issue quoted at the beginning:
protected function getMigrationNameLimit()
{
if ($this->_migrationNameLimit !== null) {
return $this->_migrationNameLimit;
}
$tableSchema = $this->db->schema ? $this->db->schema->getTableSchema($this->migrationTable, true) : null;
if ($tableSchema !== null) {
if ($this->db->slavePdo->getAttribute(\PDO::ATTR_CASE) === \PDO::CASE_UPPER) {
$tableSchema->columns = array_change_key_case($tableSchema->columns, CASE_LOWER);
}
return $this->_migrationNameLimit = $tableSchema->columns['version']->size;
}
return static::MAX_NAME_LENGTH;
}
I changed here locally and it worked =)
Tests also fail on PgSQL >=9.5 see https://github.com/yiisoft/yii2/issues/15254 - but the error looks not directly related.
maybe you upgraded your PgSQL version?
I'm using the PostgreSQL 9.6, but, this error appears in the versions 9.5 and 9.6! The code above worked in the 2 versions :)
@dersonsena try PostgreSQL 9.4
Hi @bscheshirwork! My production Postgresql Version is 9.5, so .... my Postgresql container it has to be highter 9.5. But, this solution above fix the problem... How @klimov-paul helped me in another issue ;)
@dersonsena you can add link to @klimov-paul 's comment?
PostgreSQL v9.5 not convert default values to column format. check your default value for this problem. int column can contain string default value float column can contain string default value
10.0 also not convert CURRENT_TIMESTAMP to now(), convert to string 'CURRENT_TIMESTAMP'
But in the issue that was solved the problem was the uppercase array keys. Same thing happened here. Upstairs has the commit links and the issue.
Hi everyone!
I trying to use Yii Migrations with the follow command:
./yii migrate/create migration_name
and the Migration Tool return the error below:
I dont find out nothing about this, so... I created the issue here for this.