@@ -36,59 +36,59 @@ |
||
36 | 36 | |
37 | 37 | class Version18000Date20191014105105 extends SimpleMigrationStep { |
38 | 38 | |
39 | - /** @var IDBConnection */ |
|
40 | - protected $connection; |
|
39 | + /** @var IDBConnection */ |
|
40 | + protected $connection; |
|
41 | 41 | |
42 | - public function __construct(IDBConnection $connection) { |
|
43 | - $this->connection = $connection; |
|
44 | - } |
|
42 | + public function __construct(IDBConnection $connection) { |
|
43 | + $this->connection = $connection; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param IOutput $output |
|
48 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
49 | - * @param array $options |
|
50 | - * @return null|ISchemaWrapper |
|
51 | - */ |
|
52 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
53 | - /** @var ISchemaWrapper $schema */ |
|
54 | - $schema = $schemaClosure(); |
|
55 | - $table = $schema->createTable('direct_edit'); |
|
46 | + /** |
|
47 | + * @param IOutput $output |
|
48 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
49 | + * @param array $options |
|
50 | + * @return null|ISchemaWrapper |
|
51 | + */ |
|
52 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
53 | + /** @var ISchemaWrapper $schema */ |
|
54 | + $schema = $schemaClosure(); |
|
55 | + $table = $schema->createTable('direct_edit'); |
|
56 | 56 | |
57 | - $table->addColumn('id', Types::BIGINT, [ |
|
58 | - 'autoincrement' => true, |
|
59 | - 'notnull' => true, |
|
60 | - ]); |
|
61 | - $table->addColumn('editor_id', Types::STRING, [ |
|
62 | - 'notnull' => true, |
|
63 | - 'length' => 64, |
|
64 | - ]); |
|
65 | - $table->addColumn('token', Types::STRING, [ |
|
66 | - 'notnull' => true, |
|
67 | - 'length' => 64, |
|
68 | - ]); |
|
69 | - $table->addColumn('file_id', Types::BIGINT, [ |
|
70 | - 'notnull' => true, |
|
71 | - ]); |
|
72 | - $table->addColumn('user_id', Types::STRING, [ |
|
73 | - 'notnull' => false, |
|
74 | - 'length' => 64, |
|
75 | - ]); |
|
76 | - $table->addColumn('share_id', Types::BIGINT, [ |
|
77 | - 'notnull' => false |
|
78 | - ]); |
|
79 | - $table->addColumn('timestamp', Types::BIGINT, [ |
|
80 | - 'notnull' => true, |
|
81 | - 'length' => 20, |
|
82 | - 'unsigned' => true, |
|
83 | - ]); |
|
84 | - $table->addColumn('accessed', Types::BOOLEAN, [ |
|
85 | - 'notnull' => false, |
|
86 | - 'default' => false |
|
87 | - ]); |
|
57 | + $table->addColumn('id', Types::BIGINT, [ |
|
58 | + 'autoincrement' => true, |
|
59 | + 'notnull' => true, |
|
60 | + ]); |
|
61 | + $table->addColumn('editor_id', Types::STRING, [ |
|
62 | + 'notnull' => true, |
|
63 | + 'length' => 64, |
|
64 | + ]); |
|
65 | + $table->addColumn('token', Types::STRING, [ |
|
66 | + 'notnull' => true, |
|
67 | + 'length' => 64, |
|
68 | + ]); |
|
69 | + $table->addColumn('file_id', Types::BIGINT, [ |
|
70 | + 'notnull' => true, |
|
71 | + ]); |
|
72 | + $table->addColumn('user_id', Types::STRING, [ |
|
73 | + 'notnull' => false, |
|
74 | + 'length' => 64, |
|
75 | + ]); |
|
76 | + $table->addColumn('share_id', Types::BIGINT, [ |
|
77 | + 'notnull' => false |
|
78 | + ]); |
|
79 | + $table->addColumn('timestamp', Types::BIGINT, [ |
|
80 | + 'notnull' => true, |
|
81 | + 'length' => 20, |
|
82 | + 'unsigned' => true, |
|
83 | + ]); |
|
84 | + $table->addColumn('accessed', Types::BOOLEAN, [ |
|
85 | + 'notnull' => false, |
|
86 | + 'default' => false |
|
87 | + ]); |
|
88 | 88 | |
89 | - $table->setPrimaryKey(['id']); |
|
90 | - $table->addIndex(['token']); |
|
89 | + $table->setPrimaryKey(['id']); |
|
90 | + $table->addIndex(['token']); |
|
91 | 91 | |
92 | - return $schema; |
|
93 | - } |
|
92 | + return $schema; |
|
93 | + } |
|
94 | 94 | } |
@@ -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 | } |