Skip to content

SQLite does not support addCommentOnTable() #219

@Tigrov

Description

@Tigrov

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

$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'

<?= $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,
]);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions