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->addEventsColumn($table); $table->setPrimaryKey(['id']); } else { $table = $schema->getTable('flow_operations'); if(!$table->hasColumn('events')) { $this->addEventsColumn($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 addEventsColumn(Table $table) { $table->addColumn('events', Type::TEXT, [ 'notnull' => true, 'default' => '[]', ]); } }