-
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
SQLite does not support addCommentOnTable()
and addCommentOnColumn()
but supports comments in CREATE TABLE
query
CREATE TABLE `table_name` -- table comment
(
id INTEGER, -- field comment
);
The follow command throws an Exception
in SQLite
./yii migrate:create post --command=table --fields='name:string(50):comment("Student Name")'
Due to column comment is initialized separately
db-migration/src/MigrationBuilder.php
Lines 199 to 209 in 44f9ac4
$this->db->createCommand()->createTable($table, $columns, $options)->execute(); | |
/** @psalm-var array<string, string> $columns */ | |
foreach ($columns as $column => $type) { | |
if ($type instanceof ColumnInterface) { | |
$comment = $type->getComment(); | |
if ($comment !== null) { | |
$this->db->createCommand()->addCommentOnColumn($table, $column, $comment)->execute(); | |
} | |
} | |
} |
The same for the follow command
./yii migrate:create post --command=table --table-comment='Posts of blog'
db-migration/resources/views/createTableMigration.php
Lines 42 to 53 in 940d988
<?= $this->render(__DIR__ . '/_createTable.php', [ | |
'table' => $table, | |
'columns' => $columns, | |
'foreignKeys' => $foreignKeys, | |
]) | |
?> | |
<?php if (!empty($tableComment)) { | |
echo $this->render(__DIR__ . '/_addComments.php', [ | |
'table' => $table, | |
'tableComment' => $tableComment, | |
]); | |
} |
vjik
Metadata
Metadata
Assignees
Labels
No labels