From 551f1d8ce42ff438a8bd349df61d84f1b415d907 Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Thu, 8 Jul 2021 11:58:24 -0300 Subject: [PATCH] Allow nunlable to booleans needed due NC 22 changes. --- appinfo/info.xml | 4 +- lib/Db/Task.php | 24 ---------- lib/Db/TaskMapper.php | 23 --------- .../Version000204Date20200530211356.php | 29 ----------- .../Version000205Date20200604122312.php | 2 +- .../Version00720Date20210708130231.php | 48 +++++++++++++++++++ 6 files changed, 51 insertions(+), 79 deletions(-) delete mode 100644 lib/Db/Task.php delete mode 100644 lib/Db/TaskMapper.php create mode 100644 lib/Migration/Version00720Date20210708130231.php diff --git a/appinfo/info.xml b/appinfo/info.xml index bb3c1cb..88716b2 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Quick notes Quick notes with a basic rich text Quick notes with a basic rich text - 0.7.1 + 0.7.2 agpl Matias De lellis QuickNotes @@ -20,6 +20,6 @@ https://raw.githubusercontent.com/matiasdelellis/quicknotes/master/doc/quicknotes-attachments.jpeg https://raw.githubusercontent.com/matiasdelellis/quicknotes/master/doc/quicknotes-shared-note.jpeg - + diff --git a/lib/Db/Task.php b/lib/Db/Task.php deleted file mode 100644 index f087161..0000000 --- a/lib/Db/Task.php +++ /dev/null @@ -1,24 +0,0 @@ - $this->id, - 'description' => $this->description, - 'done' => $this->done, - 'ordering' => $this->ordering, - 'noteId' => $this->noteId - ]; - } -} \ No newline at end of file diff --git a/lib/Db/TaskMapper.php b/lib/Db/TaskMapper.php deleted file mode 100644 index 6fbbc9f..0000000 --- a/lib/Db/TaskMapper.php +++ /dev/null @@ -1,23 +0,0 @@ -findEntity($sql, [$id, $noteId]); - } - - public function findAll($noteId) { - $sql = 'SELECT * FROM *PREFIX*quicknotes_tasks WHERE note_id = ?'; - return $this->findEntities($sql, [$noteId]); - } - -} \ No newline at end of file diff --git a/lib/Migration/Version000204Date20200530211356.php b/lib/Migration/Version000204Date20200530211356.php index d229f4e..f2a54cb 100644 --- a/lib/Migration/Version000204Date20200530211356.php +++ b/lib/Migration/Version000204Date20200530211356.php @@ -127,35 +127,6 @@ class Version000204Date20200530211356 extends SimpleMigrationStep { $table->setPrimaryKey(['id']); } - if (!$schema->hasTable('quicknotes_tasks')) { - $table = $schema->createTable('quicknotes_tasks'); - $table->addColumn('id', 'bigint', [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 8, - 'unsigned' => true, - ]); - $table->addColumn('note_id', 'bigint', [ - 'notnull' => true, - 'length' => 8, - 'unsigned' => true, - ]); - $table->addColumn('description', 'string', [ - 'notnull' => true, - 'length' => 200, - 'default' => '', - ]); - $table->addColumn('done', 'boolean', [ - 'notnull' => true, - 'default' => false, - ]); - $table->addColumn('ordering', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - } - if (!$schema->hasTable('quicknotes_shares')) { $table = $schema->createTable('quicknotes_shares'); $table->addColumn('id', 'bigint', [ diff --git a/lib/Migration/Version000205Date20200604122312.php b/lib/Migration/Version000205Date20200604122312.php index c2ce3fa..d22846f 100644 --- a/lib/Migration/Version000205Date20200604122312.php +++ b/lib/Migration/Version000205Date20200604122312.php @@ -26,7 +26,7 @@ class Version000205Date20200604122312 extends SimpleMigrationStep { $table = $schema->getTable('quicknotes_notes'); $table->addColumn('pinned', 'boolean', [ - 'notnull' => true, + 'notnull' => false, 'default' => false, ]); return $schema; diff --git a/lib/Migration/Version00720Date20210708130231.php b/lib/Migration/Version00720Date20210708130231.php new file mode 100644 index 0000000..e49df60 --- /dev/null +++ b/lib/Migration/Version00720Date20210708130231.php @@ -0,0 +1,48 @@ +hasTable('quicknotes_tasks')) { + $schema->dropTable('quicknotes_tasks'); + } + + $this->ensureColumnIsNullable($schema, 'quicknotes_notes', 'pinned'); + + return $schema; + } + + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { + $table = $schema->getTable($tableName); + $column = $table->getColumn($columnName); + + if ($column->getNotnull()) { + $column->setNotnull(false); + return true; + } + + return false; + } + +}