Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add migration to create DB table for client diagnostics
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Oct 3, 2023
commit 86fd999e64d7842dd7ca9e4ddfbaca2fd505b554
4 changes: 3 additions & 1 deletion apps/settings/lib/Db/ClientDiagnosticMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
* @template-extends QBMapper<ClientDiagnostic>
*/
class ClientDiagnosticMapper extends QBMapper {
public const TABLE_NAME = 'client_diagnostics';

public function __construct(IDBConnection $db) {
parent::__construct($db, 'client_diagnostics', ClientDiagnostic::class);
parent::__construct($db, self::TABLE_NAME, ClientDiagnostic::class);
}
}
72 changes: 72 additions & 0 deletions core/Migrations/Version28000Date20231002171502.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2023 Côme Chilliet <[email protected]>
*
* @author Côme Chilliet <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OC\Core\Migrations;

use Closure;
use OCA\Settings\Db\ClientDiagnosticMapper;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Introduce client_diagnostics table
*/
class Version28000Date20231002171502 extends SimpleMigrationStep {
/**
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if (!$schema->hasTable(ClientDiagnosticMapper::TABLE_NAME)) {
$table = $schema->createTable(ClientDiagnosticMapper::TABLE_NAME);

$table->addColumn('id', Types::BIGINT, [
'notnull' => true,
'length' => 64,
'autoincrement' => true,
]);
$table->addColumn('authtokenid', Types::BIGINT, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('diagnostic', Types::TEXT, [
'notnull' => true,
]);

$table->setPrimaryKey(['id'], 'client_diagnostics_id_primary');
$table->addUniqueIndex(['authtokenid'], 'client_diagnostics_authtokenid_index');

$changed = true;
return $schema;
}

return null;
}
}
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@
'OC\\Core\\Migrations\\Version28000Date20230616104802' => $baseDir . '/core/Migrations/Version28000Date20230616104802.php',
'OC\\Core\\Migrations\\Version28000Date20230728104802' => $baseDir . '/core/Migrations/Version28000Date20230728104802.php',
'OC\\Core\\Migrations\\Version28000Date20230803221055' => $baseDir . '/core/Migrations/Version28000Date20230803221055.php',
'OC\\Core\\Migrations\\Version28000Date20231002171502' => $baseDir . '/core/Migrations/Version28000Date20231002171502.php',
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Migrations\\Version28000Date20230616104802' => __DIR__ . '/../../..' . '/core/Migrations/Version28000Date20230616104802.php',
'OC\\Core\\Migrations\\Version28000Date20230728104802' => __DIR__ . '/../../..' . '/core/Migrations/Version28000Date20230728104802.php',
'OC\\Core\\Migrations\\Version28000Date20230803221055' => __DIR__ . '/../../..' . '/core/Migrations/Version28000Date20230803221055.php',
'OC\\Core\\Migrations\\Version28000Date20231002171502' => __DIR__ . '/../../..' . '/core/Migrations/Version28000Date20231002171502.php',
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',
'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php',
Expand Down