-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in migration createTable (and possible other) method when DB data type has more than one word #19759
Comments
What would you prefer? |
I prefer to implement the solution but there are two ways class m200000_000000_create_table_fruits extends \yii\db\Migration
{
public function safeUp()
{
$this->createTable('{{%fruits}}', [
'ts' => $this->timestamp()->null()->defaultExpression("(CURRENT_TIMESTAMP)"),
'ts2' => $this->timestamp()->null()->defaultValue("2011-11-11 00:00:00"),
'ts3' => $this->timestamp()->null()->defaultValue("2022-11-11 00:00:00"),
0 => '"ts4" timestamp NULL DEFAULT \'2022-11-11 00:00:00\'',
1 => '"ts5" timestamp NULL DEFAULT (CURRENT_TIMESTAMP)',
2 => '"ts6" timestamp NULL DEFAULT \'2000-11-11 00:00:00\'',
3 => '"d" date NULL DEFAULT (CURRENT_DATE + INTERVAL \'1 YEAR\')',
4 => '"d2" text NULL DEFAULT (CURRENT_DATE + INTERVAL \'1 YEAR\')',
5 => '"d3" text NULL DEFAULT \'text default\'',
'c7' => 'double precision null default null', <---- this will lead to error
6 => 'c8 double precision null default null', <---- this will not lead to error
'ts7' => $this->date()->null()->defaultExpression("(CURRENT_DATE + INTERVAL '1 YEAR')"),
]);
} so the solution for this bug is to use numeric index (or ignore index) and define column defination as shown above if physical data type needs to be used in migration. so at least a work-around is present for this bug. so at this moment the implementation is not needed and to conclude I prefer to just change the docs and add an example in the docs to use both ways |
Alright. Would you help updating docs? |
Yes |
double precision
is the SQL data type. It has two words.Consider method \yii\db\migration::createTable()
What steps will reproduce the problem?
What is the expected result?
This should create table in DB successfully.
What do you get instead?
I get SQL error: Part of SQL created was
'double precision precision' creates SQL syntax error.
Solution
2 Possibilities
createTable()
method and similar methods as mentioned below:Additional info
The text was updated successfully, but these errors were encountered: