From 2959e15c7a23fd939a6341a70b856752efdf17a1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 24 Sep 2019 11:01:18 +0200 Subject: Fix "Cannot add a NOT NULL column with default value NULL" Signed-off-by: Joas Schilling --- .../Migration/Version2000Date20190808074233.php | 129 +++++++++++++++++++++ .../Migration/Version2019Date20190808074233.php | 120 ------------------- 2 files changed, 129 insertions(+), 120 deletions(-) create mode 100644 apps/workflowengine/lib/Migration/Version2000Date20190808074233.php delete mode 100644 apps/workflowengine/lib/Migration/Version2019Date20190808074233.php (limited to 'apps/workflowengine/lib') diff --git a/apps/workflowengine/lib/Migration/Version2000Date20190808074233.php b/apps/workflowengine/lib/Migration/Version2000Date20190808074233.php new file mode 100644 index 00000000000..c048ffbb5be --- /dev/null +++ b/apps/workflowengine/lib/Migration/Version2000Date20190808074233.php @@ -0,0 +1,129 @@ +hasTable('flow_checks')) { + $table = $schema->createTable('flow_checks'); + $table->addColumn('id', Type::INTEGER, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('class', Type::STRING, [ + 'notnull' => true, + 'length' => 256, + 'default' => '', + ]); + $table->addColumn('operator', Type::STRING, [ + 'notnull' => true, + 'length' => 16, + 'default' => '', + ]); + $table->addColumn('value', Type::TEXT, [ + 'notnull' => false, + ]); + $table->addColumn('hash', Type::STRING, [ + 'notnull' => true, + 'length' => 32, + 'default' => '', + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['hash'], 'flow_unique_hash'); + } + + if (!$schema->hasTable('flow_operations')) { + $table = $schema->createTable('flow_operations'); + $table->addColumn('id', Type::INTEGER, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('class', Type::STRING, [ + 'notnull' => true, + 'length' => 256, + 'default' => '', + ]); + $table->addColumn('name', Type::STRING, [ + 'notnull' => true, + 'length' => 256, + 'default' => '', + ]); + $table->addColumn('checks', Type::TEXT, [ + 'notnull' => false, + ]); + $table->addColumn('operation', Type::TEXT, [ + 'notnull' => false, + ]); + $this->ensureEntityColumns($table); + $table->setPrimaryKey(['id']); + } else { + $table = $schema->getTable('flow_operations'); + $this->ensureEntityColumns($table); + } + + if (!$schema->hasTable('flow_operations_scope')) { + $table = $schema->createTable('flow_operations_scope'); + $table->addColumn('id', Type::BIGINT, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 4, + ]); + $table->addColumn('operation_id', Type::INTEGER, [ + 'notnull' => true, + 'length' => 4, + 'default' => 0, + ]); + $table->addColumn('type', Type::INTEGER, [ + 'notnull' => true, + 'length' => 4, + 'default' => 0, + ]); + $table->addColumn('value', Type::STRING, [ + 'notnull' => false, + 'length' => 64, + 'default' => '', + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope'); + } + + return $schema; + } + + protected function ensureEntityColumns(Table $table) { + if(!$table->hasColumn('entity')) { + $table->addColumn('entity', Type::STRING, [ + 'notnull' => true, + 'length' => 256, + 'default' => '', + ]); + } + if(!$table->hasColumn('events')) { + $table->addColumn('events', Type::TEXT, [ + 'notnull' => true, + 'default' => '[]', + ]); + } + } +} diff --git a/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php b/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php deleted file mode 100644 index 6ac48616b16..00000000000 --- a/apps/workflowengine/lib/Migration/Version2019Date20190808074233.php +++ /dev/null @@ -1,120 +0,0 @@ -hasTable('flow_checks')) { - $table = $schema->createTable('flow_checks'); - $table->addColumn('id', Type::INTEGER, [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 4, - ]); - $table->addColumn('class', Type::STRING, [ - 'notnull' => true, - 'length' => 256, - ]); - $table->addColumn('operator', Type::STRING, [ - 'notnull' => true, - 'length' => 16, - ]); - $table->addColumn('value', Type::TEXT, [ - 'notnull' => false, - ]); - $table->addColumn('hash', Type::STRING, [ - 'notnull' => true, - 'length' => 32, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['hash'], 'flow_unique_hash'); - } - - if (!$schema->hasTable('flow_operations')) { - $table = $schema->createTable('flow_operations'); - $table->addColumn('id', Type::INTEGER, [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 4, - ]); - $table->addColumn('class', Type::STRING, [ - 'notnull' => true, - 'length' => 256, - ]); - $table->addColumn('name', Type::STRING, [ - 'notnull' => true, - 'length' => 256, - ]); - $table->addColumn('checks', Type::TEXT, [ - 'notnull' => false, - ]); - $table->addColumn('operation', Type::TEXT, [ - 'notnull' => false, - ]); - $this->ensureEntityColumns($table); - $table->setPrimaryKey(['id']); - } else { - $table = $schema->getTable('flow_operations'); - $this->ensureEntityColumns($table); - } - - if (!$schema->hasTable('flow_operations_scope')) { - $table = $schema->createTable('flow_operations_scope'); - $table->addColumn('id', Type::BIGINT, [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 4, - ]); - $table->addColumn('operation_id', Type::INTEGER, [ - 'notnull' => true, - 'length' => 4, - ]); - $table->addColumn('type', Type::INTEGER, [ - 'notnull' => true, - 'length' => 4, - ]); - $table->addColumn('value', Type::STRING, [ - 'notnull' => false, - 'length' => 64, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['operation_id', 'type', 'value'], 'flow_unique_scope'); - } - - return $schema; - } - - 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' => '[]', - ]); - } - } -} -- cgit v1.2.3