Skip to content

SQLite does not support addCommentOnTable() #219

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

Open
Tigrov opened this issue Oct 17, 2023 · 0 comments
Open

SQLite does not support addCommentOnTable() #219

Tigrov opened this issue Oct 17, 2023 · 0 comments

Comments

@Tigrov
Copy link
Member

Tigrov commented Oct 17, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant