diff options
author | Simon L <szaimen@e.mail.de> | 2023-03-14 13:14:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 13:14:06 +0100 |
commit | ea6b4c69c97bec407c2c420b6410d7ea6a55d4b2 (patch) | |
tree | 2f95d935e1328746f3bf3d07e47c65bb346a4778 | |
parent | 5af2aa1e8150a6eeffe3e026b194a46ce3261ead (diff) | |
parent | 2f0c60dccca026d24dfd7b9d66d8e490640beac9 (diff) | |
download | nextcloud-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.php | 6 | ||||
-rw-r--r-- | tests/lib/DB/MigratorTest.php | 24 |
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); |