migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license AGPL-3.0-or-later
*
* 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\Notifications\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version2004Date20190107135757 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('notifications')) {
$table = $schema->createTable('notifications');
$table->addColumn('notification_id', Types::INTEGER, [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
]);
$table->addColumn('app', Types::STRING, [
'notnull' => true,
'length' => 32,
]);
$table->addColumn('user', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('timestamp', Types::INTEGER, [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
$table->addColumn('object_type', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('object_id', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('subject', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('subject_parameters', Types::TEXT, [
'notnull' => false,
]);
$table->addColumn('message', Types::STRING, [
'notnull' => false,
'length' => 64,
]);
$table->addColumn('message_parameters', Types::TEXT, [
'notnull' => false,
]);
$table->addColumn('link', Types::STRING, [
'notnull' => false,
'length' => 4000,
]);
$table->addColumn('icon', Types::STRING, [
'notnull' => false,
'length' => 4000,
]);
$table->addColumn('actions', Types::TEXT, [
'notnull' => false,
]);
$table->setPrimaryKey(['notification_id']);
$table->addIndex(['app'], 'oc_notifications_app');
$table->addIndex(['user'], 'oc_notifications_user');
$table->addIndex(['timestamp'], 'oc_notifications_timestamp');
$table->addIndex(['object_type', 'object_id'], 'oc_notifications_object');
}
// $schema->createTable('notifications_pushtokens') was
// replaced with notifications_pushhash in Version2010Date20210218082811
// and deleted in Version2010Date20210218082855
return $schema;
}
}
@@ -0,0 +1,149 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license AGPL-3.0-or-later
*
* 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\Notifications\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Recreate notifications_pushtoken(s) with a primary key for cluster support
*/
class Version2010Date20210218082811 extends SimpleMigrationStep {
/** @var IDBConnection */
protected $connection;
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('notifications_pushhash')) {
$table = $schema->createTable('notifications_pushhash');
$table->addColumn('id', Types::INTEGER, [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
]);
$table->addColumn('uid', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('token', Types::INTEGER, [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
$table->addColumn('deviceidentifier', Types::STRING, [
'notnull' => true,
'length' => 128,
]);
$table->addColumn('devicepublickey', Types::STRING, [
'notnull' => true,
'length' => 512,
]);
$table->addColumn('devicepublickeyhash', Types::STRING, [
'notnull' => true,
'length' => 128,
]);
$table->addColumn('pushtokenhash', Types::STRING, [
'notnull' => true,
'length' => 128,
]);
$table->addColumn('proxyserver', Types::STRING, [
'notnull' => true,
'length' => 256,
]);
$table->addColumn('apptype', Types::STRING, [
'notnull' => true,
'length' => 32,
'default' => 'unknown',
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['uid', 'token'], 'oc_npushhash_uid');
}
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
if (!$this->connection->tableExists('notifications_pushtokens')) {
return;
}
$insert = $this->connection->getQueryBuilder();
$insert->insert('notifications_pushhash')
->values([
'uid' => $insert->createParameter('uid'),
'token' => $insert->createParameter('token'),
'deviceidentifier' => $insert->createParameter('deviceidentifier'),
'devicepublickey' => $insert->createParameter('devicepublickey'),
'devicepublickeyhash' => $insert->createParameter('devicepublickeyhash'),
'pushtokenhash' => $insert->createParameter('pushtokenhash'),
'proxyserver' => $insert->createParameter('proxyserver'),
'apptype' => $insert->createParameter('apptype'),
]);
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('notifications_pushtokens');
$result = $query->execute();
while ($row = $result->fetch()) {
$insert
->setParameter('uid', $row['uid'])
->setParameter('token', (int) $row['token'], IQueryBuilder::PARAM_INT)
->setParameter('deviceidentifier', $row['deviceidentifier'])
->setParameter('devicepublickey', $row['devicepublickey'])
->setParameter('devicepublickeyhash', $row['devicepublickeyhash'])
->setParameter('pushtokenhash', $row['pushtokenhash'])
->setParameter('proxyserver', $row['proxyserver'])
->setParameter('apptype', $row['apptype'])
;
$insert->execute();
}
$result->closeCursor();
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license AGPL-3.0-or-later
*
* 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\Notifications\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Delete the old notifications_pushtokens after we added notifications_pushhash with a primary key
*/
class Version2010Date20210218082855 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('notifications_pushtokens')) {
$schema->dropTable('notifications_pushtokens');
return $schema;
}
return null;
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license AGPL-3.0-or-later
*
* 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\Notifications\Migration;
use Closure;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version2011Date20210930134607 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('notifications_settings')) {
$table = $schema->createTable('notifications_settings');
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
]);
$table->addColumn('user_id', Types::STRING, [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('batch_time', Types::INTEGER, [
'default' => 0,
'length' => 4,
]);
$table->addColumn('last_send_id', Types::BIGINT, [
'default' => 0,
]);
$table->addColumn('next_send_time', Types::INTEGER, [
'default' => 0,
'length' => 11,
]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['user_id'], 'notset_user');
$table->addIndex(['next_send_time'], 'notset_nextsend');
return $schema;
}
return null;
}
}
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license AGPL-3.0-or-later
*
* 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\Notifications\Migration;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version2011Date20220826074907 extends SimpleMigrationStep {
/** @var IDBConnection */
protected $connection;
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
$query = $this->connection->getQueryBuilder();
// The maximum valid value is NOW + 7 days, but since updating is fixed
// and you only run into the bug at the year 2038, we can also count up 8 days.
$time = time() + 3600 * 24 * 8;
$query->update('notifications_settings')
->set('next_send_time', $query->createNamedParameter(1, IQueryBuilder::PARAM_INT))
->where($query->expr()->gt('next_send_time', $query->createNamedParameter($time, IQueryBuilder::PARAM_INT)));
$count = $query->executeStatement();
if ($count > 0) {
$output->info('Fixed next send of ' . $count . ' disabled users');
}
}
}