aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-03-14 13:14:06 +0100
committerGitHub <noreply@github.com>2023-03-14 13:14:06 +0100
commitea6b4c69c97bec407c2c420b6410d7ea6a55d4b2 (patch)
tree2f95d935e1328746f3bf3d07e47c65bb346a4778
parent5af2aa1e8150a6eeffe3e026b194a46ce3261ead (diff)
parent2f0c60dccca026d24dfd7b9d66d8e490640beac9 (diff)
downloadnextcloud-server-ea6b4c69c97bec407c2c420b6410d7ea6a55d4b2.tar.gz
nextcloud-server-ea6b4c69c97bec407c2c420b6410d7ea6a55d4b2.zip
Merge pull request #37004 from nextcloud/backport/36803/stable24
[stable24] [db]: Remove not supported column comments for SQLite
-rw-r--r--lib/private/DB/SQLiteMigrator.php6
-rw-r--r--tests/lib/DB/MigratorTest.php24
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/private/DB/SQLiteMigrator.php b/lib/private/DB/SQLiteMigrator.php
index 76138fee545..351b6f37640 100644
--- a/lib/private/DB/SQLiteMigrator.php
+++ b/lib/private/DB/SQLiteMigrator.php
@@ -40,9 +40,13 @@ class SQLiteMigrator extends Migrator {
$platform->registerDoctrineTypeMapping('smallint unsigned', 'integer');
$platform->registerDoctrineTypeMapping('varchar ', 'string');
- // with sqlite autoincrement columns is of type integer
foreach ($targetSchema->getTables() as $table) {
foreach ($table->getColumns() as $column) {
+ // column comments are not supported on SQLite
+ if ($column->getComment() !== null) {
+ $column->setComment(null);
+ }
+ // with sqlite autoincrement columns is of type integer
if ($column->getType() instanceof BigIntType && $column->getAutoincrement()) {
$column->setType(Type::getType('integer'));
}
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index af44159efa3..6e4574688fb 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -237,6 +237,30 @@ class MigratorTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
+ /**
+ * Test for nextcloud/server#36803
+ */
+ public function testColumnCommentsInUpdate() {
+ $startSchema = new Schema([], [], $this->getSchemaConfig());
+ $table = $startSchema->createTable($this->tableName);
+ $table->addColumn('id', 'integer', ['autoincrement' => true, 'comment' => 'foo']);
+ $table->setPrimaryKey(['id']);
+
+ $endSchema = new Schema([], [], $this->getSchemaConfig());
+ $table = $endSchema->createTable($this->tableName);
+ $table->addColumn('id', 'integer', ['autoincrement' => true, 'comment' => 'foo']);
+ // Assert adding comments on existing tables work (or at least does not throw)
+ $table->addColumn('time', 'integer', ['comment' => 'unix-timestamp', 'notnull' => false]);
+ $table->setPrimaryKey(['id']);
+
+ $migrator = $this->getMigrator();
+ $migrator->migrate($startSchema);
+
+ $migrator->migrate($endSchema);
+
+ $this->addToAssertionCount(1);
+ }
+
public function testAddingForeignKey() {
$startSchema = new Schema([], [], $this->getSchemaConfig());
$table = $startSchema->createTable($this->tableName);