@@ -32,77 +32,77 @@ |
||
32 | 32 | * Very thin wrapper class to make output testable |
33 | 33 | */ |
34 | 34 | class Output implements IOutput { |
35 | - /** @var string */ |
|
36 | - private $webRoot; |
|
35 | + /** @var string */ |
|
36 | + private $webRoot; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param $webRoot |
|
40 | - */ |
|
41 | - public function __construct($webRoot) { |
|
42 | - $this->webRoot = $webRoot; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @param $webRoot |
|
40 | + */ |
|
41 | + public function __construct($webRoot) { |
|
42 | + $this->webRoot = $webRoot; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $out |
|
47 | - */ |
|
48 | - public function setOutput($out) { |
|
49 | - print($out); |
|
50 | - } |
|
45 | + /** |
|
46 | + * @param string $out |
|
47 | + */ |
|
48 | + public function setOutput($out) { |
|
49 | + print($out); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string|resource $path or file handle |
|
54 | - * |
|
55 | - * @return bool false if an error occurred |
|
56 | - */ |
|
57 | - public function setReadfile($path) { |
|
58 | - if (is_resource($path)) { |
|
59 | - $output = fopen('php://output', 'w'); |
|
60 | - return stream_copy_to_stream($path, $output) > 0; |
|
61 | - } else { |
|
62 | - return @readfile($path); |
|
63 | - } |
|
64 | - } |
|
52 | + /** |
|
53 | + * @param string|resource $path or file handle |
|
54 | + * |
|
55 | + * @return bool false if an error occurred |
|
56 | + */ |
|
57 | + public function setReadfile($path) { |
|
58 | + if (is_resource($path)) { |
|
59 | + $output = fopen('php://output', 'w'); |
|
60 | + return stream_copy_to_stream($path, $output) > 0; |
|
61 | + } else { |
|
62 | + return @readfile($path); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string $header |
|
68 | - */ |
|
69 | - public function setHeader($header) { |
|
70 | - header($header); |
|
71 | - } |
|
66 | + /** |
|
67 | + * @param string $header |
|
68 | + */ |
|
69 | + public function setHeader($header) { |
|
70 | + header($header); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param int $code sets the http status code |
|
75 | - */ |
|
76 | - public function setHttpResponseCode($code) { |
|
77 | - http_response_code($code); |
|
78 | - } |
|
73 | + /** |
|
74 | + * @param int $code sets the http status code |
|
75 | + */ |
|
76 | + public function setHttpResponseCode($code) { |
|
77 | + http_response_code($code); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return int returns the current http response code |
|
82 | - */ |
|
83 | - public function getHttpResponseCode() { |
|
84 | - return http_response_code(); |
|
85 | - } |
|
80 | + /** |
|
81 | + * @return int returns the current http response code |
|
82 | + */ |
|
83 | + public function getHttpResponseCode() { |
|
84 | + return http_response_code(); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param string $name |
|
89 | - * @param string $value |
|
90 | - * @param int $expire |
|
91 | - * @param string $path |
|
92 | - * @param string $domain |
|
93 | - * @param bool $secure |
|
94 | - * @param bool $httpOnly |
|
95 | - */ |
|
96 | - public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
|
97 | - $path = $this->webRoot ? : '/'; |
|
87 | + /** |
|
88 | + * @param string $name |
|
89 | + * @param string $value |
|
90 | + * @param int $expire |
|
91 | + * @param string $path |
|
92 | + * @param string $domain |
|
93 | + * @param bool $secure |
|
94 | + * @param bool $httpOnly |
|
95 | + */ |
|
96 | + public function setCookie($name, $value, $expire, $path, $domain, $secure, $httpOnly, $sameSite = 'Lax') { |
|
97 | + $path = $this->webRoot ? : '/'; |
|
98 | 98 | |
99 | - setcookie($name, $value, [ |
|
100 | - 'expires' => $expire, |
|
101 | - 'path' => $path, |
|
102 | - 'domain' => $domain, |
|
103 | - 'secure' => $secure, |
|
104 | - 'httponly' => $httpOnly, |
|
105 | - 'samesite' => $sameSite |
|
106 | - ]); |
|
107 | - } |
|
99 | + setcookie($name, $value, [ |
|
100 | + 'expires' => $expire, |
|
101 | + 'path' => $path, |
|
102 | + 'domain' => $domain, |
|
103 | + 'secure' => $secure, |
|
104 | + 'httponly' => $httpOnly, |
|
105 | + 'samesite' => $sameSite |
|
106 | + ]); |
|
107 | + } |
|
108 | 108 | } |
@@ -34,19 +34,19 @@ |
||
34 | 34 | use OCP\Migration\SimpleMigrationStep; |
35 | 35 | |
36 | 36 | class Version14000Date20180710092004 extends SimpleMigrationStep { |
37 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
38 | - /** @var ISchemaWrapper $schema */ |
|
39 | - $schema = $schemaClosure(); |
|
37 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
38 | + /** @var ISchemaWrapper $schema */ |
|
39 | + $schema = $schemaClosure(); |
|
40 | 40 | |
41 | - $table = $schema->getTable('share'); |
|
41 | + $table = $schema->getTable('share'); |
|
42 | 42 | |
43 | - if (!$table->hasColumn('password_by_talk')) { |
|
44 | - $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
45 | - 'default' => 0, |
|
46 | - 'notnull' => false, |
|
47 | - ]); |
|
48 | - } |
|
43 | + if (!$table->hasColumn('password_by_talk')) { |
|
44 | + $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
45 | + 'default' => 0, |
|
46 | + 'notnull' => false, |
|
47 | + ]); |
|
48 | + } |
|
49 | 49 | |
50 | - return $schema; |
|
51 | - } |
|
50 | + return $schema; |
|
51 | + } |
|
52 | 52 | } |
@@ -32,30 +32,30 @@ |
||
32 | 32 | use OCP\Migration\SimpleMigrationStep; |
33 | 33 | |
34 | 34 | class Version1016Date20201109085907 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): ?ISchemaWrapper { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
44 | - |
|
45 | - $result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring'); |
|
46 | - |
|
47 | - return $result ? $schema : null; |
|
48 | - } |
|
49 | - |
|
50 | - protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
51 | - $table = $schema->getTable($tableName); |
|
52 | - $column = $table->getColumn($columnName); |
|
53 | - |
|
54 | - if ($column->getNotnull()) { |
|
55 | - $column->setNotnull(false); |
|
56 | - return true; |
|
57 | - } |
|
58 | - |
|
59 | - return false; |
|
60 | - } |
|
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): ?ISchemaWrapper { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | + |
|
45 | + $result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring'); |
|
46 | + |
|
47 | + return $result ? $schema : null; |
|
48 | + } |
|
49 | + |
|
50 | + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
51 | + $table = $schema->getTable($tableName); |
|
52 | + $column = $table->getColumn($columnName); |
|
53 | + |
|
54 | + if ($column->getNotnull()) { |
|
55 | + $column->setNotnull(false); |
|
56 | + return true; |
|
57 | + } |
|
58 | + |
|
59 | + return false; |
|
60 | + } |
|
61 | 61 | } |
@@ -32,30 +32,30 @@ |
||
32 | 32 | use OCP\Migration\SimpleMigrationStep; |
33 | 33 | |
34 | 34 | class Version20000Date20201111081915 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): ?ISchemaWrapper { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
44 | - |
|
45 | - $result = $this->ensureColumnIsNullable($schema, 'direct_edit', 'accessed'); |
|
46 | - |
|
47 | - return $result ? $schema : null; |
|
48 | - } |
|
49 | - |
|
50 | - protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
51 | - $table = $schema->getTable($tableName); |
|
52 | - $column = $table->getColumn($columnName); |
|
53 | - |
|
54 | - if ($column->getNotnull()) { |
|
55 | - $column->setNotnull(false); |
|
56 | - return true; |
|
57 | - } |
|
58 | - |
|
59 | - return false; |
|
60 | - } |
|
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): ?ISchemaWrapper { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | + |
|
45 | + $result = $this->ensureColumnIsNullable($schema, 'direct_edit', 'accessed'); |
|
46 | + |
|
47 | + return $result ? $schema : null; |
|
48 | + } |
|
49 | + |
|
50 | + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
51 | + $table = $schema->getTable($tableName); |
|
52 | + $column = $table->getColumn($columnName); |
|
53 | + |
|
54 | + if ($column->getNotnull()) { |
|
55 | + $column->setNotnull(false); |
|
56 | + return true; |
|
57 | + } |
|
58 | + |
|
59 | + return false; |
|
60 | + } |
|
61 | 61 | } |
@@ -37,61 +37,61 @@ |
||
37 | 37 | */ |
38 | 38 | class Version0001Date20200602134824 extends SimpleMigrationStep { |
39 | 39 | |
40 | - /** |
|
41 | - * @param IOutput $output |
|
42 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43 | - * @param array $options |
|
44 | - * @return null|ISchemaWrapper |
|
45 | - * @since 20.0.0 |
|
46 | - */ |
|
47 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
48 | - /** @var ISchemaWrapper $schema */ |
|
49 | - $schema = $schemaClosure(); |
|
40 | + /** |
|
41 | + * @param IOutput $output |
|
42 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43 | + * @param array $options |
|
44 | + * @return null|ISchemaWrapper |
|
45 | + * @since 20.0.0 |
|
46 | + */ |
|
47 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
48 | + /** @var ISchemaWrapper $schema */ |
|
49 | + $schema = $schemaClosure(); |
|
50 | 50 | |
51 | - $statusTable = $schema->createTable('user_status'); |
|
52 | - $statusTable->addColumn('id', Types::BIGINT, [ |
|
53 | - 'autoincrement' => true, |
|
54 | - 'notnull' => true, |
|
55 | - 'length' => 20, |
|
56 | - 'unsigned' => true, |
|
57 | - ]); |
|
58 | - $statusTable->addColumn('user_id', Types::STRING, [ |
|
59 | - 'notnull' => true, |
|
60 | - 'length' => 255, |
|
61 | - ]); |
|
62 | - $statusTable->addColumn('status', Types::STRING, [ |
|
63 | - 'notnull' => true, |
|
64 | - 'length' => 255, |
|
65 | - ]); |
|
66 | - $statusTable->addColumn('status_timestamp', Types::INTEGER, [ |
|
67 | - 'notnull' => true, |
|
68 | - 'length' => 11, |
|
69 | - 'unsigned' => true, |
|
70 | - ]); |
|
71 | - $statusTable->addColumn('is_user_defined', Types::BOOLEAN, [ |
|
72 | - 'notnull' => false, |
|
73 | - ]); |
|
74 | - $statusTable->addColumn('message_id', Types::STRING, [ |
|
75 | - 'notnull' => false, |
|
76 | - 'length' => 255, |
|
77 | - ]); |
|
78 | - $statusTable->addColumn('custom_icon', Types::STRING, [ |
|
79 | - 'notnull' => false, |
|
80 | - 'length' => 255, |
|
81 | - ]); |
|
82 | - $statusTable->addColumn('custom_message', Types::TEXT, [ |
|
83 | - 'notnull' => false, |
|
84 | - ]); |
|
85 | - $statusTable->addColumn('clear_at', Types::INTEGER, [ |
|
86 | - 'notnull' => false, |
|
87 | - 'length' => 11, |
|
88 | - 'unsigned' => true, |
|
89 | - ]); |
|
51 | + $statusTable = $schema->createTable('user_status'); |
|
52 | + $statusTable->addColumn('id', Types::BIGINT, [ |
|
53 | + 'autoincrement' => true, |
|
54 | + 'notnull' => true, |
|
55 | + 'length' => 20, |
|
56 | + 'unsigned' => true, |
|
57 | + ]); |
|
58 | + $statusTable->addColumn('user_id', Types::STRING, [ |
|
59 | + 'notnull' => true, |
|
60 | + 'length' => 255, |
|
61 | + ]); |
|
62 | + $statusTable->addColumn('status', Types::STRING, [ |
|
63 | + 'notnull' => true, |
|
64 | + 'length' => 255, |
|
65 | + ]); |
|
66 | + $statusTable->addColumn('status_timestamp', Types::INTEGER, [ |
|
67 | + 'notnull' => true, |
|
68 | + 'length' => 11, |
|
69 | + 'unsigned' => true, |
|
70 | + ]); |
|
71 | + $statusTable->addColumn('is_user_defined', Types::BOOLEAN, [ |
|
72 | + 'notnull' => false, |
|
73 | + ]); |
|
74 | + $statusTable->addColumn('message_id', Types::STRING, [ |
|
75 | + 'notnull' => false, |
|
76 | + 'length' => 255, |
|
77 | + ]); |
|
78 | + $statusTable->addColumn('custom_icon', Types::STRING, [ |
|
79 | + 'notnull' => false, |
|
80 | + 'length' => 255, |
|
81 | + ]); |
|
82 | + $statusTable->addColumn('custom_message', Types::TEXT, [ |
|
83 | + 'notnull' => false, |
|
84 | + ]); |
|
85 | + $statusTable->addColumn('clear_at', Types::INTEGER, [ |
|
86 | + 'notnull' => false, |
|
87 | + 'length' => 11, |
|
88 | + 'unsigned' => true, |
|
89 | + ]); |
|
90 | 90 | |
91 | - $statusTable->setPrimaryKey(['id']); |
|
92 | - $statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix'); |
|
93 | - $statusTable->addIndex(['clear_at'], 'user_status_clr_ix'); |
|
91 | + $statusTable->setPrimaryKey(['id']); |
|
92 | + $statusTable->addUniqueIndex(['user_id'], 'user_status_uid_ix'); |
|
93 | + $statusTable->addIndex(['clear_at'], 'user_status_clr_ix'); |
|
94 | 94 | |
95 | - return $schema; |
|
96 | - } |
|
95 | + return $schema; |
|
96 | + } |
|
97 | 97 | } |
@@ -33,30 +33,30 @@ |
||
33 | 33 | |
34 | 34 | class Version1000Date20201111130204 extends SimpleMigrationStep { |
35 | 35 | |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * @return null|ISchemaWrapper |
|
41 | - */ |
|
42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
43 | - /** @var ISchemaWrapper $schema */ |
|
44 | - $schema = $schemaClosure(); |
|
45 | - |
|
46 | - $result = $this->ensureColumnIsNullable($schema, 'user_status', 'is_user_defined'); |
|
47 | - |
|
48 | - return $result ? $schema : null; |
|
49 | - } |
|
50 | - |
|
51 | - protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
52 | - $table = $schema->getTable($tableName); |
|
53 | - $column = $table->getColumn($columnName); |
|
54 | - |
|
55 | - if ($column->getNotnull()) { |
|
56 | - $column->setNotnull(false); |
|
57 | - return true; |
|
58 | - } |
|
59 | - |
|
60 | - return false; |
|
61 | - } |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * @return null|ISchemaWrapper |
|
41 | + */ |
|
42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
43 | + /** @var ISchemaWrapper $schema */ |
|
44 | + $schema = $schemaClosure(); |
|
45 | + |
|
46 | + $result = $this->ensureColumnIsNullable($schema, 'user_status', 'is_user_defined'); |
|
47 | + |
|
48 | + return $result ? $schema : null; |
|
49 | + } |
|
50 | + |
|
51 | + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { |
|
52 | + $table = $schema->getTable($tableName); |
|
53 | + $column = $table->getColumn($columnName); |
|
54 | + |
|
55 | + if ($column->getNotnull()) { |
|
56 | + $column->setNotnull(false); |
|
57 | + return true; |
|
58 | + } |
|
59 | + |
|
60 | + return false; |
|
61 | + } |
|
62 | 62 | } |
@@ -32,44 +32,44 @@ |
||
32 | 32 | use OCP\Migration\SimpleMigrationStep; |
33 | 33 | |
34 | 34 | class Version21000Date20201202095923 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): ?ISchemaWrapper { |
|
42 | - /** @var ISchemaWrapper $schema */ |
|
43 | - $schema = $schemaClosure(); |
|
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): ?ISchemaWrapper { |
|
42 | + /** @var ISchemaWrapper $schema */ |
|
43 | + $schema = $schemaClosure(); |
|
44 | 44 | |
45 | - if (!$schema->hasTable('accounts_data')) { |
|
46 | - $table = $schema->createTable('accounts_data'); |
|
47 | - $table->addColumn('id', Types::BIGINT, [ |
|
48 | - 'autoincrement' => true, |
|
49 | - 'notnull' => true, |
|
50 | - 'length' => 20, |
|
51 | - ]); |
|
52 | - $table->addColumn('uid', Types::STRING, [ |
|
53 | - 'notnull' => true, |
|
54 | - 'length' => 64, |
|
55 | - ]); |
|
56 | - $table->addColumn('name', Types::STRING, [ |
|
57 | - 'notnull' => true, |
|
58 | - 'length' => 64, |
|
59 | - ]); |
|
60 | - $table->addColumn('value', Types::STRING, [ |
|
61 | - 'notnull' => false, |
|
62 | - 'length' => 255, |
|
63 | - 'default' => '', |
|
64 | - ]); |
|
65 | - $table->setPrimaryKey(['id']); |
|
66 | - $table->addIndex(['uid'], 'accounts_data_uid'); |
|
67 | - $table->addIndex(['name'], 'accounts_data_name'); |
|
68 | - $table->addIndex(['value'], 'accounts_data_value'); |
|
45 | + if (!$schema->hasTable('accounts_data')) { |
|
46 | + $table = $schema->createTable('accounts_data'); |
|
47 | + $table->addColumn('id', Types::BIGINT, [ |
|
48 | + 'autoincrement' => true, |
|
49 | + 'notnull' => true, |
|
50 | + 'length' => 20, |
|
51 | + ]); |
|
52 | + $table->addColumn('uid', Types::STRING, [ |
|
53 | + 'notnull' => true, |
|
54 | + 'length' => 64, |
|
55 | + ]); |
|
56 | + $table->addColumn('name', Types::STRING, [ |
|
57 | + 'notnull' => true, |
|
58 | + 'length' => 64, |
|
59 | + ]); |
|
60 | + $table->addColumn('value', Types::STRING, [ |
|
61 | + 'notnull' => false, |
|
62 | + 'length' => 255, |
|
63 | + 'default' => '', |
|
64 | + ]); |
|
65 | + $table->setPrimaryKey(['id']); |
|
66 | + $table->addIndex(['uid'], 'accounts_data_uid'); |
|
67 | + $table->addIndex(['name'], 'accounts_data_name'); |
|
68 | + $table->addIndex(['value'], 'accounts_data_value'); |
|
69 | 69 | |
70 | - return $schema; |
|
71 | - } |
|
70 | + return $schema; |
|
71 | + } |
|
72 | 72 | |
73 | - return null; |
|
74 | - } |
|
73 | + return null; |
|
74 | + } |
|
75 | 75 | } |
@@ -33,55 +33,55 @@ |
||
33 | 33 | use OCP\Migration\SimpleMigrationStep; |
34 | 34 | |
35 | 35 | class Version1010Date20200630192639 extends SimpleMigrationStep { |
36 | - /** |
|
37 | - * @param IOutput $output |
|
38 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | - * @param array $options |
|
40 | - * @return null|ISchemaWrapper |
|
41 | - */ |
|
42 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | - /** @var ISchemaWrapper $schema */ |
|
44 | - $schema = $schemaClosure(); |
|
36 | + /** |
|
37 | + * @param IOutput $output |
|
38 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
39 | + * @param array $options |
|
40 | + * @return null|ISchemaWrapper |
|
41 | + */ |
|
42 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
43 | + /** @var ISchemaWrapper $schema */ |
|
44 | + $schema = $schemaClosure(); |
|
45 | 45 | |
46 | - if (!$schema->hasTable('files_trash')) { |
|
47 | - $table = $schema->createTable('files_trash'); |
|
48 | - $table->addColumn('auto_id', Types::BIGINT, [ |
|
49 | - 'autoincrement' => true, |
|
50 | - 'notnull' => true, |
|
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 | - } |
|
46 | + if (!$schema->hasTable('files_trash')) { |
|
47 | + $table = $schema->createTable('files_trash'); |
|
48 | + $table->addColumn('auto_id', Types::BIGINT, [ |
|
49 | + 'autoincrement' => true, |
|
50 | + 'notnull' => true, |
|
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 | 87 | } |
@@ -34,37 +34,37 @@ |
||
34 | 34 | use OCP\Migration\SimpleMigrationStep; |
35 | 35 | |
36 | 36 | class Version21000Date20201223143245 extends SimpleMigrationStep { |
37 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
38 | - /** @var ISchemaWrapper $schema */ |
|
39 | - $schema = $schemaClosure(); |
|
37 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
38 | + /** @var ISchemaWrapper $schema */ |
|
39 | + $schema = $schemaClosure(); |
|
40 | 40 | |
41 | - if ($schema->hasTable('share_external')) { |
|
42 | - $table = $schema->getTable('share_external'); |
|
43 | - $changed = false; |
|
44 | - if (!$table->hasColumn('parent')) { |
|
45 | - $table->addColumn('parent', Types::BIGINT, [ |
|
46 | - 'notnull' => false, |
|
47 | - 'default' => -1, |
|
48 | - ]); |
|
49 | - $changed = true; |
|
50 | - } |
|
51 | - if (!$table->hasColumn('share_type')) { |
|
52 | - $table->addColumn('share_type', Types::INTEGER, [ |
|
53 | - 'notnull' => false, |
|
54 | - 'length' => 4, |
|
55 | - ]); |
|
56 | - $changed = true; |
|
57 | - } |
|
58 | - if ($table->hasColumn('lastscan')) { |
|
59 | - $table->dropColumn('lastscan'); |
|
60 | - $changed = true; |
|
61 | - } |
|
41 | + if ($schema->hasTable('share_external')) { |
|
42 | + $table = $schema->getTable('share_external'); |
|
43 | + $changed = false; |
|
44 | + if (!$table->hasColumn('parent')) { |
|
45 | + $table->addColumn('parent', Types::BIGINT, [ |
|
46 | + 'notnull' => false, |
|
47 | + 'default' => -1, |
|
48 | + ]); |
|
49 | + $changed = true; |
|
50 | + } |
|
51 | + if (!$table->hasColumn('share_type')) { |
|
52 | + $table->addColumn('share_type', Types::INTEGER, [ |
|
53 | + 'notnull' => false, |
|
54 | + 'length' => 4, |
|
55 | + ]); |
|
56 | + $changed = true; |
|
57 | + } |
|
58 | + if ($table->hasColumn('lastscan')) { |
|
59 | + $table->dropColumn('lastscan'); |
|
60 | + $changed = true; |
|
61 | + } |
|
62 | 62 | |
63 | - if ($changed) { |
|
64 | - return $schema; |
|
65 | - } |
|
66 | - } |
|
63 | + if ($changed) { |
|
64 | + return $schema; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - return null; |
|
69 | - } |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | } |