Passed
Push — master ( 7ad038...6c6f41 )
by Morris
13:41 queued 10s
created

Version1010Date20200630192639   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 35
c 1
b 0
f 0
dl 0
loc 52
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A changeSchema() 0 45 2
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * @copyright Copyright (c) 2020 Joas Schilling <[email protected]>
6
 *
7
 * @author Joas Schilling <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
namespace OCA\Files_Trashbin\Migration;
27
28
use Closure;
29
use Doctrine\DBAL\Types\Types;
30
use OCP\DB\ISchemaWrapper;
31
use OCP\Migration\IOutput;
32
use OCP\Migration\SimpleMigrationStep;
33
34
class Version1010Date20200630192639 extends SimpleMigrationStep {
35
	/**
36
	 * @param IOutput $output
37
	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
38
	 * @param array $options
39
	 * @return null|ISchemaWrapper
40
	 */
41
	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
42
		/** @var ISchemaWrapper $schema */
43
		$schema = $schemaClosure();
44
45
		if (!$schema->hasTable('files_trash')) {
46
			$table = $schema->createTable('files_trash');
47
			$table->addColumn('auto_id', Types::INTEGER, [
48
				'autoincrement' => true,
49
				'notnull' => true,
50
				'length' => 4,
51
			]);
52
			$table->addColumn('id', Types::STRING, [
53
				'notnull' => true,
54
				'length' => 250,
55
				'default' => '',
56
			]);
57
			$table->addColumn('user', Types::STRING, [
58
				'notnull' => true,
59
				'length' => 64,
60
				'default' => '',
61
			]);
62
			$table->addColumn('timestamp', Types::STRING, [
63
				'notnull' => true,
64
				'length' => 12,
65
				'default' => '',
66
			]);
67
			$table->addColumn('location', Types::STRING, [
68
				'notnull' => true,
69
				'length' => 512,
70
				'default' => '',
71
			]);
72
			$table->addColumn('type', Types::STRING, [
73
				'notnull' => false,
74
				'length' => 4,
75
			]);
76
			$table->addColumn('mime', Types::STRING, [
77
				'notnull' => false,
78
				'length' => 255,
79
			]);
80
			$table->setPrimaryKey(['auto_id']);
81
			$table->addIndex(['id'], 'id_index');
82
			$table->addIndex(['timestamp'], 'timestamp_index');
83
			$table->addIndex(['user'], 'user_index');
84
		}
85
		return $schema;
86
	}
87
}
88