2023-02-08 18:45:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
2023-08-21 05:13:09 +00:00
|
|
|
* @copyright Copyright (c) 2023 Varun Patil <radialapps@gmail.com>
|
|
|
|
* @author Varun Patil <radialapps@gmail.com>
|
2023-02-08 18:45:25 +00:00
|
|
|
* @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 OCA\Memories\Migration;
|
|
|
|
|
|
|
|
use OCP\DB\ISchemaWrapper;
|
|
|
|
use OCP\DB\Types;
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-generated migration step: Please modify to your needs!
|
|
|
|
*/
|
|
|
|
class Version401100Date20230208181533 extends SimpleMigrationStep
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
|
|
|
*/
|
|
|
|
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
|
|
|
*/
|
|
|
|
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper
|
|
|
|
{
|
|
|
|
/** @var ISchemaWrapper $schema */
|
|
|
|
$schema = $schemaClosure();
|
|
|
|
|
2023-02-09 08:35:35 +00:00
|
|
|
// Add lat lon to memories
|
2023-02-08 18:45:25 +00:00
|
|
|
$table = $schema->getTable('memories');
|
|
|
|
if (!$table->hasColumn('lat')) {
|
|
|
|
$table->addColumn('lat', Types::DECIMAL, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
'precision' => 8,
|
|
|
|
'scale' => 6,
|
|
|
|
]);
|
|
|
|
$table->addColumn('lon', Types::DECIMAL, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
'precision' => 9,
|
|
|
|
'scale' => 6,
|
|
|
|
]);
|
|
|
|
$table->addIndex(['lat', 'lon'], 'memories_lat_lon_index');
|
2023-02-09 08:35:35 +00:00
|
|
|
|
|
|
|
$table->addColumn('mapcluster', Types::INTEGER, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
|
|
|
$table->addIndex(['mapcluster'], 'memories_mapcluster_index');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add clusters table
|
|
|
|
if (!$schema->hasTable('memories_mapclusters')) {
|
|
|
|
$table = $schema->createTable('memories_mapclusters');
|
|
|
|
$table->addColumn('id', Types::INTEGER, [
|
|
|
|
'autoincrement' => true,
|
|
|
|
'notnull' => true,
|
|
|
|
]);
|
|
|
|
$table->addColumn('point_count', Types::INTEGER, [
|
|
|
|
'notnull' => true,
|
|
|
|
]);
|
|
|
|
$table->addColumn('lat_sum', Types::FLOAT, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
|
|
|
$table->addColumn('lon_sum', Types::FLOAT, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
|
|
|
$table->addColumn('lat', Types::FLOAT, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
|
|
|
$table->addColumn('lon', Types::FLOAT, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
2023-02-09 16:25:37 +00:00
|
|
|
$table->addColumn('last_update', Types::INTEGER, [
|
|
|
|
'notnull' => false,
|
|
|
|
'default' => null,
|
|
|
|
]);
|
2023-02-09 08:35:35 +00:00
|
|
|
|
|
|
|
$table->setPrimaryKey(['id']);
|
|
|
|
$table->addIndex(['lat', 'lon'], 'memories_clst_ll_idx');
|
2023-02-08 18:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $schema;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
|
|
|
*/
|
|
|
|
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|