diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-08-28 23:56:21 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-09-09 22:56:03 +0200 |
commit | 54bdc95cc15853c42eac6e306aadcc325b6e74a2 (patch) | |
tree | 100863f3e26c3d9387d9a6e0a1745145adf9b1ba /apps/workflowengine | |
parent | 4c717884e3a384d7b97d88aa749ae0130750924d (diff) | |
download | nextcloud-server-54bdc95cc15853c42eac6e306aadcc325b6e74a2.tar.gz nextcloud-server-54bdc95cc15853c42eac6e306aadcc325b6e74a2.zip |
fix missing value and run against empty tables in migration script
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/workflowengine')
-rw-r--r-- | apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php | 4 | ||||
-rw-r--r-- | apps/workflowengine/lib/Migration/Version2019Date20190808074233.php | 28 |
2 files changed, 17 insertions, 15 deletions
diff --git a/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php b/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php index 8b3f3d5a9c3..f715ebc7ef7 100644 --- a/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php +++ b/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php @@ -58,7 +58,7 @@ class PopulateNewlyIntroducedDatabaseFields implements IRepairStep { $qb = $this->dbc->getQueryBuilder(); $qb->update('flow_operations') - ->set('entity', File::class) + ->set('entity', $qb->createNamedParameter(File::class)) ->where($qb->expr()->emptyString('entity')) ->execute(); @@ -70,8 +70,8 @@ class PopulateNewlyIntroducedDatabaseFields implements IRepairStep { $insertQuery = $qb->insert('flow_operations_scope'); while($id = $ids->fetchColumn(0)) { $insertQuery->values(['operation_id' => $qb->createNamedParameter($id), 'type' => IManager::SCOPE_ADMIN]); + $insertQuery->execute(); } - $insertQuery->execute(); } protected function getIdsWithoutScope(): Statement { diff --git a/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php b/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php index ffea3c88d01..6ac48616b16 100644 --- a/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php +++ b/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php @@ -70,13 +70,11 @@ class Version2019Date20190808074233 extends SimpleMigrationStep { $table->addColumn('operation', Type::TEXT, [ 'notnull' => false, ]); - $this->addEntityColumns($table); + $this->ensureEntityColumns($table); $table->setPrimaryKey(['id']); } else { $table = $schema->getTable('flow_operations'); - if(!$table->hasColumn('entity')) { - $this->addEntityColumns($table); - } + $this->ensureEntityColumns($table); } if (!$schema->hasTable('flow_operations_scope')) { @@ -105,14 +103,18 @@ class Version2019Date20190808074233 extends SimpleMigrationStep { return $schema; } - protected function addEntityColumns(Table $table) { - $table->addColumn('entity', Type::STRING, [ - 'notnull' => true, - 'length' => 256, - ]); - $table->addColumn('events', Type::TEXT, [ - 'notnull' => true, - 'default' => '[]', - ]); + protected function ensureEntityColumns(Table $table) { + if(!$table->hasColumn('entity')) { + $table->addColumn('entity', Type::STRING, [ + 'notnull' => true, + 'length' => 256, + ]); + } + if(!$table->hasColumn('events')) { + $table->addColumn('events', Type::TEXT, [ + 'notnull' => true, + 'default' => '[]', + ]); + } } } |