Completed
Push — master ( 798cfb...d08acf )
by Maxence
01:34
created

Version2000Date20201208130255::preSchemaChange()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace OCA\FullTextSearch\Migration;
6
7
use Closure;
8
use OCP\DB\ISchemaWrapper;
9
use OCP\Migration\IOutput;
10
use OCP\Migration\SimpleMigrationStep;
11
12
/**
13
 * Auto-generated migration step: Please modify to your needs!
14
 */
15
class Version2000Date20201208130255 extends SimpleMigrationStep {
16
17
	/**
18
	 * @param IOutput $output
19
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20
	 * @param array $options
21
	 */
22
	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
23
	}
24
25
	/**
26
	 * @param IOutput $output
27
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28
	 * @param array $options
29
	 * @return null|ISchemaWrapper
30
	 */
31
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32
		/** @var ISchemaWrapper $schema */
33
		$schema = $schemaClosure();
34
35
		if (!$schema->hasTable('fulltextsearch_indexes')) {
36
			$table = $schema->createTable('fulltextsearch_indexes');
37
			$table->addColumn('provider_id', 'string', [
38
				'notnull' => true,
39
				'length' => 255,
40
			]);
41
			$table->addColumn('document_id', 'string', [
42
				'notnull' => true,
43
				'length' => 254,
44
			]);
45
			$table->addColumn('source', 'string', [
46
				'notnull' => false,
47
				'length' => 64,
48
			]);
49
			$table->addColumn('owner_id', 'string', [
50
				'notnull' => true,
51
				'length' => 64,
52
			]);
53
			$table->addColumn('status', 'smallint', [
54
				'notnull' => true,
55
				'length' => 1,
56
			]);
57
			$table->addColumn('options', 'string', [
58
				'notnull' => false,
59
				'length' => 511,
60
			]);
61
			$table->addColumn('err', 'smallint', [
62
				'notnull' => true,
63
				'length' => 1,
64
			]);
65
			$table->addColumn('message', 'string', [
66
				'notnull' => false,
67
				'length' => 8000,
68
			]);
69
			$table->addColumn('indexed', 'bigint', [
70
				'notnull' => false,
71
				'length' => 6,
72
			]);
73
			$table->setPrimaryKey(['provider_id', 'document_id']);
74
		}
75
76
		if (!$schema->hasTable('fulltextsearch_ticks')) {
77
			$table = $schema->createTable('fulltextsearch_ticks');
78
			$table->addColumn('id', 'bigint', [
79
				'autoincrement' => true,
80
				'notnull' => true,
81
				'length' => 7,
82
				'unsigned' => true,
83
			]);
84
			$table->addColumn('source', 'string', [
85
				'notnull' => false,
86
				'length' => 128,
87
			]);
88
			$table->addColumn('data', 'string', [
89
				'notnull' => false,
90
				'length' => 6000,
91
			]);
92
			$table->addColumn('status', 'string', [
93
				'notnull' => false,
94
				'length' => 32,
95
			]);
96
			$table->addColumn('action', 'string', [
97
				'notnull' => false,
98
				'length' => 64,
99
			]);
100
			$table->addColumn('first_tick', 'bigint', [
101
				'notnull' => false,
102
				'length' => 6,
103
			]);
104
			$table->addColumn('tick', 'bigint', [
105
				'notnull' => false,
106
				'length' => 6,
107
			]);
108
			$table->setPrimaryKey(['id']);
109
		}
110
		return $schema;
111
	}
112
113
	/**
114
	 * @param IOutput $output
115
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
116
	 * @param array $options
117
	 */
118
	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
119
	}
120
}
121