Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Migration/Version2400Date202201301329.php')
-rw-r--r--lib/Migration/Version2400Date202201301329.php162
1 files changed, 162 insertions, 0 deletions
diff --git a/lib/Migration/Version2400Date202201301329.php b/lib/Migration/Version2400Date202201301329.php
new file mode 100644
index 0000000..0290be5
--- /dev/null
+++ b/lib/Migration/Version2400Date202201301329.php
@@ -0,0 +1,162 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OCA\FullTextSearch\Migration;
+
+use Closure;
+use OCA\FullTextSearch\Service\ConfigService;
+use OCP\DB\Exception;
+use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+/**
+ * Auto-generated migration step: Please modify to your needs!
+ */
+class Version2400Date202201301329 extends SimpleMigrationStep {
+
+
+ /** @var IDBConnection */
+ private $dbConnection;
+
+ /** @var ConfigService */
+ private $configService;
+
+
+ /**
+ * @param IDBConnection $dbConnection
+ * @param ConfigService $configService
+ */
+ public function __construct(IDBConnection $dbConnection, ConfigService $configService) {
+ $this->dbConnection = $dbConnection;
+ $this->configService = $configService;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ *
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('fulltextsearch_index')) {
+ $table = $schema->createTable('fulltextsearch_index');
+ $table->addColumn(
+ 'provider_id', 'string',
+ [
+ 'notnull' => true,
+ 'length' => 254,
+ ]
+ );
+ $table->addColumn(
+ 'document_id', 'string',
+ [
+ 'notnull' => true,
+ 'length' => 254,
+ ]
+ );
+ $table->addColumn(
+ 'collection', 'string',
+ [
+ 'default' => '',
+ 'notnull' => false,
+ 'length' => 31
+ ]
+ );
+ $table->addColumn(
+ 'source', 'string',
+ [
+ 'notnull' => false,
+ 'length' => 64,
+ ]
+ );
+ $table->addColumn(
+ 'owner_id', 'string',
+ [
+ 'notnull' => true,
+ 'length' => 64,
+ ]
+ );
+ $table->addColumn(
+ 'status', 'smallint',
+ [
+ 'notnull' => true,
+ 'length' => 1,
+ ]
+ );
+ $table->addColumn(
+ 'options', 'string',
+ [
+ 'notnull' => false,
+ 'length' => 511,
+ ]
+ );
+ $table->addColumn(
+ 'err', 'smallint',
+ [
+ 'notnull' => true,
+ 'length' => 1,
+ ]
+ );
+ $table->addColumn(
+ 'message', 'text',
+ [
+ 'notnull' => false,
+ ]
+ );
+ $table->addColumn(
+ 'indexed', 'bigint',
+ [
+ 'notnull' => false,
+ 'length' => 6,
+ 'unsigned' => true
+ ]
+ );
+ $table->setPrimaryKey(['provider_id', 'document_id', 'collection']);
+ $table->addIndex(['collection']);
+ $table->addIndex(['collection', 'provider_id', 'document_id', 'status'], 'cpds');
+ }
+
+ return $schema;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ *
+ * @throws Exception
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+ if (!$schema->hasTable('fulltextsearch_indexes')) {
+ return;
+ }
+
+ $query = $this->dbConnection->getQueryBuilder();
+ $query->select($query->func()->count('*', 'index_count'))
+ ->from('fulltextsearch_indexes');
+ $result = $query->executeQuery();
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ if ((int)$row['index_count'] > 0) {
+ $this->configService->setAppValue(ConfigService::MIGRATION_24, '0');
+ }
+ }
+}