@@ -39,87 +39,87 @@ |
||
39 | 39 | |
40 | 40 | class ConvertFilecacheBigInt extends Command { |
41 | 41 | |
42 | - /** @var IDBConnection */ |
|
43 | - private $connection; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param IDBConnection $connection |
|
47 | - */ |
|
48 | - public function __construct(IDBConnection $connection) { |
|
49 | - $this->connection = $connection; |
|
50 | - parent::__construct(); |
|
51 | - } |
|
52 | - |
|
53 | - protected function configure() { |
|
54 | - $this |
|
55 | - ->setName('db:convert-filecache-bigint') |
|
56 | - ->setDescription('Convert the ID columns of the filecache to BigInt'); |
|
57 | - } |
|
58 | - |
|
59 | - protected function getColumnsByTable() { |
|
60 | - // also update in CheckSetupController::hasBigIntConversionPendingColumns() |
|
61 | - return [ |
|
62 | - 'activity' => ['activity_id', 'object_id'], |
|
63 | - 'activity_mq' => ['mail_id'], |
|
64 | - 'authtoken' => ['id'], |
|
65 | - 'bruteforce_attempts' => ['id'], |
|
66 | - 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'], |
|
67 | - 'file_locks' => ['id'], |
|
68 | - 'jobs' => ['id'], |
|
69 | - 'mimetypes' => ['id'], |
|
70 | - 'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'], |
|
71 | - 'storages' => ['numeric_id'], |
|
72 | - ]; |
|
73 | - } |
|
74 | - |
|
75 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
76 | - $schema = new SchemaWrapper($this->connection); |
|
77 | - $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform; |
|
78 | - $updates = []; |
|
79 | - |
|
80 | - $tables = $this->getColumnsByTable(); |
|
81 | - foreach ($tables as $tableName => $columns) { |
|
82 | - if (!$schema->hasTable($tableName)) { |
|
83 | - continue; |
|
84 | - } |
|
85 | - |
|
86 | - $table = $schema->getTable($tableName); |
|
87 | - |
|
88 | - foreach ($columns as $columnName) { |
|
89 | - $column = $table->getColumn($columnName); |
|
90 | - $isAutoIncrement = $column->getAutoincrement(); |
|
91 | - $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement; |
|
92 | - if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) { |
|
93 | - $column->setType(Type::getType(Types::BIGINT)); |
|
94 | - $column->setOptions(['length' => 20]); |
|
95 | - |
|
96 | - $updates[] = '* ' . $tableName . '.' . $columnName; |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - if (empty($updates)) { |
|
102 | - $output->writeln('<info>All tables already up to date!</info>'); |
|
103 | - return 0; |
|
104 | - } |
|
105 | - |
|
106 | - $output->writeln('<comment>Following columns will be updated:</comment>'); |
|
107 | - $output->writeln(''); |
|
108 | - $output->writeln($updates); |
|
109 | - $output->writeln(''); |
|
110 | - $output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>'); |
|
111 | - |
|
112 | - if ($input->isInteractive()) { |
|
113 | - $helper = $this->getHelper('question'); |
|
114 | - $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false); |
|
115 | - |
|
116 | - if (!$helper->ask($input, $output, $question)) { |
|
117 | - return 1; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
122 | - |
|
123 | - return 0; |
|
124 | - } |
|
42 | + /** @var IDBConnection */ |
|
43 | + private $connection; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param IDBConnection $connection |
|
47 | + */ |
|
48 | + public function __construct(IDBConnection $connection) { |
|
49 | + $this->connection = $connection; |
|
50 | + parent::__construct(); |
|
51 | + } |
|
52 | + |
|
53 | + protected function configure() { |
|
54 | + $this |
|
55 | + ->setName('db:convert-filecache-bigint') |
|
56 | + ->setDescription('Convert the ID columns of the filecache to BigInt'); |
|
57 | + } |
|
58 | + |
|
59 | + protected function getColumnsByTable() { |
|
60 | + // also update in CheckSetupController::hasBigIntConversionPendingColumns() |
|
61 | + return [ |
|
62 | + 'activity' => ['activity_id', 'object_id'], |
|
63 | + 'activity_mq' => ['mail_id'], |
|
64 | + 'authtoken' => ['id'], |
|
65 | + 'bruteforce_attempts' => ['id'], |
|
66 | + 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'], |
|
67 | + 'file_locks' => ['id'], |
|
68 | + 'jobs' => ['id'], |
|
69 | + 'mimetypes' => ['id'], |
|
70 | + 'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'], |
|
71 | + 'storages' => ['numeric_id'], |
|
72 | + ]; |
|
73 | + } |
|
74 | + |
|
75 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
76 | + $schema = new SchemaWrapper($this->connection); |
|
77 | + $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform; |
|
78 | + $updates = []; |
|
79 | + |
|
80 | + $tables = $this->getColumnsByTable(); |
|
81 | + foreach ($tables as $tableName => $columns) { |
|
82 | + if (!$schema->hasTable($tableName)) { |
|
83 | + continue; |
|
84 | + } |
|
85 | + |
|
86 | + $table = $schema->getTable($tableName); |
|
87 | + |
|
88 | + foreach ($columns as $columnName) { |
|
89 | + $column = $table->getColumn($columnName); |
|
90 | + $isAutoIncrement = $column->getAutoincrement(); |
|
91 | + $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement; |
|
92 | + if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) { |
|
93 | + $column->setType(Type::getType(Types::BIGINT)); |
|
94 | + $column->setOptions(['length' => 20]); |
|
95 | + |
|
96 | + $updates[] = '* ' . $tableName . '.' . $columnName; |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + if (empty($updates)) { |
|
102 | + $output->writeln('<info>All tables already up to date!</info>'); |
|
103 | + return 0; |
|
104 | + } |
|
105 | + |
|
106 | + $output->writeln('<comment>Following columns will be updated:</comment>'); |
|
107 | + $output->writeln(''); |
|
108 | + $output->writeln($updates); |
|
109 | + $output->writeln(''); |
|
110 | + $output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>'); |
|
111 | + |
|
112 | + if ($input->isInteractive()) { |
|
113 | + $helper = $this->getHelper('question'); |
|
114 | + $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false); |
|
115 | + |
|
116 | + if (!$helper->ask($input, $output, $question)) { |
|
117 | + return 1; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
122 | + |
|
123 | + return 0; |
|
124 | + } |
|
125 | 125 | } |
@@ -93,7 +93,7 @@ |
||
93 | 93 | $column->setType(Type::getType(Types::BIGINT)); |
94 | 94 | $column->setOptions(['length' => 20]); |
95 | 95 | |
96 | - $updates[] = '* ' . $tableName . '.' . $columnName; |
|
96 | + $updates[] = '* '.$tableName.'.'.$columnName; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -37,41 +37,41 @@ |
||
37 | 37 | |
38 | 38 | class Version17000Date20190514105811 extends SimpleMigrationStep { |
39 | 39 | |
40 | - /** |
|
41 | - * @param IOutput $output |
|
42 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43 | - * @param array $options |
|
44 | - * @return ISchemaWrapper |
|
45 | - */ |
|
46 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
47 | - /** @var ISchemaWrapper $schema */ |
|
48 | - $schema = $schemaClosure(); |
|
49 | - if (!$schema->hasTable('filecache_extended')) { |
|
50 | - $table = $schema->createTable('filecache_extended'); |
|
51 | - $table->addColumn('fileid', Types::BIGINT, [ |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 4, |
|
54 | - 'unsigned' => true, |
|
55 | - ]); |
|
56 | - $table->addColumn('metadata_etag', Types::STRING, [ |
|
57 | - 'notnull' => false, |
|
58 | - 'length' => 40, |
|
59 | - ]); |
|
60 | - $table->addColumn('creation_time', Types::BIGINT, [ |
|
61 | - 'notnull' => true, |
|
62 | - 'length' => 20, |
|
63 | - 'default' => 0, |
|
64 | - ]); |
|
65 | - $table->addColumn('upload_time', Types::BIGINT, [ |
|
66 | - 'notnull' => true, |
|
67 | - 'length' => 20, |
|
68 | - 'default' => 0, |
|
69 | - ]); |
|
70 | - $table->addUniqueIndex(['fileid'], 'fce_fileid_idx'); |
|
71 | - $table->addIndex(['creation_time'], 'fce_ctime_idx'); |
|
72 | - $table->addIndex(['upload_time'], 'fce_utime_idx'); |
|
73 | - } |
|
40 | + /** |
|
41 | + * @param IOutput $output |
|
42 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
43 | + * @param array $options |
|
44 | + * @return ISchemaWrapper |
|
45 | + */ |
|
46 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
47 | + /** @var ISchemaWrapper $schema */ |
|
48 | + $schema = $schemaClosure(); |
|
49 | + if (!$schema->hasTable('filecache_extended')) { |
|
50 | + $table = $schema->createTable('filecache_extended'); |
|
51 | + $table->addColumn('fileid', Types::BIGINT, [ |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 4, |
|
54 | + 'unsigned' => true, |
|
55 | + ]); |
|
56 | + $table->addColumn('metadata_etag', Types::STRING, [ |
|
57 | + 'notnull' => false, |
|
58 | + 'length' => 40, |
|
59 | + ]); |
|
60 | + $table->addColumn('creation_time', Types::BIGINT, [ |
|
61 | + 'notnull' => true, |
|
62 | + 'length' => 20, |
|
63 | + 'default' => 0, |
|
64 | + ]); |
|
65 | + $table->addColumn('upload_time', Types::BIGINT, [ |
|
66 | + 'notnull' => true, |
|
67 | + 'length' => 20, |
|
68 | + 'default' => 0, |
|
69 | + ]); |
|
70 | + $table->addUniqueIndex(['fileid'], 'fce_fileid_idx'); |
|
71 | + $table->addIndex(['creation_time'], 'fce_ctime_idx'); |
|
72 | + $table->addIndex(['upload_time'], 'fce_utime_idx'); |
|
73 | + } |
|
74 | 74 | |
75 | - return $schema; |
|
76 | - } |
|
75 | + return $schema; |
|
76 | + } |
|
77 | 77 | } |
@@ -33,18 +33,18 @@ |
||
33 | 33 | use OCP\Migration\SimpleMigrationStep; |
34 | 34 | |
35 | 35 | class Version14000Date20180710092004 extends SimpleMigrationStep { |
36 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
37 | - /** @var ISchemaWrapper $schema */ |
|
38 | - $schema = $schemaClosure(); |
|
36 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
37 | + /** @var ISchemaWrapper $schema */ |
|
38 | + $schema = $schemaClosure(); |
|
39 | 39 | |
40 | - $table = $schema->getTable('share'); |
|
40 | + $table = $schema->getTable('share'); |
|
41 | 41 | |
42 | - if (!$table->hasColumn('password_by_talk')) { |
|
43 | - $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
44 | - 'default' => 0, |
|
45 | - ]); |
|
46 | - } |
|
42 | + if (!$table->hasColumn('password_by_talk')) { |
|
43 | + $table->addColumn('password_by_talk', Types::BOOLEAN, [ |
|
44 | + 'default' => 0, |
|
45 | + ]); |
|
46 | + } |
|
47 | 47 | |
48 | - return $schema; |
|
49 | - } |
|
48 | + return $schema; |
|
49 | + } |
|
50 | 50 | } |
@@ -35,902 +35,902 @@ |
||
35 | 35 | |
36 | 36 | class Version13000Date20170718121200 extends SimpleMigrationStep { |
37 | 37 | |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * @return null|ISchemaWrapper |
|
43 | - * @since 13.0.0 |
|
44 | - */ |
|
45 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
46 | - /** @var ISchemaWrapper $schema */ |
|
47 | - $schema = $schemaClosure(); |
|
48 | - |
|
49 | - if (!$schema->hasTable('appconfig')) { |
|
50 | - $table = $schema->createTable('appconfig'); |
|
51 | - $table->addColumn('appid', 'string', [ |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 32, |
|
54 | - 'default' => '', |
|
55 | - ]); |
|
56 | - $table->addColumn('configkey', 'string', [ |
|
57 | - 'notnull' => true, |
|
58 | - 'length' => 64, |
|
59 | - 'default' => '', |
|
60 | - ]); |
|
61 | - $table->addColumn('configvalue', 'text', [ |
|
62 | - 'notnull' => false, |
|
63 | - ]); |
|
64 | - $table->setPrimaryKey(['appid', 'configkey']); |
|
65 | - $table->addIndex(['configkey'], 'appconfig_config_key_index'); |
|
66 | - $table->addIndex(['appid'], 'appconfig_appid_key'); |
|
67 | - } |
|
68 | - |
|
69 | - if (!$schema->hasTable('storages')) { |
|
70 | - $table = $schema->createTable('storages'); |
|
71 | - $table->addColumn('id', 'string', [ |
|
72 | - 'notnull' => false, |
|
73 | - 'length' => 64, |
|
74 | - ]); |
|
75 | - $table->addColumn('numeric_id', Types::BIGINT, [ |
|
76 | - 'autoincrement' => true, |
|
77 | - 'notnull' => true, |
|
78 | - 'length' => 20, |
|
79 | - ]); |
|
80 | - $table->addColumn('available', 'integer', [ |
|
81 | - 'notnull' => true, |
|
82 | - 'default' => 1, |
|
83 | - ]); |
|
84 | - $table->addColumn('last_checked', 'integer', [ |
|
85 | - 'notnull' => false, |
|
86 | - ]); |
|
87 | - $table->setPrimaryKey(['numeric_id']); |
|
88 | - $table->addUniqueIndex(['id'], 'storages_id_index'); |
|
89 | - } |
|
90 | - |
|
91 | - if (!$schema->hasTable('mounts')) { |
|
92 | - $table = $schema->createTable('mounts'); |
|
93 | - $table->addColumn('id', 'integer', [ |
|
94 | - 'autoincrement' => true, |
|
95 | - 'notnull' => true, |
|
96 | - 'length' => 4, |
|
97 | - ]); |
|
98 | - $table->addColumn('storage_id', Types::BIGINT, [ |
|
99 | - 'notnull' => true, |
|
100 | - 'length' => 20, |
|
101 | - ]); |
|
102 | - $table->addColumn('root_id', Types::BIGINT, [ |
|
103 | - 'notnull' => true, |
|
104 | - 'length' => 20, |
|
105 | - ]); |
|
106 | - $table->addColumn('user_id', 'string', [ |
|
107 | - 'notnull' => true, |
|
108 | - 'length' => 64, |
|
109 | - ]); |
|
110 | - $table->addColumn('mount_point', 'string', [ |
|
111 | - 'notnull' => true, |
|
112 | - 'length' => 4000, |
|
113 | - ]); |
|
114 | - $table->addColumn('mount_id', Types::BIGINT, [ |
|
115 | - 'notnull' => false, |
|
116 | - 'length' => 20, |
|
117 | - ]); |
|
118 | - $table->setPrimaryKey(['id']); |
|
119 | - $table->addIndex(['user_id'], 'mounts_user_index'); |
|
120 | - $table->addIndex(['storage_id'], 'mounts_storage_index'); |
|
121 | - $table->addIndex(['root_id'], 'mounts_root_index'); |
|
122 | - $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
123 | - $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
|
124 | - } |
|
125 | - |
|
126 | - if (!$schema->hasTable('mimetypes')) { |
|
127 | - $table = $schema->createTable('mimetypes'); |
|
128 | - $table->addColumn('id', Types::BIGINT, [ |
|
129 | - 'autoincrement' => true, |
|
130 | - 'notnull' => true, |
|
131 | - 'length' => 20, |
|
132 | - ]); |
|
133 | - $table->addColumn('mimetype', 'string', [ |
|
134 | - 'notnull' => true, |
|
135 | - 'length' => 255, |
|
136 | - 'default' => '', |
|
137 | - ]); |
|
138 | - $table->setPrimaryKey(['id']); |
|
139 | - $table->addUniqueIndex(['mimetype'], 'mimetype_id_index'); |
|
140 | - } |
|
141 | - |
|
142 | - if (!$schema->hasTable('filecache')) { |
|
143 | - $table = $schema->createTable('filecache'); |
|
144 | - $table->addColumn('fileid', Types::BIGINT, [ |
|
145 | - 'autoincrement' => true, |
|
146 | - 'notnull' => true, |
|
147 | - 'length' => 20, |
|
148 | - ]); |
|
149 | - $table->addColumn('storage', Types::BIGINT, [ |
|
150 | - 'notnull' => true, |
|
151 | - 'length' => 20, |
|
152 | - 'default' => 0, |
|
153 | - ]); |
|
154 | - $table->addColumn('path', 'string', [ |
|
155 | - 'notnull' => false, |
|
156 | - 'length' => 4000, |
|
157 | - ]); |
|
158 | - $table->addColumn('path_hash', 'string', [ |
|
159 | - 'notnull' => true, |
|
160 | - 'length' => 32, |
|
161 | - 'default' => '', |
|
162 | - ]); |
|
163 | - $table->addColumn('parent', Types::BIGINT, [ |
|
164 | - 'notnull' => true, |
|
165 | - 'length' => 20, |
|
166 | - 'default' => 0, |
|
167 | - ]); |
|
168 | - $table->addColumn('name', 'string', [ |
|
169 | - 'notnull' => false, |
|
170 | - 'length' => 250, |
|
171 | - ]); |
|
172 | - $table->addColumn('mimetype', Types::BIGINT, [ |
|
173 | - 'notnull' => true, |
|
174 | - 'length' => 20, |
|
175 | - 'default' => 0, |
|
176 | - ]); |
|
177 | - $table->addColumn('mimepart', Types::BIGINT, [ |
|
178 | - 'notnull' => true, |
|
179 | - 'length' => 20, |
|
180 | - 'default' => 0, |
|
181 | - ]); |
|
182 | - $table->addColumn('size', 'bigint', [ |
|
183 | - 'notnull' => true, |
|
184 | - 'length' => 8, |
|
185 | - 'default' => 0, |
|
186 | - ]); |
|
187 | - $table->addColumn('mtime', Types::BIGINT, [ |
|
188 | - 'notnull' => true, |
|
189 | - 'length' => 20, |
|
190 | - 'default' => 0, |
|
191 | - ]); |
|
192 | - $table->addColumn('storage_mtime', Types::BIGINT, [ |
|
193 | - 'notnull' => true, |
|
194 | - 'length' => 20, |
|
195 | - 'default' => 0, |
|
196 | - ]); |
|
197 | - $table->addColumn('encrypted', 'integer', [ |
|
198 | - 'notnull' => true, |
|
199 | - 'length' => 4, |
|
200 | - 'default' => 0, |
|
201 | - ]); |
|
202 | - $table->addColumn('unencrypted_size', 'bigint', [ |
|
203 | - 'notnull' => true, |
|
204 | - 'length' => 8, |
|
205 | - 'default' => 0, |
|
206 | - ]); |
|
207 | - $table->addColumn('etag', 'string', [ |
|
208 | - 'notnull' => false, |
|
209 | - 'length' => 40, |
|
210 | - ]); |
|
211 | - $table->addColumn('permissions', 'integer', [ |
|
212 | - 'notnull' => false, |
|
213 | - 'length' => 4, |
|
214 | - 'default' => 0, |
|
215 | - ]); |
|
216 | - $table->addColumn('checksum', 'string', [ |
|
217 | - 'notnull' => false, |
|
218 | - 'length' => 255, |
|
219 | - ]); |
|
220 | - $table->setPrimaryKey(['fileid']); |
|
221 | - $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash'); |
|
222 | - $table->addIndex(['parent', 'name'], 'fs_parent_name_hash'); |
|
223 | - $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); |
|
224 | - $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); |
|
225 | - $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); |
|
226 | - $table->addIndex(['mtime'], 'fs_mtime'); |
|
227 | - } |
|
228 | - |
|
229 | - if (!$schema->hasTable('group_user')) { |
|
230 | - $table = $schema->createTable('group_user'); |
|
231 | - $table->addColumn('gid', 'string', [ |
|
232 | - 'notnull' => true, |
|
233 | - 'length' => 64, |
|
234 | - 'default' => '', |
|
235 | - ]); |
|
236 | - $table->addColumn('uid', 'string', [ |
|
237 | - 'notnull' => true, |
|
238 | - 'length' => 64, |
|
239 | - 'default' => '', |
|
240 | - ]); |
|
241 | - $table->setPrimaryKey(['gid', 'uid']); |
|
242 | - $table->addIndex(['uid'], 'gu_uid_index'); |
|
243 | - } |
|
244 | - |
|
245 | - if (!$schema->hasTable('group_admin')) { |
|
246 | - $table = $schema->createTable('group_admin'); |
|
247 | - $table->addColumn('gid', 'string', [ |
|
248 | - 'notnull' => true, |
|
249 | - 'length' => 64, |
|
250 | - 'default' => '', |
|
251 | - ]); |
|
252 | - $table->addColumn('uid', 'string', [ |
|
253 | - 'notnull' => true, |
|
254 | - 'length' => 64, |
|
255 | - 'default' => '', |
|
256 | - ]); |
|
257 | - $table->setPrimaryKey(['gid', 'uid']); |
|
258 | - $table->addIndex(['uid'], 'group_admin_uid'); |
|
259 | - } |
|
260 | - |
|
261 | - if (!$schema->hasTable('groups')) { |
|
262 | - $table = $schema->createTable('groups'); |
|
263 | - $table->addColumn('gid', 'string', [ |
|
264 | - 'notnull' => true, |
|
265 | - 'length' => 64, |
|
266 | - 'default' => '', |
|
267 | - ]); |
|
268 | - $table->setPrimaryKey(['gid']); |
|
269 | - } |
|
270 | - |
|
271 | - if (!$schema->hasTable('preferences')) { |
|
272 | - $table = $schema->createTable('preferences'); |
|
273 | - $table->addColumn('userid', 'string', [ |
|
274 | - 'notnull' => true, |
|
275 | - 'length' => 64, |
|
276 | - 'default' => '', |
|
277 | - ]); |
|
278 | - $table->addColumn('appid', 'string', [ |
|
279 | - 'notnull' => true, |
|
280 | - 'length' => 32, |
|
281 | - 'default' => '', |
|
282 | - ]); |
|
283 | - $table->addColumn('configkey', 'string', [ |
|
284 | - 'notnull' => true, |
|
285 | - 'length' => 64, |
|
286 | - 'default' => '', |
|
287 | - ]); |
|
288 | - $table->addColumn('configvalue', 'text', [ |
|
289 | - 'notnull' => false, |
|
290 | - ]); |
|
291 | - $table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
292 | - } |
|
293 | - |
|
294 | - if (!$schema->hasTable('properties')) { |
|
295 | - $table = $schema->createTable('properties'); |
|
296 | - $table->addColumn('id', 'integer', [ |
|
297 | - 'autoincrement' => true, |
|
298 | - 'notnull' => true, |
|
299 | - 'length' => 4, |
|
300 | - ]); |
|
301 | - $table->addColumn('userid', 'string', [ |
|
302 | - 'notnull' => true, |
|
303 | - 'length' => 64, |
|
304 | - 'default' => '', |
|
305 | - ]); |
|
306 | - $table->addColumn('propertypath', 'string', [ |
|
307 | - 'notnull' => true, |
|
308 | - 'length' => 255, |
|
309 | - 'default' => '', |
|
310 | - ]); |
|
311 | - $table->addColumn('propertyname', 'string', [ |
|
312 | - 'notnull' => true, |
|
313 | - 'length' => 255, |
|
314 | - 'default' => '', |
|
315 | - ]); |
|
316 | - $table->addColumn('propertyvalue', 'text', [ |
|
317 | - 'notnull' => true, |
|
318 | - ]); |
|
319 | - $table->setPrimaryKey(['id']); |
|
320 | - $table->addIndex(['userid'], 'property_index'); |
|
321 | - $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
322 | - } |
|
323 | - |
|
324 | - if (!$schema->hasTable('share')) { |
|
325 | - $table = $schema->createTable('share'); |
|
326 | - $table->addColumn('id', 'integer', [ |
|
327 | - 'autoincrement' => true, |
|
328 | - 'notnull' => true, |
|
329 | - 'length' => 4, |
|
330 | - ]); |
|
331 | - $table->addColumn('share_type', 'smallint', [ |
|
332 | - 'notnull' => true, |
|
333 | - 'length' => 1, |
|
334 | - 'default' => 0, |
|
335 | - ]); |
|
336 | - $table->addColumn('share_with', 'string', [ |
|
337 | - 'notnull' => false, |
|
338 | - 'length' => 255, |
|
339 | - ]); |
|
340 | - $table->addColumn('password', 'string', [ |
|
341 | - 'notnull' => false, |
|
342 | - 'length' => 255, |
|
343 | - ]); |
|
344 | - $table->addColumn('uid_owner', 'string', [ |
|
345 | - 'notnull' => true, |
|
346 | - 'length' => 64, |
|
347 | - 'default' => '', |
|
348 | - ]); |
|
349 | - $table->addColumn('uid_initiator', 'string', [ |
|
350 | - 'notnull' => false, |
|
351 | - 'length' => 64, |
|
352 | - ]); |
|
353 | - $table->addColumn('parent', 'integer', [ |
|
354 | - 'notnull' => false, |
|
355 | - 'length' => 4, |
|
356 | - ]); |
|
357 | - $table->addColumn('item_type', 'string', [ |
|
358 | - 'notnull' => true, |
|
359 | - 'length' => 64, |
|
360 | - 'default' => '', |
|
361 | - ]); |
|
362 | - $table->addColumn('item_source', 'string', [ |
|
363 | - 'notnull' => false, |
|
364 | - 'length' => 255, |
|
365 | - ]); |
|
366 | - $table->addColumn('item_target', 'string', [ |
|
367 | - 'notnull' => false, |
|
368 | - 'length' => 255, |
|
369 | - ]); |
|
370 | - $table->addColumn('file_source', 'integer', [ |
|
371 | - 'notnull' => false, |
|
372 | - 'length' => 4, |
|
373 | - ]); |
|
374 | - $table->addColumn('file_target', 'string', [ |
|
375 | - 'notnull' => false, |
|
376 | - 'length' => 512, |
|
377 | - ]); |
|
378 | - $table->addColumn('permissions', 'smallint', [ |
|
379 | - 'notnull' => true, |
|
380 | - 'length' => 1, |
|
381 | - 'default' => 0, |
|
382 | - ]); |
|
383 | - $table->addColumn('stime', 'bigint', [ |
|
384 | - 'notnull' => true, |
|
385 | - 'length' => 8, |
|
386 | - 'default' => 0, |
|
387 | - ]); |
|
388 | - $table->addColumn('accepted', 'smallint', [ |
|
389 | - 'notnull' => true, |
|
390 | - 'length' => 1, |
|
391 | - 'default' => 0, |
|
392 | - ]); |
|
393 | - $table->addColumn('expiration', 'datetime', [ |
|
394 | - 'notnull' => false, |
|
395 | - ]); |
|
396 | - $table->addColumn('token', 'string', [ |
|
397 | - 'notnull' => false, |
|
398 | - 'length' => 32, |
|
399 | - ]); |
|
400 | - $table->addColumn('mail_send', 'smallint', [ |
|
401 | - 'notnull' => true, |
|
402 | - 'length' => 1, |
|
403 | - 'default' => 0, |
|
404 | - ]); |
|
405 | - $table->addColumn('share_name', 'string', [ |
|
406 | - 'notnull' => false, |
|
407 | - 'length' => 64, |
|
408 | - ]); |
|
409 | - $table->setPrimaryKey(['id']); |
|
410 | - $table->addIndex(['item_type', 'share_type'], 'item_share_type_index'); |
|
411 | - $table->addIndex(['file_source'], 'file_source_index'); |
|
412 | - $table->addIndex(['token'], 'token_index'); |
|
413 | - $table->addIndex(['share_with'], 'share_with_index'); |
|
414 | - $table->addIndex(['parent'], 'parent_index'); |
|
415 | - $table->addIndex(['uid_owner'], 'owner_index'); |
|
416 | - $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
417 | - } |
|
418 | - |
|
419 | - if (!$schema->hasTable('jobs')) { |
|
420 | - $table = $schema->createTable('jobs'); |
|
421 | - $table->addColumn('id', 'integer', [ |
|
422 | - 'autoincrement' => true, |
|
423 | - 'notnull' => true, |
|
424 | - 'length' => 4, |
|
425 | - 'unsigned' => true, |
|
426 | - ]); |
|
427 | - $table->addColumn('class', 'string', [ |
|
428 | - 'notnull' => true, |
|
429 | - 'length' => 255, |
|
430 | - 'default' => '', |
|
431 | - ]); |
|
432 | - $table->addColumn('argument', 'string', [ |
|
433 | - 'notnull' => true, |
|
434 | - 'length' => 4000, |
|
435 | - 'default' => '', |
|
436 | - ]); |
|
437 | - $table->addColumn('last_run', 'integer', [ |
|
438 | - 'notnull' => false, |
|
439 | - 'default' => 0, |
|
440 | - ]); |
|
441 | - $table->addColumn('last_checked', 'integer', [ |
|
442 | - 'notnull' => false, |
|
443 | - 'default' => 0, |
|
444 | - ]); |
|
445 | - $table->addColumn('reserved_at', 'integer', [ |
|
446 | - 'notnull' => false, |
|
447 | - 'default' => 0, |
|
448 | - ]); |
|
449 | - $table->addColumn('execution_duration', 'integer', [ |
|
450 | - 'notnull' => true, |
|
451 | - 'default' => 0, |
|
452 | - ]); |
|
453 | - $table->setPrimaryKey(['id']); |
|
454 | - $table->addIndex(['class'], 'job_class_index'); |
|
455 | - } |
|
456 | - |
|
457 | - if (!$schema->hasTable('users')) { |
|
458 | - $table = $schema->createTable('users'); |
|
459 | - $table->addColumn('uid', 'string', [ |
|
460 | - 'notnull' => true, |
|
461 | - 'length' => 64, |
|
462 | - 'default' => '', |
|
463 | - ]); |
|
464 | - $table->addColumn('displayname', 'string', [ |
|
465 | - 'notnull' => false, |
|
466 | - 'length' => 64, |
|
467 | - ]); |
|
468 | - $table->addColumn('password', 'string', [ |
|
469 | - 'notnull' => true, |
|
470 | - 'length' => 255, |
|
471 | - 'default' => '', |
|
472 | - ]); |
|
473 | - $table->setPrimaryKey(['uid']); |
|
474 | - } |
|
475 | - |
|
476 | - if (!$schema->hasTable('authtoken')) { |
|
477 | - $table = $schema->createTable('authtoken'); |
|
478 | - $table->addColumn('id', 'integer', [ |
|
479 | - 'autoincrement' => true, |
|
480 | - 'notnull' => true, |
|
481 | - 'length' => 4, |
|
482 | - 'unsigned' => true, |
|
483 | - ]); |
|
484 | - $table->addColumn('uid', 'string', [ |
|
485 | - 'notnull' => true, |
|
486 | - 'length' => 64, |
|
487 | - 'default' => '', |
|
488 | - ]); |
|
489 | - $table->addColumn('login_name', 'string', [ |
|
490 | - 'notnull' => true, |
|
491 | - 'length' => 64, |
|
492 | - 'default' => '', |
|
493 | - ]); |
|
494 | - $table->addColumn('password', 'text', [ |
|
495 | - 'notnull' => false, |
|
496 | - ]); |
|
497 | - $table->addColumn('name', 'text', [ |
|
498 | - 'notnull' => true, |
|
499 | - 'default' => '', |
|
500 | - ]); |
|
501 | - $table->addColumn('token', 'string', [ |
|
502 | - 'notnull' => true, |
|
503 | - 'length' => 200, |
|
504 | - 'default' => '', |
|
505 | - ]); |
|
506 | - $table->addColumn('type', 'smallint', [ |
|
507 | - 'notnull' => true, |
|
508 | - 'length' => 2, |
|
509 | - 'default' => 0, |
|
510 | - 'unsigned' => true, |
|
511 | - ]); |
|
512 | - $table->addColumn('remember', 'smallint', [ |
|
513 | - 'notnull' => true, |
|
514 | - 'length' => 1, |
|
515 | - 'default' => 0, |
|
516 | - 'unsigned' => true, |
|
517 | - ]); |
|
518 | - $table->addColumn('last_activity', 'integer', [ |
|
519 | - 'notnull' => true, |
|
520 | - 'length' => 4, |
|
521 | - 'default' => 0, |
|
522 | - 'unsigned' => true, |
|
523 | - ]); |
|
524 | - $table->addColumn('last_check', 'integer', [ |
|
525 | - 'notnull' => true, |
|
526 | - 'length' => 4, |
|
527 | - 'default' => 0, |
|
528 | - 'unsigned' => true, |
|
529 | - ]); |
|
530 | - $table->addColumn('scope', 'text', [ |
|
531 | - 'notnull' => false, |
|
532 | - ]); |
|
533 | - $table->setPrimaryKey(['id']); |
|
534 | - $table->addUniqueIndex(['token'], 'authtoken_token_index'); |
|
535 | - $table->addIndex(['last_activity'], 'authtoken_last_activity_idx'); |
|
536 | - } |
|
537 | - |
|
538 | - if (!$schema->hasTable('bruteforce_attempts')) { |
|
539 | - $table = $schema->createTable('bruteforce_attempts'); |
|
540 | - $table->addColumn('id', 'integer', [ |
|
541 | - 'autoincrement' => true, |
|
542 | - 'notnull' => true, |
|
543 | - 'length' => 4, |
|
544 | - 'unsigned' => true, |
|
545 | - ]); |
|
546 | - $table->addColumn('action', 'string', [ |
|
547 | - 'notnull' => true, |
|
548 | - 'length' => 64, |
|
549 | - 'default' => '', |
|
550 | - ]); |
|
551 | - $table->addColumn('occurred', 'integer', [ |
|
552 | - 'notnull' => true, |
|
553 | - 'length' => 4, |
|
554 | - 'default' => 0, |
|
555 | - 'unsigned' => true, |
|
556 | - ]); |
|
557 | - $table->addColumn('ip', 'string', [ |
|
558 | - 'notnull' => true, |
|
559 | - 'length' => 255, |
|
560 | - 'default' => '', |
|
561 | - ]); |
|
562 | - $table->addColumn('subnet', 'string', [ |
|
563 | - 'notnull' => true, |
|
564 | - 'length' => 255, |
|
565 | - 'default' => '', |
|
566 | - ]); |
|
567 | - $table->addColumn('metadata', 'string', [ |
|
568 | - 'notnull' => true, |
|
569 | - 'length' => 255, |
|
570 | - 'default' => '', |
|
571 | - ]); |
|
572 | - $table->setPrimaryKey(['id']); |
|
573 | - $table->addIndex(['ip'], 'bruteforce_attempts_ip'); |
|
574 | - $table->addIndex(['subnet'], 'bruteforce_attempts_subnet'); |
|
575 | - } |
|
576 | - |
|
577 | - if (!$schema->hasTable('vcategory')) { |
|
578 | - $table = $schema->createTable('vcategory'); |
|
579 | - $table->addColumn('id', 'integer', [ |
|
580 | - 'autoincrement' => true, |
|
581 | - 'notnull' => true, |
|
582 | - 'length' => 4, |
|
583 | - 'unsigned' => true, |
|
584 | - ]); |
|
585 | - $table->addColumn('uid', 'string', [ |
|
586 | - 'notnull' => true, |
|
587 | - 'length' => 64, |
|
588 | - 'default' => '', |
|
589 | - ]); |
|
590 | - $table->addColumn('type', 'string', [ |
|
591 | - 'notnull' => true, |
|
592 | - 'length' => 64, |
|
593 | - 'default' => '', |
|
594 | - ]); |
|
595 | - $table->addColumn('category', 'string', [ |
|
596 | - 'notnull' => true, |
|
597 | - 'length' => 255, |
|
598 | - 'default' => '', |
|
599 | - ]); |
|
600 | - $table->setPrimaryKey(['id']); |
|
601 | - $table->addIndex(['uid'], 'uid_index'); |
|
602 | - $table->addIndex(['type'], 'type_index'); |
|
603 | - $table->addIndex(['category'], 'category_index'); |
|
604 | - } |
|
605 | - |
|
606 | - if (!$schema->hasTable('vcategory_to_object')) { |
|
607 | - $table = $schema->createTable('vcategory_to_object'); |
|
608 | - $table->addColumn('objid', 'integer', [ |
|
609 | - 'notnull' => true, |
|
610 | - 'length' => 4, |
|
611 | - 'default' => 0, |
|
612 | - 'unsigned' => true, |
|
613 | - ]); |
|
614 | - $table->addColumn('categoryid', 'integer', [ |
|
615 | - 'notnull' => true, |
|
616 | - 'length' => 4, |
|
617 | - 'default' => 0, |
|
618 | - 'unsigned' => true, |
|
619 | - ]); |
|
620 | - $table->addColumn('type', 'string', [ |
|
621 | - 'notnull' => true, |
|
622 | - 'length' => 64, |
|
623 | - 'default' => '', |
|
624 | - ]); |
|
625 | - $table->setPrimaryKey(['categoryid', 'objid', 'type']); |
|
626 | - $table->addIndex(['objid', 'type'], 'vcategory_objectd_index'); |
|
627 | - } |
|
628 | - |
|
629 | - if (!$schema->hasTable('systemtag')) { |
|
630 | - $table = $schema->createTable('systemtag'); |
|
631 | - $table->addColumn('id', 'integer', [ |
|
632 | - 'autoincrement' => true, |
|
633 | - 'notnull' => true, |
|
634 | - 'length' => 4, |
|
635 | - 'unsigned' => true, |
|
636 | - ]); |
|
637 | - $table->addColumn('name', 'string', [ |
|
638 | - 'notnull' => true, |
|
639 | - 'length' => 64, |
|
640 | - 'default' => '', |
|
641 | - ]); |
|
642 | - $table->addColumn('visibility', 'smallint', [ |
|
643 | - 'notnull' => true, |
|
644 | - 'length' => 1, |
|
645 | - 'default' => 1, |
|
646 | - ]); |
|
647 | - $table->addColumn('editable', 'smallint', [ |
|
648 | - 'notnull' => true, |
|
649 | - 'length' => 1, |
|
650 | - 'default' => 1, |
|
651 | - ]); |
|
652 | - $table->setPrimaryKey(['id']); |
|
653 | - $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
|
654 | - } |
|
655 | - |
|
656 | - if (!$schema->hasTable('systemtag_object_mapping')) { |
|
657 | - $table = $schema->createTable('systemtag_object_mapping'); |
|
658 | - $table->addColumn('objectid', 'string', [ |
|
659 | - 'notnull' => true, |
|
660 | - 'length' => 64, |
|
661 | - 'default' => '', |
|
662 | - ]); |
|
663 | - $table->addColumn('objecttype', 'string', [ |
|
664 | - 'notnull' => true, |
|
665 | - 'length' => 64, |
|
666 | - 'default' => '', |
|
667 | - ]); |
|
668 | - $table->addColumn('systemtagid', 'integer', [ |
|
669 | - 'notnull' => true, |
|
670 | - 'length' => 4, |
|
671 | - 'default' => 0, |
|
672 | - 'unsigned' => true, |
|
673 | - ]); |
|
674 | - $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); |
|
675 | - } |
|
676 | - |
|
677 | - if (!$schema->hasTable('systemtag_group')) { |
|
678 | - $table = $schema->createTable('systemtag_group'); |
|
679 | - $table->addColumn('systemtagid', 'integer', [ |
|
680 | - 'notnull' => true, |
|
681 | - 'length' => 4, |
|
682 | - 'default' => 0, |
|
683 | - 'unsigned' => true, |
|
684 | - ]); |
|
685 | - $table->addColumn('gid', 'string', [ |
|
686 | - 'notnull' => true, |
|
687 | - ]); |
|
688 | - $table->setPrimaryKey(['gid', 'systemtagid']); |
|
689 | - } |
|
690 | - |
|
691 | - if (!$schema->hasTable('file_locks')) { |
|
692 | - $table = $schema->createTable('file_locks'); |
|
693 | - $table->addColumn('id', 'integer', [ |
|
694 | - 'autoincrement' => true, |
|
695 | - 'notnull' => true, |
|
696 | - 'length' => 4, |
|
697 | - 'unsigned' => true, |
|
698 | - ]); |
|
699 | - $table->addColumn('lock', 'integer', [ |
|
700 | - 'notnull' => true, |
|
701 | - 'length' => 4, |
|
702 | - 'default' => 0, |
|
703 | - ]); |
|
704 | - $table->addColumn('key', 'string', [ |
|
705 | - 'notnull' => true, |
|
706 | - 'length' => 64, |
|
707 | - ]); |
|
708 | - $table->addColumn('ttl', 'integer', [ |
|
709 | - 'notnull' => true, |
|
710 | - 'length' => 4, |
|
711 | - 'default' => -1, |
|
712 | - ]); |
|
713 | - $table->setPrimaryKey(['id']); |
|
714 | - $table->addUniqueIndex(['key'], 'lock_key_index'); |
|
715 | - $table->addIndex(['ttl'], 'lock_ttl_index'); |
|
716 | - } |
|
717 | - |
|
718 | - if (!$schema->hasTable('comments')) { |
|
719 | - $table = $schema->createTable('comments'); |
|
720 | - $table->addColumn('id', 'integer', [ |
|
721 | - 'autoincrement' => true, |
|
722 | - 'notnull' => true, |
|
723 | - 'length' => 4, |
|
724 | - 'unsigned' => true, |
|
725 | - ]); |
|
726 | - $table->addColumn('parent_id', 'integer', [ |
|
727 | - 'notnull' => true, |
|
728 | - 'length' => 4, |
|
729 | - 'default' => 0, |
|
730 | - 'unsigned' => true, |
|
731 | - ]); |
|
732 | - $table->addColumn('topmost_parent_id', 'integer', [ |
|
733 | - 'notnull' => true, |
|
734 | - 'length' => 4, |
|
735 | - 'default' => 0, |
|
736 | - 'unsigned' => true, |
|
737 | - ]); |
|
738 | - $table->addColumn('children_count', 'integer', [ |
|
739 | - 'notnull' => true, |
|
740 | - 'length' => 4, |
|
741 | - 'default' => 0, |
|
742 | - 'unsigned' => true, |
|
743 | - ]); |
|
744 | - $table->addColumn('actor_type', 'string', [ |
|
745 | - 'notnull' => true, |
|
746 | - 'length' => 64, |
|
747 | - 'default' => '', |
|
748 | - ]); |
|
749 | - $table->addColumn('actor_id', 'string', [ |
|
750 | - 'notnull' => true, |
|
751 | - 'length' => 64, |
|
752 | - 'default' => '', |
|
753 | - ]); |
|
754 | - $table->addColumn('message', 'text', [ |
|
755 | - 'notnull' => false, |
|
756 | - ]); |
|
757 | - $table->addColumn('verb', 'string', [ |
|
758 | - 'notnull' => false, |
|
759 | - 'length' => 64, |
|
760 | - ]); |
|
761 | - $table->addColumn('creation_timestamp', 'datetime', [ |
|
762 | - 'notnull' => false, |
|
763 | - ]); |
|
764 | - $table->addColumn('latest_child_timestamp', 'datetime', [ |
|
765 | - 'notnull' => false, |
|
766 | - ]); |
|
767 | - $table->addColumn('object_type', 'string', [ |
|
768 | - 'notnull' => true, |
|
769 | - 'length' => 64, |
|
770 | - 'default' => '', |
|
771 | - ]); |
|
772 | - $table->addColumn('object_id', 'string', [ |
|
773 | - 'notnull' => true, |
|
774 | - 'length' => 64, |
|
775 | - 'default' => '', |
|
776 | - ]); |
|
777 | - $table->addColumn('reference_id', 'string', [ |
|
778 | - 'notnull' => false, |
|
779 | - 'length' => 64, |
|
780 | - ]); |
|
781 | - $table->setPrimaryKey(['id']); |
|
782 | - $table->addIndex(['parent_id'], 'comments_parent_id_index'); |
|
783 | - $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
|
784 | - $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
|
785 | - $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
|
786 | - } |
|
787 | - |
|
788 | - if (!$schema->hasTable('comments_read_markers')) { |
|
789 | - $table = $schema->createTable('comments_read_markers'); |
|
790 | - $table->addColumn('user_id', 'string', [ |
|
791 | - 'notnull' => true, |
|
792 | - 'length' => 64, |
|
793 | - 'default' => '', |
|
794 | - ]); |
|
795 | - $table->addColumn('marker_datetime', 'datetime', [ |
|
796 | - 'notnull' => false, |
|
797 | - ]); |
|
798 | - $table->addColumn('object_type', 'string', [ |
|
799 | - 'notnull' => true, |
|
800 | - 'length' => 64, |
|
801 | - 'default' => '', |
|
802 | - ]); |
|
803 | - $table->addColumn('object_id', 'string', [ |
|
804 | - 'notnull' => true, |
|
805 | - 'length' => 64, |
|
806 | - 'default' => '', |
|
807 | - ]); |
|
808 | - $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
|
809 | - $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); |
|
810 | - } |
|
811 | - |
|
812 | - if (!$schema->hasTable('credentials')) { |
|
813 | - $table = $schema->createTable('credentials'); |
|
814 | - $table->addColumn('user', 'string', [ |
|
815 | - 'notnull' => true, |
|
816 | - 'length' => 64, |
|
817 | - ]); |
|
818 | - $table->addColumn('identifier', 'string', [ |
|
819 | - 'notnull' => true, |
|
820 | - 'length' => 64, |
|
821 | - ]); |
|
822 | - $table->addColumn('credentials', 'text', [ |
|
823 | - 'notnull' => false, |
|
824 | - ]); |
|
825 | - $table->setPrimaryKey(['user', 'identifier']); |
|
826 | - $table->addIndex(['user'], 'credentials_user'); |
|
827 | - } |
|
828 | - |
|
829 | - if (!$schema->hasTable('admin_sections')) { |
|
830 | - $table = $schema->createTable('admin_sections'); |
|
831 | - $table->addColumn('id', 'string', [ |
|
832 | - 'notnull' => true, |
|
833 | - 'length' => 64, |
|
834 | - ]); |
|
835 | - $table->addColumn('class', 'string', [ |
|
836 | - 'notnull' => true, |
|
837 | - 'length' => 255, |
|
838 | - 'default' => '', |
|
839 | - ]); |
|
840 | - $table->addColumn('priority', 'smallint', [ |
|
841 | - 'notnull' => true, |
|
842 | - 'length' => 1, |
|
843 | - 'default' => 0, |
|
844 | - ]); |
|
845 | - $table->setPrimaryKey(['id']); |
|
846 | - $table->addUniqueIndex(['class'], 'admin_sections_class'); |
|
847 | - } |
|
848 | - |
|
849 | - if (!$schema->hasTable('admin_settings')) { |
|
850 | - $table = $schema->createTable('admin_settings'); |
|
851 | - $table->addColumn('id', 'integer', [ |
|
852 | - 'autoincrement' => true, |
|
853 | - 'notnull' => true, |
|
854 | - 'length' => 4, |
|
855 | - ]); |
|
856 | - $table->addColumn('class', 'string', [ |
|
857 | - 'notnull' => true, |
|
858 | - 'length' => 255, |
|
859 | - 'default' => '', |
|
860 | - ]); |
|
861 | - $table->addColumn('section', 'string', [ |
|
862 | - 'notnull' => false, |
|
863 | - 'length' => 64, |
|
864 | - ]); |
|
865 | - $table->addColumn('priority', 'smallint', [ |
|
866 | - 'notnull' => true, |
|
867 | - 'length' => 1, |
|
868 | - 'default' => 0, |
|
869 | - ]); |
|
870 | - $table->setPrimaryKey(['id']); |
|
871 | - $table->addUniqueIndex(['class'], 'admin_settings_class'); |
|
872 | - $table->addIndex(['section'], 'admin_settings_section'); |
|
873 | - } |
|
874 | - |
|
875 | - if (!$schema->hasTable('personal_sections')) { |
|
876 | - $table = $schema->createTable('personal_sections'); |
|
877 | - $table->addColumn('id', 'string', [ |
|
878 | - 'notnull' => true, |
|
879 | - 'length' => 64, |
|
880 | - ]); |
|
881 | - $table->addColumn('class', 'string', [ |
|
882 | - 'notnull' => true, |
|
883 | - 'length' => 255, |
|
884 | - 'default' => '', |
|
885 | - ]); |
|
886 | - $table->addColumn('priority', 'smallint', [ |
|
887 | - 'notnull' => true, |
|
888 | - 'length' => 1, |
|
889 | - 'default' => 0, |
|
890 | - ]); |
|
891 | - $table->setPrimaryKey(['id']); |
|
892 | - $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
893 | - } |
|
894 | - |
|
895 | - if (!$schema->hasTable('personal_settings')) { |
|
896 | - $table = $schema->createTable('personal_settings'); |
|
897 | - $table->addColumn('id', 'integer', [ |
|
898 | - 'autoincrement' => true, |
|
899 | - 'notnull' => true, |
|
900 | - 'length' => 4, |
|
901 | - ]); |
|
902 | - $table->addColumn('class', 'string', [ |
|
903 | - 'notnull' => true, |
|
904 | - 'length' => 255, |
|
905 | - 'default' => '', |
|
906 | - ]); |
|
907 | - $table->addColumn('section', 'string', [ |
|
908 | - 'notnull' => false, |
|
909 | - 'length' => 64, |
|
910 | - ]); |
|
911 | - $table->addColumn('priority', 'smallint', [ |
|
912 | - 'notnull' => true, |
|
913 | - 'length' => 1, |
|
914 | - 'default' => 0, |
|
915 | - ]); |
|
916 | - $table->setPrimaryKey(['id']); |
|
917 | - $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
918 | - $table->addIndex(['section'], 'personal_settings_section'); |
|
919 | - } |
|
920 | - |
|
921 | - if (!$schema->hasTable('accounts')) { |
|
922 | - $table = $schema->createTable('accounts'); |
|
923 | - $table->addColumn('uid', 'string', [ |
|
924 | - 'notnull' => true, |
|
925 | - 'length' => 64, |
|
926 | - 'default' => '', |
|
927 | - ]); |
|
928 | - $table->addColumn('data', 'text', [ |
|
929 | - 'notnull' => true, |
|
930 | - 'default' => '', |
|
931 | - ]); |
|
932 | - $table->setPrimaryKey(['uid']); |
|
933 | - } |
|
934 | - return $schema; |
|
935 | - } |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * @return null|ISchemaWrapper |
|
43 | + * @since 13.0.0 |
|
44 | + */ |
|
45 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
46 | + /** @var ISchemaWrapper $schema */ |
|
47 | + $schema = $schemaClosure(); |
|
48 | + |
|
49 | + if (!$schema->hasTable('appconfig')) { |
|
50 | + $table = $schema->createTable('appconfig'); |
|
51 | + $table->addColumn('appid', 'string', [ |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 32, |
|
54 | + 'default' => '', |
|
55 | + ]); |
|
56 | + $table->addColumn('configkey', 'string', [ |
|
57 | + 'notnull' => true, |
|
58 | + 'length' => 64, |
|
59 | + 'default' => '', |
|
60 | + ]); |
|
61 | + $table->addColumn('configvalue', 'text', [ |
|
62 | + 'notnull' => false, |
|
63 | + ]); |
|
64 | + $table->setPrimaryKey(['appid', 'configkey']); |
|
65 | + $table->addIndex(['configkey'], 'appconfig_config_key_index'); |
|
66 | + $table->addIndex(['appid'], 'appconfig_appid_key'); |
|
67 | + } |
|
68 | + |
|
69 | + if (!$schema->hasTable('storages')) { |
|
70 | + $table = $schema->createTable('storages'); |
|
71 | + $table->addColumn('id', 'string', [ |
|
72 | + 'notnull' => false, |
|
73 | + 'length' => 64, |
|
74 | + ]); |
|
75 | + $table->addColumn('numeric_id', Types::BIGINT, [ |
|
76 | + 'autoincrement' => true, |
|
77 | + 'notnull' => true, |
|
78 | + 'length' => 20, |
|
79 | + ]); |
|
80 | + $table->addColumn('available', 'integer', [ |
|
81 | + 'notnull' => true, |
|
82 | + 'default' => 1, |
|
83 | + ]); |
|
84 | + $table->addColumn('last_checked', 'integer', [ |
|
85 | + 'notnull' => false, |
|
86 | + ]); |
|
87 | + $table->setPrimaryKey(['numeric_id']); |
|
88 | + $table->addUniqueIndex(['id'], 'storages_id_index'); |
|
89 | + } |
|
90 | + |
|
91 | + if (!$schema->hasTable('mounts')) { |
|
92 | + $table = $schema->createTable('mounts'); |
|
93 | + $table->addColumn('id', 'integer', [ |
|
94 | + 'autoincrement' => true, |
|
95 | + 'notnull' => true, |
|
96 | + 'length' => 4, |
|
97 | + ]); |
|
98 | + $table->addColumn('storage_id', Types::BIGINT, [ |
|
99 | + 'notnull' => true, |
|
100 | + 'length' => 20, |
|
101 | + ]); |
|
102 | + $table->addColumn('root_id', Types::BIGINT, [ |
|
103 | + 'notnull' => true, |
|
104 | + 'length' => 20, |
|
105 | + ]); |
|
106 | + $table->addColumn('user_id', 'string', [ |
|
107 | + 'notnull' => true, |
|
108 | + 'length' => 64, |
|
109 | + ]); |
|
110 | + $table->addColumn('mount_point', 'string', [ |
|
111 | + 'notnull' => true, |
|
112 | + 'length' => 4000, |
|
113 | + ]); |
|
114 | + $table->addColumn('mount_id', Types::BIGINT, [ |
|
115 | + 'notnull' => false, |
|
116 | + 'length' => 20, |
|
117 | + ]); |
|
118 | + $table->setPrimaryKey(['id']); |
|
119 | + $table->addIndex(['user_id'], 'mounts_user_index'); |
|
120 | + $table->addIndex(['storage_id'], 'mounts_storage_index'); |
|
121 | + $table->addIndex(['root_id'], 'mounts_root_index'); |
|
122 | + $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
123 | + $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
|
124 | + } |
|
125 | + |
|
126 | + if (!$schema->hasTable('mimetypes')) { |
|
127 | + $table = $schema->createTable('mimetypes'); |
|
128 | + $table->addColumn('id', Types::BIGINT, [ |
|
129 | + 'autoincrement' => true, |
|
130 | + 'notnull' => true, |
|
131 | + 'length' => 20, |
|
132 | + ]); |
|
133 | + $table->addColumn('mimetype', 'string', [ |
|
134 | + 'notnull' => true, |
|
135 | + 'length' => 255, |
|
136 | + 'default' => '', |
|
137 | + ]); |
|
138 | + $table->setPrimaryKey(['id']); |
|
139 | + $table->addUniqueIndex(['mimetype'], 'mimetype_id_index'); |
|
140 | + } |
|
141 | + |
|
142 | + if (!$schema->hasTable('filecache')) { |
|
143 | + $table = $schema->createTable('filecache'); |
|
144 | + $table->addColumn('fileid', Types::BIGINT, [ |
|
145 | + 'autoincrement' => true, |
|
146 | + 'notnull' => true, |
|
147 | + 'length' => 20, |
|
148 | + ]); |
|
149 | + $table->addColumn('storage', Types::BIGINT, [ |
|
150 | + 'notnull' => true, |
|
151 | + 'length' => 20, |
|
152 | + 'default' => 0, |
|
153 | + ]); |
|
154 | + $table->addColumn('path', 'string', [ |
|
155 | + 'notnull' => false, |
|
156 | + 'length' => 4000, |
|
157 | + ]); |
|
158 | + $table->addColumn('path_hash', 'string', [ |
|
159 | + 'notnull' => true, |
|
160 | + 'length' => 32, |
|
161 | + 'default' => '', |
|
162 | + ]); |
|
163 | + $table->addColumn('parent', Types::BIGINT, [ |
|
164 | + 'notnull' => true, |
|
165 | + 'length' => 20, |
|
166 | + 'default' => 0, |
|
167 | + ]); |
|
168 | + $table->addColumn('name', 'string', [ |
|
169 | + 'notnull' => false, |
|
170 | + 'length' => 250, |
|
171 | + ]); |
|
172 | + $table->addColumn('mimetype', Types::BIGINT, [ |
|
173 | + 'notnull' => true, |
|
174 | + 'length' => 20, |
|
175 | + 'default' => 0, |
|
176 | + ]); |
|
177 | + $table->addColumn('mimepart', Types::BIGINT, [ |
|
178 | + 'notnull' => true, |
|
179 | + 'length' => 20, |
|
180 | + 'default' => 0, |
|
181 | + ]); |
|
182 | + $table->addColumn('size', 'bigint', [ |
|
183 | + 'notnull' => true, |
|
184 | + 'length' => 8, |
|
185 | + 'default' => 0, |
|
186 | + ]); |
|
187 | + $table->addColumn('mtime', Types::BIGINT, [ |
|
188 | + 'notnull' => true, |
|
189 | + 'length' => 20, |
|
190 | + 'default' => 0, |
|
191 | + ]); |
|
192 | + $table->addColumn('storage_mtime', Types::BIGINT, [ |
|
193 | + 'notnull' => true, |
|
194 | + 'length' => 20, |
|
195 | + 'default' => 0, |
|
196 | + ]); |
|
197 | + $table->addColumn('encrypted', 'integer', [ |
|
198 | + 'notnull' => true, |
|
199 | + 'length' => 4, |
|
200 | + 'default' => 0, |
|
201 | + ]); |
|
202 | + $table->addColumn('unencrypted_size', 'bigint', [ |
|
203 | + 'notnull' => true, |
|
204 | + 'length' => 8, |
|
205 | + 'default' => 0, |
|
206 | + ]); |
|
207 | + $table->addColumn('etag', 'string', [ |
|
208 | + 'notnull' => false, |
|
209 | + 'length' => 40, |
|
210 | + ]); |
|
211 | + $table->addColumn('permissions', 'integer', [ |
|
212 | + 'notnull' => false, |
|
213 | + 'length' => 4, |
|
214 | + 'default' => 0, |
|
215 | + ]); |
|
216 | + $table->addColumn('checksum', 'string', [ |
|
217 | + 'notnull' => false, |
|
218 | + 'length' => 255, |
|
219 | + ]); |
|
220 | + $table->setPrimaryKey(['fileid']); |
|
221 | + $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash'); |
|
222 | + $table->addIndex(['parent', 'name'], 'fs_parent_name_hash'); |
|
223 | + $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); |
|
224 | + $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); |
|
225 | + $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); |
|
226 | + $table->addIndex(['mtime'], 'fs_mtime'); |
|
227 | + } |
|
228 | + |
|
229 | + if (!$schema->hasTable('group_user')) { |
|
230 | + $table = $schema->createTable('group_user'); |
|
231 | + $table->addColumn('gid', 'string', [ |
|
232 | + 'notnull' => true, |
|
233 | + 'length' => 64, |
|
234 | + 'default' => '', |
|
235 | + ]); |
|
236 | + $table->addColumn('uid', 'string', [ |
|
237 | + 'notnull' => true, |
|
238 | + 'length' => 64, |
|
239 | + 'default' => '', |
|
240 | + ]); |
|
241 | + $table->setPrimaryKey(['gid', 'uid']); |
|
242 | + $table->addIndex(['uid'], 'gu_uid_index'); |
|
243 | + } |
|
244 | + |
|
245 | + if (!$schema->hasTable('group_admin')) { |
|
246 | + $table = $schema->createTable('group_admin'); |
|
247 | + $table->addColumn('gid', 'string', [ |
|
248 | + 'notnull' => true, |
|
249 | + 'length' => 64, |
|
250 | + 'default' => '', |
|
251 | + ]); |
|
252 | + $table->addColumn('uid', 'string', [ |
|
253 | + 'notnull' => true, |
|
254 | + 'length' => 64, |
|
255 | + 'default' => '', |
|
256 | + ]); |
|
257 | + $table->setPrimaryKey(['gid', 'uid']); |
|
258 | + $table->addIndex(['uid'], 'group_admin_uid'); |
|
259 | + } |
|
260 | + |
|
261 | + if (!$schema->hasTable('groups')) { |
|
262 | + $table = $schema->createTable('groups'); |
|
263 | + $table->addColumn('gid', 'string', [ |
|
264 | + 'notnull' => true, |
|
265 | + 'length' => 64, |
|
266 | + 'default' => '', |
|
267 | + ]); |
|
268 | + $table->setPrimaryKey(['gid']); |
|
269 | + } |
|
270 | + |
|
271 | + if (!$schema->hasTable('preferences')) { |
|
272 | + $table = $schema->createTable('preferences'); |
|
273 | + $table->addColumn('userid', 'string', [ |
|
274 | + 'notnull' => true, |
|
275 | + 'length' => 64, |
|
276 | + 'default' => '', |
|
277 | + ]); |
|
278 | + $table->addColumn('appid', 'string', [ |
|
279 | + 'notnull' => true, |
|
280 | + 'length' => 32, |
|
281 | + 'default' => '', |
|
282 | + ]); |
|
283 | + $table->addColumn('configkey', 'string', [ |
|
284 | + 'notnull' => true, |
|
285 | + 'length' => 64, |
|
286 | + 'default' => '', |
|
287 | + ]); |
|
288 | + $table->addColumn('configvalue', 'text', [ |
|
289 | + 'notnull' => false, |
|
290 | + ]); |
|
291 | + $table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
292 | + } |
|
293 | + |
|
294 | + if (!$schema->hasTable('properties')) { |
|
295 | + $table = $schema->createTable('properties'); |
|
296 | + $table->addColumn('id', 'integer', [ |
|
297 | + 'autoincrement' => true, |
|
298 | + 'notnull' => true, |
|
299 | + 'length' => 4, |
|
300 | + ]); |
|
301 | + $table->addColumn('userid', 'string', [ |
|
302 | + 'notnull' => true, |
|
303 | + 'length' => 64, |
|
304 | + 'default' => '', |
|
305 | + ]); |
|
306 | + $table->addColumn('propertypath', 'string', [ |
|
307 | + 'notnull' => true, |
|
308 | + 'length' => 255, |
|
309 | + 'default' => '', |
|
310 | + ]); |
|
311 | + $table->addColumn('propertyname', 'string', [ |
|
312 | + 'notnull' => true, |
|
313 | + 'length' => 255, |
|
314 | + 'default' => '', |
|
315 | + ]); |
|
316 | + $table->addColumn('propertyvalue', 'text', [ |
|
317 | + 'notnull' => true, |
|
318 | + ]); |
|
319 | + $table->setPrimaryKey(['id']); |
|
320 | + $table->addIndex(['userid'], 'property_index'); |
|
321 | + $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
322 | + } |
|
323 | + |
|
324 | + if (!$schema->hasTable('share')) { |
|
325 | + $table = $schema->createTable('share'); |
|
326 | + $table->addColumn('id', 'integer', [ |
|
327 | + 'autoincrement' => true, |
|
328 | + 'notnull' => true, |
|
329 | + 'length' => 4, |
|
330 | + ]); |
|
331 | + $table->addColumn('share_type', 'smallint', [ |
|
332 | + 'notnull' => true, |
|
333 | + 'length' => 1, |
|
334 | + 'default' => 0, |
|
335 | + ]); |
|
336 | + $table->addColumn('share_with', 'string', [ |
|
337 | + 'notnull' => false, |
|
338 | + 'length' => 255, |
|
339 | + ]); |
|
340 | + $table->addColumn('password', 'string', [ |
|
341 | + 'notnull' => false, |
|
342 | + 'length' => 255, |
|
343 | + ]); |
|
344 | + $table->addColumn('uid_owner', 'string', [ |
|
345 | + 'notnull' => true, |
|
346 | + 'length' => 64, |
|
347 | + 'default' => '', |
|
348 | + ]); |
|
349 | + $table->addColumn('uid_initiator', 'string', [ |
|
350 | + 'notnull' => false, |
|
351 | + 'length' => 64, |
|
352 | + ]); |
|
353 | + $table->addColumn('parent', 'integer', [ |
|
354 | + 'notnull' => false, |
|
355 | + 'length' => 4, |
|
356 | + ]); |
|
357 | + $table->addColumn('item_type', 'string', [ |
|
358 | + 'notnull' => true, |
|
359 | + 'length' => 64, |
|
360 | + 'default' => '', |
|
361 | + ]); |
|
362 | + $table->addColumn('item_source', 'string', [ |
|
363 | + 'notnull' => false, |
|
364 | + 'length' => 255, |
|
365 | + ]); |
|
366 | + $table->addColumn('item_target', 'string', [ |
|
367 | + 'notnull' => false, |
|
368 | + 'length' => 255, |
|
369 | + ]); |
|
370 | + $table->addColumn('file_source', 'integer', [ |
|
371 | + 'notnull' => false, |
|
372 | + 'length' => 4, |
|
373 | + ]); |
|
374 | + $table->addColumn('file_target', 'string', [ |
|
375 | + 'notnull' => false, |
|
376 | + 'length' => 512, |
|
377 | + ]); |
|
378 | + $table->addColumn('permissions', 'smallint', [ |
|
379 | + 'notnull' => true, |
|
380 | + 'length' => 1, |
|
381 | + 'default' => 0, |
|
382 | + ]); |
|
383 | + $table->addColumn('stime', 'bigint', [ |
|
384 | + 'notnull' => true, |
|
385 | + 'length' => 8, |
|
386 | + 'default' => 0, |
|
387 | + ]); |
|
388 | + $table->addColumn('accepted', 'smallint', [ |
|
389 | + 'notnull' => true, |
|
390 | + 'length' => 1, |
|
391 | + 'default' => 0, |
|
392 | + ]); |
|
393 | + $table->addColumn('expiration', 'datetime', [ |
|
394 | + 'notnull' => false, |
|
395 | + ]); |
|
396 | + $table->addColumn('token', 'string', [ |
|
397 | + 'notnull' => false, |
|
398 | + 'length' => 32, |
|
399 | + ]); |
|
400 | + $table->addColumn('mail_send', 'smallint', [ |
|
401 | + 'notnull' => true, |
|
402 | + 'length' => 1, |
|
403 | + 'default' => 0, |
|
404 | + ]); |
|
405 | + $table->addColumn('share_name', 'string', [ |
|
406 | + 'notnull' => false, |
|
407 | + 'length' => 64, |
|
408 | + ]); |
|
409 | + $table->setPrimaryKey(['id']); |
|
410 | + $table->addIndex(['item_type', 'share_type'], 'item_share_type_index'); |
|
411 | + $table->addIndex(['file_source'], 'file_source_index'); |
|
412 | + $table->addIndex(['token'], 'token_index'); |
|
413 | + $table->addIndex(['share_with'], 'share_with_index'); |
|
414 | + $table->addIndex(['parent'], 'parent_index'); |
|
415 | + $table->addIndex(['uid_owner'], 'owner_index'); |
|
416 | + $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
417 | + } |
|
418 | + |
|
419 | + if (!$schema->hasTable('jobs')) { |
|
420 | + $table = $schema->createTable('jobs'); |
|
421 | + $table->addColumn('id', 'integer', [ |
|
422 | + 'autoincrement' => true, |
|
423 | + 'notnull' => true, |
|
424 | + 'length' => 4, |
|
425 | + 'unsigned' => true, |
|
426 | + ]); |
|
427 | + $table->addColumn('class', 'string', [ |
|
428 | + 'notnull' => true, |
|
429 | + 'length' => 255, |
|
430 | + 'default' => '', |
|
431 | + ]); |
|
432 | + $table->addColumn('argument', 'string', [ |
|
433 | + 'notnull' => true, |
|
434 | + 'length' => 4000, |
|
435 | + 'default' => '', |
|
436 | + ]); |
|
437 | + $table->addColumn('last_run', 'integer', [ |
|
438 | + 'notnull' => false, |
|
439 | + 'default' => 0, |
|
440 | + ]); |
|
441 | + $table->addColumn('last_checked', 'integer', [ |
|
442 | + 'notnull' => false, |
|
443 | + 'default' => 0, |
|
444 | + ]); |
|
445 | + $table->addColumn('reserved_at', 'integer', [ |
|
446 | + 'notnull' => false, |
|
447 | + 'default' => 0, |
|
448 | + ]); |
|
449 | + $table->addColumn('execution_duration', 'integer', [ |
|
450 | + 'notnull' => true, |
|
451 | + 'default' => 0, |
|
452 | + ]); |
|
453 | + $table->setPrimaryKey(['id']); |
|
454 | + $table->addIndex(['class'], 'job_class_index'); |
|
455 | + } |
|
456 | + |
|
457 | + if (!$schema->hasTable('users')) { |
|
458 | + $table = $schema->createTable('users'); |
|
459 | + $table->addColumn('uid', 'string', [ |
|
460 | + 'notnull' => true, |
|
461 | + 'length' => 64, |
|
462 | + 'default' => '', |
|
463 | + ]); |
|
464 | + $table->addColumn('displayname', 'string', [ |
|
465 | + 'notnull' => false, |
|
466 | + 'length' => 64, |
|
467 | + ]); |
|
468 | + $table->addColumn('password', 'string', [ |
|
469 | + 'notnull' => true, |
|
470 | + 'length' => 255, |
|
471 | + 'default' => '', |
|
472 | + ]); |
|
473 | + $table->setPrimaryKey(['uid']); |
|
474 | + } |
|
475 | + |
|
476 | + if (!$schema->hasTable('authtoken')) { |
|
477 | + $table = $schema->createTable('authtoken'); |
|
478 | + $table->addColumn('id', 'integer', [ |
|
479 | + 'autoincrement' => true, |
|
480 | + 'notnull' => true, |
|
481 | + 'length' => 4, |
|
482 | + 'unsigned' => true, |
|
483 | + ]); |
|
484 | + $table->addColumn('uid', 'string', [ |
|
485 | + 'notnull' => true, |
|
486 | + 'length' => 64, |
|
487 | + 'default' => '', |
|
488 | + ]); |
|
489 | + $table->addColumn('login_name', 'string', [ |
|
490 | + 'notnull' => true, |
|
491 | + 'length' => 64, |
|
492 | + 'default' => '', |
|
493 | + ]); |
|
494 | + $table->addColumn('password', 'text', [ |
|
495 | + 'notnull' => false, |
|
496 | + ]); |
|
497 | + $table->addColumn('name', 'text', [ |
|
498 | + 'notnull' => true, |
|
499 | + 'default' => '', |
|
500 | + ]); |
|
501 | + $table->addColumn('token', 'string', [ |
|
502 | + 'notnull' => true, |
|
503 | + 'length' => 200, |
|
504 | + 'default' => '', |
|
505 | + ]); |
|
506 | + $table->addColumn('type', 'smallint', [ |
|
507 | + 'notnull' => true, |
|
508 | + 'length' => 2, |
|
509 | + 'default' => 0, |
|
510 | + 'unsigned' => true, |
|
511 | + ]); |
|
512 | + $table->addColumn('remember', 'smallint', [ |
|
513 | + 'notnull' => true, |
|
514 | + 'length' => 1, |
|
515 | + 'default' => 0, |
|
516 | + 'unsigned' => true, |
|
517 | + ]); |
|
518 | + $table->addColumn('last_activity', 'integer', [ |
|
519 | + 'notnull' => true, |
|
520 | + 'length' => 4, |
|
521 | + 'default' => 0, |
|
522 | + 'unsigned' => true, |
|
523 | + ]); |
|
524 | + $table->addColumn('last_check', 'integer', [ |
|
525 | + 'notnull' => true, |
|
526 | + 'length' => 4, |
|
527 | + 'default' => 0, |
|
528 | + 'unsigned' => true, |
|
529 | + ]); |
|
530 | + $table->addColumn('scope', 'text', [ |
|
531 | + 'notnull' => false, |
|
532 | + ]); |
|
533 | + $table->setPrimaryKey(['id']); |
|
534 | + $table->addUniqueIndex(['token'], 'authtoken_token_index'); |
|
535 | + $table->addIndex(['last_activity'], 'authtoken_last_activity_idx'); |
|
536 | + } |
|
537 | + |
|
538 | + if (!$schema->hasTable('bruteforce_attempts')) { |
|
539 | + $table = $schema->createTable('bruteforce_attempts'); |
|
540 | + $table->addColumn('id', 'integer', [ |
|
541 | + 'autoincrement' => true, |
|
542 | + 'notnull' => true, |
|
543 | + 'length' => 4, |
|
544 | + 'unsigned' => true, |
|
545 | + ]); |
|
546 | + $table->addColumn('action', 'string', [ |
|
547 | + 'notnull' => true, |
|
548 | + 'length' => 64, |
|
549 | + 'default' => '', |
|
550 | + ]); |
|
551 | + $table->addColumn('occurred', 'integer', [ |
|
552 | + 'notnull' => true, |
|
553 | + 'length' => 4, |
|
554 | + 'default' => 0, |
|
555 | + 'unsigned' => true, |
|
556 | + ]); |
|
557 | + $table->addColumn('ip', 'string', [ |
|
558 | + 'notnull' => true, |
|
559 | + 'length' => 255, |
|
560 | + 'default' => '', |
|
561 | + ]); |
|
562 | + $table->addColumn('subnet', 'string', [ |
|
563 | + 'notnull' => true, |
|
564 | + 'length' => 255, |
|
565 | + 'default' => '', |
|
566 | + ]); |
|
567 | + $table->addColumn('metadata', 'string', [ |
|
568 | + 'notnull' => true, |
|
569 | + 'length' => 255, |
|
570 | + 'default' => '', |
|
571 | + ]); |
|
572 | + $table->setPrimaryKey(['id']); |
|
573 | + $table->addIndex(['ip'], 'bruteforce_attempts_ip'); |
|
574 | + $table->addIndex(['subnet'], 'bruteforce_attempts_subnet'); |
|
575 | + } |
|
576 | + |
|
577 | + if (!$schema->hasTable('vcategory')) { |
|
578 | + $table = $schema->createTable('vcategory'); |
|
579 | + $table->addColumn('id', 'integer', [ |
|
580 | + 'autoincrement' => true, |
|
581 | + 'notnull' => true, |
|
582 | + 'length' => 4, |
|
583 | + 'unsigned' => true, |
|
584 | + ]); |
|
585 | + $table->addColumn('uid', 'string', [ |
|
586 | + 'notnull' => true, |
|
587 | + 'length' => 64, |
|
588 | + 'default' => '', |
|
589 | + ]); |
|
590 | + $table->addColumn('type', 'string', [ |
|
591 | + 'notnull' => true, |
|
592 | + 'length' => 64, |
|
593 | + 'default' => '', |
|
594 | + ]); |
|
595 | + $table->addColumn('category', 'string', [ |
|
596 | + 'notnull' => true, |
|
597 | + 'length' => 255, |
|
598 | + 'default' => '', |
|
599 | + ]); |
|
600 | + $table->setPrimaryKey(['id']); |
|
601 | + $table->addIndex(['uid'], 'uid_index'); |
|
602 | + $table->addIndex(['type'], 'type_index'); |
|
603 | + $table->addIndex(['category'], 'category_index'); |
|
604 | + } |
|
605 | + |
|
606 | + if (!$schema->hasTable('vcategory_to_object')) { |
|
607 | + $table = $schema->createTable('vcategory_to_object'); |
|
608 | + $table->addColumn('objid', 'integer', [ |
|
609 | + 'notnull' => true, |
|
610 | + 'length' => 4, |
|
611 | + 'default' => 0, |
|
612 | + 'unsigned' => true, |
|
613 | + ]); |
|
614 | + $table->addColumn('categoryid', 'integer', [ |
|
615 | + 'notnull' => true, |
|
616 | + 'length' => 4, |
|
617 | + 'default' => 0, |
|
618 | + 'unsigned' => true, |
|
619 | + ]); |
|
620 | + $table->addColumn('type', 'string', [ |
|
621 | + 'notnull' => true, |
|
622 | + 'length' => 64, |
|
623 | + 'default' => '', |
|
624 | + ]); |
|
625 | + $table->setPrimaryKey(['categoryid', 'objid', 'type']); |
|
626 | + $table->addIndex(['objid', 'type'], 'vcategory_objectd_index'); |
|
627 | + } |
|
628 | + |
|
629 | + if (!$schema->hasTable('systemtag')) { |
|
630 | + $table = $schema->createTable('systemtag'); |
|
631 | + $table->addColumn('id', 'integer', [ |
|
632 | + 'autoincrement' => true, |
|
633 | + 'notnull' => true, |
|
634 | + 'length' => 4, |
|
635 | + 'unsigned' => true, |
|
636 | + ]); |
|
637 | + $table->addColumn('name', 'string', [ |
|
638 | + 'notnull' => true, |
|
639 | + 'length' => 64, |
|
640 | + 'default' => '', |
|
641 | + ]); |
|
642 | + $table->addColumn('visibility', 'smallint', [ |
|
643 | + 'notnull' => true, |
|
644 | + 'length' => 1, |
|
645 | + 'default' => 1, |
|
646 | + ]); |
|
647 | + $table->addColumn('editable', 'smallint', [ |
|
648 | + 'notnull' => true, |
|
649 | + 'length' => 1, |
|
650 | + 'default' => 1, |
|
651 | + ]); |
|
652 | + $table->setPrimaryKey(['id']); |
|
653 | + $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
|
654 | + } |
|
655 | + |
|
656 | + if (!$schema->hasTable('systemtag_object_mapping')) { |
|
657 | + $table = $schema->createTable('systemtag_object_mapping'); |
|
658 | + $table->addColumn('objectid', 'string', [ |
|
659 | + 'notnull' => true, |
|
660 | + 'length' => 64, |
|
661 | + 'default' => '', |
|
662 | + ]); |
|
663 | + $table->addColumn('objecttype', 'string', [ |
|
664 | + 'notnull' => true, |
|
665 | + 'length' => 64, |
|
666 | + 'default' => '', |
|
667 | + ]); |
|
668 | + $table->addColumn('systemtagid', 'integer', [ |
|
669 | + 'notnull' => true, |
|
670 | + 'length' => 4, |
|
671 | + 'default' => 0, |
|
672 | + 'unsigned' => true, |
|
673 | + ]); |
|
674 | + $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); |
|
675 | + } |
|
676 | + |
|
677 | + if (!$schema->hasTable('systemtag_group')) { |
|
678 | + $table = $schema->createTable('systemtag_group'); |
|
679 | + $table->addColumn('systemtagid', 'integer', [ |
|
680 | + 'notnull' => true, |
|
681 | + 'length' => 4, |
|
682 | + 'default' => 0, |
|
683 | + 'unsigned' => true, |
|
684 | + ]); |
|
685 | + $table->addColumn('gid', 'string', [ |
|
686 | + 'notnull' => true, |
|
687 | + ]); |
|
688 | + $table->setPrimaryKey(['gid', 'systemtagid']); |
|
689 | + } |
|
690 | + |
|
691 | + if (!$schema->hasTable('file_locks')) { |
|
692 | + $table = $schema->createTable('file_locks'); |
|
693 | + $table->addColumn('id', 'integer', [ |
|
694 | + 'autoincrement' => true, |
|
695 | + 'notnull' => true, |
|
696 | + 'length' => 4, |
|
697 | + 'unsigned' => true, |
|
698 | + ]); |
|
699 | + $table->addColumn('lock', 'integer', [ |
|
700 | + 'notnull' => true, |
|
701 | + 'length' => 4, |
|
702 | + 'default' => 0, |
|
703 | + ]); |
|
704 | + $table->addColumn('key', 'string', [ |
|
705 | + 'notnull' => true, |
|
706 | + 'length' => 64, |
|
707 | + ]); |
|
708 | + $table->addColumn('ttl', 'integer', [ |
|
709 | + 'notnull' => true, |
|
710 | + 'length' => 4, |
|
711 | + 'default' => -1, |
|
712 | + ]); |
|
713 | + $table->setPrimaryKey(['id']); |
|
714 | + $table->addUniqueIndex(['key'], 'lock_key_index'); |
|
715 | + $table->addIndex(['ttl'], 'lock_ttl_index'); |
|
716 | + } |
|
717 | + |
|
718 | + if (!$schema->hasTable('comments')) { |
|
719 | + $table = $schema->createTable('comments'); |
|
720 | + $table->addColumn('id', 'integer', [ |
|
721 | + 'autoincrement' => true, |
|
722 | + 'notnull' => true, |
|
723 | + 'length' => 4, |
|
724 | + 'unsigned' => true, |
|
725 | + ]); |
|
726 | + $table->addColumn('parent_id', 'integer', [ |
|
727 | + 'notnull' => true, |
|
728 | + 'length' => 4, |
|
729 | + 'default' => 0, |
|
730 | + 'unsigned' => true, |
|
731 | + ]); |
|
732 | + $table->addColumn('topmost_parent_id', 'integer', [ |
|
733 | + 'notnull' => true, |
|
734 | + 'length' => 4, |
|
735 | + 'default' => 0, |
|
736 | + 'unsigned' => true, |
|
737 | + ]); |
|
738 | + $table->addColumn('children_count', 'integer', [ |
|
739 | + 'notnull' => true, |
|
740 | + 'length' => 4, |
|
741 | + 'default' => 0, |
|
742 | + 'unsigned' => true, |
|
743 | + ]); |
|
744 | + $table->addColumn('actor_type', 'string', [ |
|
745 | + 'notnull' => true, |
|
746 | + 'length' => 64, |
|
747 | + 'default' => '', |
|
748 | + ]); |
|
749 | + $table->addColumn('actor_id', 'string', [ |
|
750 | + 'notnull' => true, |
|
751 | + 'length' => 64, |
|
752 | + 'default' => '', |
|
753 | + ]); |
|
754 | + $table->addColumn('message', 'text', [ |
|
755 | + 'notnull' => false, |
|
756 | + ]); |
|
757 | + $table->addColumn('verb', 'string', [ |
|
758 | + 'notnull' => false, |
|
759 | + 'length' => 64, |
|
760 | + ]); |
|
761 | + $table->addColumn('creation_timestamp', 'datetime', [ |
|
762 | + 'notnull' => false, |
|
763 | + ]); |
|
764 | + $table->addColumn('latest_child_timestamp', 'datetime', [ |
|
765 | + 'notnull' => false, |
|
766 | + ]); |
|
767 | + $table->addColumn('object_type', 'string', [ |
|
768 | + 'notnull' => true, |
|
769 | + 'length' => 64, |
|
770 | + 'default' => '', |
|
771 | + ]); |
|
772 | + $table->addColumn('object_id', 'string', [ |
|
773 | + 'notnull' => true, |
|
774 | + 'length' => 64, |
|
775 | + 'default' => '', |
|
776 | + ]); |
|
777 | + $table->addColumn('reference_id', 'string', [ |
|
778 | + 'notnull' => false, |
|
779 | + 'length' => 64, |
|
780 | + ]); |
|
781 | + $table->setPrimaryKey(['id']); |
|
782 | + $table->addIndex(['parent_id'], 'comments_parent_id_index'); |
|
783 | + $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
|
784 | + $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
|
785 | + $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
|
786 | + } |
|
787 | + |
|
788 | + if (!$schema->hasTable('comments_read_markers')) { |
|
789 | + $table = $schema->createTable('comments_read_markers'); |
|
790 | + $table->addColumn('user_id', 'string', [ |
|
791 | + 'notnull' => true, |
|
792 | + 'length' => 64, |
|
793 | + 'default' => '', |
|
794 | + ]); |
|
795 | + $table->addColumn('marker_datetime', 'datetime', [ |
|
796 | + 'notnull' => false, |
|
797 | + ]); |
|
798 | + $table->addColumn('object_type', 'string', [ |
|
799 | + 'notnull' => true, |
|
800 | + 'length' => 64, |
|
801 | + 'default' => '', |
|
802 | + ]); |
|
803 | + $table->addColumn('object_id', 'string', [ |
|
804 | + 'notnull' => true, |
|
805 | + 'length' => 64, |
|
806 | + 'default' => '', |
|
807 | + ]); |
|
808 | + $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
|
809 | + $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); |
|
810 | + } |
|
811 | + |
|
812 | + if (!$schema->hasTable('credentials')) { |
|
813 | + $table = $schema->createTable('credentials'); |
|
814 | + $table->addColumn('user', 'string', [ |
|
815 | + 'notnull' => true, |
|
816 | + 'length' => 64, |
|
817 | + ]); |
|
818 | + $table->addColumn('identifier', 'string', [ |
|
819 | + 'notnull' => true, |
|
820 | + 'length' => 64, |
|
821 | + ]); |
|
822 | + $table->addColumn('credentials', 'text', [ |
|
823 | + 'notnull' => false, |
|
824 | + ]); |
|
825 | + $table->setPrimaryKey(['user', 'identifier']); |
|
826 | + $table->addIndex(['user'], 'credentials_user'); |
|
827 | + } |
|
828 | + |
|
829 | + if (!$schema->hasTable('admin_sections')) { |
|
830 | + $table = $schema->createTable('admin_sections'); |
|
831 | + $table->addColumn('id', 'string', [ |
|
832 | + 'notnull' => true, |
|
833 | + 'length' => 64, |
|
834 | + ]); |
|
835 | + $table->addColumn('class', 'string', [ |
|
836 | + 'notnull' => true, |
|
837 | + 'length' => 255, |
|
838 | + 'default' => '', |
|
839 | + ]); |
|
840 | + $table->addColumn('priority', 'smallint', [ |
|
841 | + 'notnull' => true, |
|
842 | + 'length' => 1, |
|
843 | + 'default' => 0, |
|
844 | + ]); |
|
845 | + $table->setPrimaryKey(['id']); |
|
846 | + $table->addUniqueIndex(['class'], 'admin_sections_class'); |
|
847 | + } |
|
848 | + |
|
849 | + if (!$schema->hasTable('admin_settings')) { |
|
850 | + $table = $schema->createTable('admin_settings'); |
|
851 | + $table->addColumn('id', 'integer', [ |
|
852 | + 'autoincrement' => true, |
|
853 | + 'notnull' => true, |
|
854 | + 'length' => 4, |
|
855 | + ]); |
|
856 | + $table->addColumn('class', 'string', [ |
|
857 | + 'notnull' => true, |
|
858 | + 'length' => 255, |
|
859 | + 'default' => '', |
|
860 | + ]); |
|
861 | + $table->addColumn('section', 'string', [ |
|
862 | + 'notnull' => false, |
|
863 | + 'length' => 64, |
|
864 | + ]); |
|
865 | + $table->addColumn('priority', 'smallint', [ |
|
866 | + 'notnull' => true, |
|
867 | + 'length' => 1, |
|
868 | + 'default' => 0, |
|
869 | + ]); |
|
870 | + $table->setPrimaryKey(['id']); |
|
871 | + $table->addUniqueIndex(['class'], 'admin_settings_class'); |
|
872 | + $table->addIndex(['section'], 'admin_settings_section'); |
|
873 | + } |
|
874 | + |
|
875 | + if (!$schema->hasTable('personal_sections')) { |
|
876 | + $table = $schema->createTable('personal_sections'); |
|
877 | + $table->addColumn('id', 'string', [ |
|
878 | + 'notnull' => true, |
|
879 | + 'length' => 64, |
|
880 | + ]); |
|
881 | + $table->addColumn('class', 'string', [ |
|
882 | + 'notnull' => true, |
|
883 | + 'length' => 255, |
|
884 | + 'default' => '', |
|
885 | + ]); |
|
886 | + $table->addColumn('priority', 'smallint', [ |
|
887 | + 'notnull' => true, |
|
888 | + 'length' => 1, |
|
889 | + 'default' => 0, |
|
890 | + ]); |
|
891 | + $table->setPrimaryKey(['id']); |
|
892 | + $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
893 | + } |
|
894 | + |
|
895 | + if (!$schema->hasTable('personal_settings')) { |
|
896 | + $table = $schema->createTable('personal_settings'); |
|
897 | + $table->addColumn('id', 'integer', [ |
|
898 | + 'autoincrement' => true, |
|
899 | + 'notnull' => true, |
|
900 | + 'length' => 4, |
|
901 | + ]); |
|
902 | + $table->addColumn('class', 'string', [ |
|
903 | + 'notnull' => true, |
|
904 | + 'length' => 255, |
|
905 | + 'default' => '', |
|
906 | + ]); |
|
907 | + $table->addColumn('section', 'string', [ |
|
908 | + 'notnull' => false, |
|
909 | + 'length' => 64, |
|
910 | + ]); |
|
911 | + $table->addColumn('priority', 'smallint', [ |
|
912 | + 'notnull' => true, |
|
913 | + 'length' => 1, |
|
914 | + 'default' => 0, |
|
915 | + ]); |
|
916 | + $table->setPrimaryKey(['id']); |
|
917 | + $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
918 | + $table->addIndex(['section'], 'personal_settings_section'); |
|
919 | + } |
|
920 | + |
|
921 | + if (!$schema->hasTable('accounts')) { |
|
922 | + $table = $schema->createTable('accounts'); |
|
923 | + $table->addColumn('uid', 'string', [ |
|
924 | + 'notnull' => true, |
|
925 | + 'length' => 64, |
|
926 | + 'default' => '', |
|
927 | + ]); |
|
928 | + $table->addColumn('data', 'text', [ |
|
929 | + 'notnull' => true, |
|
930 | + 'default' => '', |
|
931 | + ]); |
|
932 | + $table->setPrimaryKey(['uid']); |
|
933 | + } |
|
934 | + return $schema; |
|
935 | + } |
|
936 | 936 | } |
@@ -35,72 +35,72 @@ |
||
35 | 35 | use OCP\Migration\SimpleMigrationStep; |
36 | 36 | |
37 | 37 | class Version16000Date20190212081545 extends SimpleMigrationStep { |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * |
|
43 | - * @return ISchemaWrapper |
|
44 | - */ |
|
45 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
46 | - /** @var ISchemaWrapper $schema */ |
|
47 | - $schema = $schemaClosure(); |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * |
|
43 | + * @return ISchemaWrapper |
|
44 | + */ |
|
45 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { |
|
46 | + /** @var ISchemaWrapper $schema */ |
|
47 | + $schema = $schemaClosure(); |
|
48 | 48 | |
49 | - $table = $schema->createTable('login_flow_v2'); |
|
50 | - $table->addColumn('id', Types::BIGINT, [ |
|
51 | - 'autoincrement' => true, |
|
52 | - 'notnull' => true, |
|
53 | - 'length' => 20, |
|
54 | - 'unsigned' => true, |
|
55 | - ]); |
|
56 | - $table->addColumn('timestamp', Types::BIGINT, [ |
|
57 | - 'notnull' => true, |
|
58 | - 'length' => 20, |
|
59 | - 'unsigned' => true, |
|
60 | - ]); |
|
61 | - $table->addColumn('started', Types::SMALLINT, [ |
|
62 | - 'notnull' => true, |
|
63 | - 'length' => 1, |
|
64 | - 'unsigned' => true, |
|
65 | - 'default' => 0, |
|
66 | - ]); |
|
67 | - $table->addColumn('poll_token', Types::STRING, [ |
|
68 | - 'notnull' => true, |
|
69 | - 'length' => 255, |
|
70 | - ]); |
|
71 | - $table->addColumn('login_token', Types::STRING, [ |
|
72 | - 'notnull' => true, |
|
73 | - 'length' => 255, |
|
74 | - ]); |
|
75 | - $table->addColumn('public_key', Types::TEXT, [ |
|
76 | - 'notnull' => true, |
|
77 | - 'length' => 32768, |
|
78 | - ]); |
|
79 | - $table->addColumn('private_key', Types::TEXT, [ |
|
80 | - 'notnull' => true, |
|
81 | - 'length' => 32768, |
|
82 | - ]); |
|
83 | - $table->addColumn('client_name', Types::STRING, [ |
|
84 | - 'notnull' => true, |
|
85 | - 'length' => 255, |
|
86 | - ]); |
|
87 | - $table->addColumn('login_name', Types::STRING, [ |
|
88 | - 'notnull' => false, |
|
89 | - 'length' => 255, |
|
90 | - ]); |
|
91 | - $table->addColumn('server', Types::STRING, [ |
|
92 | - 'notnull' => false, |
|
93 | - 'length' => 255, |
|
94 | - ]); |
|
95 | - $table->addColumn('app_password', Types::STRING, [ |
|
96 | - 'notnull' => false, |
|
97 | - 'length' => 1024, |
|
98 | - ]); |
|
99 | - $table->setPrimaryKey(['id']); |
|
100 | - $table->addUniqueIndex(['poll_token'], 'poll_token'); |
|
101 | - $table->addUniqueIndex(['login_token'], 'login_token'); |
|
102 | - $table->addIndex(['timestamp'], 'timestamp'); |
|
49 | + $table = $schema->createTable('login_flow_v2'); |
|
50 | + $table->addColumn('id', Types::BIGINT, [ |
|
51 | + 'autoincrement' => true, |
|
52 | + 'notnull' => true, |
|
53 | + 'length' => 20, |
|
54 | + 'unsigned' => true, |
|
55 | + ]); |
|
56 | + $table->addColumn('timestamp', Types::BIGINT, [ |
|
57 | + 'notnull' => true, |
|
58 | + 'length' => 20, |
|
59 | + 'unsigned' => true, |
|
60 | + ]); |
|
61 | + $table->addColumn('started', Types::SMALLINT, [ |
|
62 | + 'notnull' => true, |
|
63 | + 'length' => 1, |
|
64 | + 'unsigned' => true, |
|
65 | + 'default' => 0, |
|
66 | + ]); |
|
67 | + $table->addColumn('poll_token', Types::STRING, [ |
|
68 | + 'notnull' => true, |
|
69 | + 'length' => 255, |
|
70 | + ]); |
|
71 | + $table->addColumn('login_token', Types::STRING, [ |
|
72 | + 'notnull' => true, |
|
73 | + 'length' => 255, |
|
74 | + ]); |
|
75 | + $table->addColumn('public_key', Types::TEXT, [ |
|
76 | + 'notnull' => true, |
|
77 | + 'length' => 32768, |
|
78 | + ]); |
|
79 | + $table->addColumn('private_key', Types::TEXT, [ |
|
80 | + 'notnull' => true, |
|
81 | + 'length' => 32768, |
|
82 | + ]); |
|
83 | + $table->addColumn('client_name', Types::STRING, [ |
|
84 | + 'notnull' => true, |
|
85 | + 'length' => 255, |
|
86 | + ]); |
|
87 | + $table->addColumn('login_name', Types::STRING, [ |
|
88 | + 'notnull' => false, |
|
89 | + 'length' => 255, |
|
90 | + ]); |
|
91 | + $table->addColumn('server', Types::STRING, [ |
|
92 | + 'notnull' => false, |
|
93 | + 'length' => 255, |
|
94 | + ]); |
|
95 | + $table->addColumn('app_password', Types::STRING, [ |
|
96 | + 'notnull' => false, |
|
97 | + 'length' => 1024, |
|
98 | + ]); |
|
99 | + $table->setPrimaryKey(['id']); |
|
100 | + $table->addUniqueIndex(['poll_token'], 'poll_token'); |
|
101 | + $table->addUniqueIndex(['login_token'], 'login_token'); |
|
102 | + $table->addIndex(['timestamp'], 'timestamp'); |
|
103 | 103 | |
104 | - return $schema; |
|
105 | - } |
|
104 | + return $schema; |
|
105 | + } |
|
106 | 106 | } |
@@ -35,59 +35,59 @@ |
||
35 | 35 | |
36 | 36 | class Version18000Date20191014105105 extends SimpleMigrationStep { |
37 | 37 | |
38 | - /** @var IDBConnection */ |
|
39 | - protected $connection; |
|
38 | + /** @var IDBConnection */ |
|
39 | + protected $connection; |
|
40 | 40 | |
41 | - public function __construct(IDBConnection $connection) { |
|
42 | - $this->connection = $connection; |
|
43 | - } |
|
41 | + public function __construct(IDBConnection $connection) { |
|
42 | + $this->connection = $connection; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param IOutput $output |
|
47 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
48 | - * @param array $options |
|
49 | - * @return null|ISchemaWrapper |
|
50 | - */ |
|
51 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
52 | - /** @var ISchemaWrapper $schema */ |
|
53 | - $schema = $schemaClosure(); |
|
54 | - $table = $schema->createTable('direct_edit'); |
|
45 | + /** |
|
46 | + * @param IOutput $output |
|
47 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
48 | + * @param array $options |
|
49 | + * @return null|ISchemaWrapper |
|
50 | + */ |
|
51 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
52 | + /** @var ISchemaWrapper $schema */ |
|
53 | + $schema = $schemaClosure(); |
|
54 | + $table = $schema->createTable('direct_edit'); |
|
55 | 55 | |
56 | - $table->addColumn('id', Types::BIGINT, [ |
|
57 | - 'autoincrement' => true, |
|
58 | - 'notnull' => true, |
|
59 | - ]); |
|
60 | - $table->addColumn('editor_id', Types::STRING, [ |
|
61 | - 'notnull' => true, |
|
62 | - 'length' => 64, |
|
63 | - ]); |
|
64 | - $table->addColumn('token', Types::STRING, [ |
|
65 | - 'notnull' => true, |
|
66 | - 'length' => 64, |
|
67 | - ]); |
|
68 | - $table->addColumn('file_id', Types::BIGINT, [ |
|
69 | - 'notnull' => true, |
|
70 | - ]); |
|
71 | - $table->addColumn('user_id', Types::STRING, [ |
|
72 | - 'notnull' => false, |
|
73 | - 'length' => 64, |
|
74 | - ]); |
|
75 | - $table->addColumn('share_id', Types::BIGINT, [ |
|
76 | - 'notnull' => false |
|
77 | - ]); |
|
78 | - $table->addColumn('timestamp', Types::BIGINT, [ |
|
79 | - 'notnull' => true, |
|
80 | - 'length' => 20, |
|
81 | - 'unsigned' => true, |
|
82 | - ]); |
|
83 | - $table->addColumn('accessed', Types::BOOLEAN, [ |
|
84 | - 'notnull' => true, |
|
85 | - 'default' => false |
|
86 | - ]); |
|
56 | + $table->addColumn('id', Types::BIGINT, [ |
|
57 | + 'autoincrement' => true, |
|
58 | + 'notnull' => true, |
|
59 | + ]); |
|
60 | + $table->addColumn('editor_id', Types::STRING, [ |
|
61 | + 'notnull' => true, |
|
62 | + 'length' => 64, |
|
63 | + ]); |
|
64 | + $table->addColumn('token', Types::STRING, [ |
|
65 | + 'notnull' => true, |
|
66 | + 'length' => 64, |
|
67 | + ]); |
|
68 | + $table->addColumn('file_id', Types::BIGINT, [ |
|
69 | + 'notnull' => true, |
|
70 | + ]); |
|
71 | + $table->addColumn('user_id', Types::STRING, [ |
|
72 | + 'notnull' => false, |
|
73 | + 'length' => 64, |
|
74 | + ]); |
|
75 | + $table->addColumn('share_id', Types::BIGINT, [ |
|
76 | + 'notnull' => false |
|
77 | + ]); |
|
78 | + $table->addColumn('timestamp', Types::BIGINT, [ |
|
79 | + 'notnull' => true, |
|
80 | + 'length' => 20, |
|
81 | + 'unsigned' => true, |
|
82 | + ]); |
|
83 | + $table->addColumn('accessed', Types::BOOLEAN, [ |
|
84 | + 'notnull' => true, |
|
85 | + 'default' => false |
|
86 | + ]); |
|
87 | 87 | |
88 | - $table->setPrimaryKey(['id']); |
|
89 | - $table->addIndex(['token']); |
|
88 | + $table->setPrimaryKey(['id']); |
|
89 | + $table->addIndex(['token']); |
|
90 | 90 | |
91 | - return $schema; |
|
92 | - } |
|
91 | + return $schema; |
|
92 | + } |
|
93 | 93 | } |
@@ -36,80 +36,80 @@ |
||
36 | 36 | class Version16000Date20190207141427 extends SimpleMigrationStep { |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param IOutput $output |
|
41 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | - * @param array $options |
|
43 | - * @return null|ISchemaWrapper |
|
44 | - */ |
|
45 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
46 | - /** @var ISchemaWrapper $schema */ |
|
47 | - $schema = $schemaClosure(); |
|
48 | - |
|
49 | - if (!$schema->hasTable('collres_collections')) { |
|
50 | - $table = $schema->createTable('collres_collections'); |
|
51 | - |
|
52 | - $table->addColumn('id', Types::BIGINT, [ |
|
53 | - 'autoincrement' => true, |
|
54 | - 'notnull' => true, |
|
55 | - ]); |
|
56 | - $table->addColumn('name', Types::STRING, [ |
|
57 | - 'notnull' => true, |
|
58 | - 'length' => 64, |
|
59 | - ]); |
|
60 | - |
|
61 | - $table->setPrimaryKey(['id']); |
|
62 | - } |
|
63 | - |
|
64 | - if (!$schema->hasTable('collres_resources')) { |
|
65 | - $table = $schema->createTable('collres_resources'); |
|
66 | - |
|
67 | - $table->addColumn('collection_id', Types::BIGINT, [ |
|
68 | - 'notnull' => true, |
|
69 | - ]); |
|
70 | - $table->addColumn('resource_type', Types::STRING, [ |
|
71 | - 'notnull' => true, |
|
72 | - 'length' => 64, |
|
73 | - ]); |
|
74 | - $table->addColumn('resource_id', Types::STRING, [ |
|
75 | - 'notnull' => true, |
|
76 | - 'length' => 64, |
|
77 | - ]); |
|
78 | - |
|
79 | - $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); |
|
80 | - } |
|
81 | - |
|
82 | - if (!$schema->hasTable('collres_accesscache')) { |
|
83 | - $table = $schema->createTable('collres_accesscache'); |
|
84 | - |
|
85 | - $table->addColumn('user_id', Types::STRING, [ |
|
86 | - 'notnull' => true, |
|
87 | - 'length' => 64, |
|
88 | - ]); |
|
89 | - $table->addColumn('collection_id', Types::BIGINT, [ |
|
90 | - 'notnull' => false, |
|
91 | - 'default' => 0, |
|
92 | - ]); |
|
93 | - $table->addColumn('resource_type', Types::STRING, [ |
|
94 | - 'notnull' => false, |
|
95 | - 'length' => 64, |
|
96 | - 'default' => '', |
|
97 | - ]); |
|
98 | - $table->addColumn('resource_id', Types::STRING, [ |
|
99 | - 'notnull' => false, |
|
100 | - 'length' => 64, |
|
101 | - 'default' => '', |
|
102 | - ]); |
|
103 | - $table->addColumn('access', Types::SMALLINT, [ |
|
104 | - 'notnull' => true, |
|
105 | - 'default' => 0, |
|
106 | - ]); |
|
107 | - |
|
108 | - $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); |
|
109 | - $table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res'); |
|
110 | - $table->addIndex(['user_id', 'collection_id'], 'collres_user_coll'); |
|
111 | - } |
|
112 | - |
|
113 | - return $schema; |
|
114 | - } |
|
39 | + /** |
|
40 | + * @param IOutput $output |
|
41 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | + * @param array $options |
|
43 | + * @return null|ISchemaWrapper |
|
44 | + */ |
|
45 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
46 | + /** @var ISchemaWrapper $schema */ |
|
47 | + $schema = $schemaClosure(); |
|
48 | + |
|
49 | + if (!$schema->hasTable('collres_collections')) { |
|
50 | + $table = $schema->createTable('collres_collections'); |
|
51 | + |
|
52 | + $table->addColumn('id', Types::BIGINT, [ |
|
53 | + 'autoincrement' => true, |
|
54 | + 'notnull' => true, |
|
55 | + ]); |
|
56 | + $table->addColumn('name', Types::STRING, [ |
|
57 | + 'notnull' => true, |
|
58 | + 'length' => 64, |
|
59 | + ]); |
|
60 | + |
|
61 | + $table->setPrimaryKey(['id']); |
|
62 | + } |
|
63 | + |
|
64 | + if (!$schema->hasTable('collres_resources')) { |
|
65 | + $table = $schema->createTable('collres_resources'); |
|
66 | + |
|
67 | + $table->addColumn('collection_id', Types::BIGINT, [ |
|
68 | + 'notnull' => true, |
|
69 | + ]); |
|
70 | + $table->addColumn('resource_type', Types::STRING, [ |
|
71 | + 'notnull' => true, |
|
72 | + 'length' => 64, |
|
73 | + ]); |
|
74 | + $table->addColumn('resource_id', Types::STRING, [ |
|
75 | + 'notnull' => true, |
|
76 | + 'length' => 64, |
|
77 | + ]); |
|
78 | + |
|
79 | + $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); |
|
80 | + } |
|
81 | + |
|
82 | + if (!$schema->hasTable('collres_accesscache')) { |
|
83 | + $table = $schema->createTable('collres_accesscache'); |
|
84 | + |
|
85 | + $table->addColumn('user_id', Types::STRING, [ |
|
86 | + 'notnull' => true, |
|
87 | + 'length' => 64, |
|
88 | + ]); |
|
89 | + $table->addColumn('collection_id', Types::BIGINT, [ |
|
90 | + 'notnull' => false, |
|
91 | + 'default' => 0, |
|
92 | + ]); |
|
93 | + $table->addColumn('resource_type', Types::STRING, [ |
|
94 | + 'notnull' => false, |
|
95 | + 'length' => 64, |
|
96 | + 'default' => '', |
|
97 | + ]); |
|
98 | + $table->addColumn('resource_id', Types::STRING, [ |
|
99 | + 'notnull' => false, |
|
100 | + 'length' => 64, |
|
101 | + 'default' => '', |
|
102 | + ]); |
|
103 | + $table->addColumn('access', Types::SMALLINT, [ |
|
104 | + 'notnull' => true, |
|
105 | + 'default' => 0, |
|
106 | + ]); |
|
107 | + |
|
108 | + $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); |
|
109 | + $table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res'); |
|
110 | + $table->addIndex(['user_id', 'collection_id'], 'collres_user_coll'); |
|
111 | + } |
|
112 | + |
|
113 | + return $schema; |
|
114 | + } |
|
115 | 115 | } |
@@ -36,45 +36,45 @@ |
||
36 | 36 | |
37 | 37 | class Version18000Date20190920085628 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(); |
|
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 | 55 | |
56 | - if ($schema->hasTable('groups')) { |
|
57 | - $table = $schema->getTable('groups'); |
|
56 | + if ($schema->hasTable('groups')) { |
|
57 | + $table = $schema->getTable('groups'); |
|
58 | 58 | |
59 | - $table->addColumn('displayname', Types::STRING, [ |
|
60 | - 'notnull' => true, |
|
61 | - 'length' => 255, |
|
62 | - 'default' => '', |
|
63 | - ]); |
|
64 | - } |
|
59 | + $table->addColumn('displayname', Types::STRING, [ |
|
60 | + 'notnull' => true, |
|
61 | + 'length' => 255, |
|
62 | + 'default' => '', |
|
63 | + ]); |
|
64 | + } |
|
65 | 65 | |
66 | - return $schema; |
|
67 | - } |
|
66 | + return $schema; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @param IOutput $output |
|
71 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
72 | - * @param array $options |
|
73 | - */ |
|
74 | - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
75 | - $query = $this->connection->getQueryBuilder(); |
|
76 | - $query->update('groups') |
|
77 | - ->set('displayname', 'gid'); |
|
78 | - $query->execute(); |
|
79 | - } |
|
69 | + /** |
|
70 | + * @param IOutput $output |
|
71 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
72 | + * @param array $options |
|
73 | + */ |
|
74 | + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { |
|
75 | + $query = $this->connection->getQueryBuilder(); |
|
76 | + $query->update('groups') |
|
77 | + ->set('displayname', 'gid'); |
|
78 | + $query->execute(); |
|
79 | + } |
|
80 | 80 | } |
@@ -35,25 +35,25 @@ |
||
35 | 35 | |
36 | 36 | class Version16000Date20190428150708 extends SimpleMigrationStep { |
37 | 37 | |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * @return null|ISchemaWrapper |
|
43 | - * @throws \Doctrine\DBAL\Schema\SchemaException |
|
44 | - */ |
|
45 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
46 | - /** @var ISchemaWrapper $schema */ |
|
47 | - $schema = $schemaClosure(); |
|
48 | - |
|
49 | - if ($schema->hasTable('collres_accesscache')) { |
|
50 | - $table = $schema->getTable('collres_accesscache'); |
|
51 | - $table->addColumn('access', Types::BOOLEAN, [ |
|
52 | - 'notnull' => true, |
|
53 | - 'default' => false |
|
54 | - ]); |
|
55 | - } |
|
56 | - |
|
57 | - return $schema; |
|
58 | - } |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * @return null|ISchemaWrapper |
|
43 | + * @throws \Doctrine\DBAL\Schema\SchemaException |
|
44 | + */ |
|
45 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
46 | + /** @var ISchemaWrapper $schema */ |
|
47 | + $schema = $schemaClosure(); |
|
48 | + |
|
49 | + if ($schema->hasTable('collres_accesscache')) { |
|
50 | + $table = $schema->getTable('collres_accesscache'); |
|
51 | + $table->addColumn('access', Types::BOOLEAN, [ |
|
52 | + 'notnull' => true, |
|
53 | + 'default' => false |
|
54 | + ]); |
|
55 | + } |
|
56 | + |
|
57 | + return $schema; |
|
58 | + } |
|
59 | 59 | } |