fix missing value and run against empty tables in migration script
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
4c717884e3
commit
54bdc95cc1
|
@ -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 {
|
||||
|
|
|
@ -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' => '[]',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue