mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Merge pull request #37003 from nextcloud/backport/36803/stable25
[stable25] [db]: Remove not supported column comments for SQLite
This commit is contained in:
commit
fb594fc6ab
2 changed files with 29 additions and 1 deletions
|
|
@ -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'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue