chenge repair steps
Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
Родитель
d17f43ce3b
Коммит
ca88921cc0
|
@ -24,12 +24,18 @@
|
|||
|
||||
namespace OCA\Polls\Migration;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class FixVotes implements IRepairStep {
|
||||
public function __construct(private TableManager $tableManager) {
|
||||
public function __construct(
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -44,8 +50,9 @@ class FixVotes implements IRepairStep {
|
|||
*/
|
||||
public function run(IOutput $output): void {
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->tableManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->tableManager->setSchema($this->schema);
|
||||
$this->tableManager->fixVotes();
|
||||
$this->tableManager->migrate();
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,17 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\IndexManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class CreateIndices implements IRepairStep {
|
||||
public function __construct(
|
||||
private IndexManager $indexManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -41,11 +45,13 @@ class CreateIndices implements IRepairStep {
|
|||
public function run(IOutput $output): void {
|
||||
$messages = [];
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->indexManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->indexManager->setSchema($this->schema);
|
||||
|
||||
$messages = array_merge($messages, $this->indexManager->createForeignKeyConstraints());
|
||||
$messages = array_merge($messages, $this->indexManager->createIndices());
|
||||
$this->indexManager->migrate();
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
}
|
||||
|
|
|
@ -24,13 +24,17 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class CreateTables implements IRepairStep {
|
||||
public function __construct(
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -45,9 +49,12 @@ class CreateTables implements IRepairStep {
|
|||
$output->info($message);
|
||||
}
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->tableManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->tableManager->setSchema($this->schema);
|
||||
|
||||
$messages = $this->tableManager->createTables();
|
||||
$this->tableManager->migrate();
|
||||
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\Poll;
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCA\Polls\Db\WatchMapper;
|
||||
|
@ -39,7 +40,8 @@ class DeleteInvalidRecords implements IRepairStep {
|
|||
public function __construct(
|
||||
private IDBConnection $connection,
|
||||
private WatchMapper $watchMapper,
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -49,12 +51,14 @@ class DeleteInvalidRecords implements IRepairStep {
|
|||
|
||||
public function run(IOutput $output):void {
|
||||
if ($this->connection->tableExists(Poll::TABLE)) {
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->tableManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->tableManager->setSchema($this->schema);
|
||||
|
||||
$this->tableManager->removeOrphaned();
|
||||
$this->tableManager->deleteAllDuplicates();
|
||||
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
|
||||
$this->watchMapper->deleteOldEntries(time());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,17 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class DropOrphanedColumns implements IRepairStep {
|
||||
public function __construct(
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -40,8 +44,10 @@ class DropOrphanedColumns implements IRepairStep {
|
|||
|
||||
public function run(IOutput $output): void {
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->tableManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->tableManager->setSchema($this->schema);
|
||||
$messages = $this->tableManager->removeObsoleteColumns();
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
|
|
|
@ -24,13 +24,17 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class DropOrphanedTables implements IRepairStep {
|
||||
public function __construct(
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -40,8 +44,12 @@ class DropOrphanedTables implements IRepairStep {
|
|||
|
||||
public function run(IOutput $output): void {
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->tableManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->tableManager->setSchema($this->schema);
|
||||
|
||||
$messages = $this->tableManager->removeObsoleteTables();
|
||||
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
|
|
|
@ -24,13 +24,17 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\IndexManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class Install implements IRepairStep {
|
||||
public function __construct(
|
||||
private IndexManager $indexManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -40,12 +44,14 @@ class Install implements IRepairStep {
|
|||
|
||||
public function run(IOutput $output): void {
|
||||
$messages = [];
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->indexManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->indexManager->setSchema($this->schema);
|
||||
|
||||
$messages = array_merge($messages, $this->indexManager->createForeignKeyConstraints());
|
||||
$messages = array_merge($messages, $this->indexManager->createIndices());
|
||||
$this->indexManager->migrate();
|
||||
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\IndexManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
|
@ -34,7 +36,9 @@ use OCP\Migration\IRepairStep;
|
|||
*/
|
||||
class RemoveIndices implements IRepairStep {
|
||||
public function __construct(
|
||||
private IndexManager $indexManager
|
||||
private IndexManager $indexManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -49,24 +53,19 @@ class RemoveIndices implements IRepairStep {
|
|||
* @inheritdoc
|
||||
*/
|
||||
public function run(IOutput $output): void {
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->indexManager->refreshSchema();
|
||||
$this->schema = $this->connection->createSchema();
|
||||
$this->indexManager->setSchema($this->schema);
|
||||
|
||||
$messages = $this->indexManager->removeAllForeignKeyConstraints();
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
}
|
||||
|
||||
// $messages = $this->indexManager->removeAllGenericIndices();
|
||||
// foreach ($messages as $message) {
|
||||
// $output->info($message);
|
||||
// }
|
||||
|
||||
$messages = $this->indexManager->removeAllUniqueIndices();
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
}
|
||||
|
||||
$this->indexManager->migrate();
|
||||
$this->indexManager->refreshSchema();
|
||||
$this->connection->migrateToSchema($this->schema);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
|
||||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
|
@ -34,7 +36,9 @@ use OCP\Migration\IRepairStep;
|
|||
*/
|
||||
class RemoveObsoleteMigrations implements IRepairStep {
|
||||
public function __construct(
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
private Schema $schema,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -49,13 +53,12 @@ class RemoveObsoleteMigrations implements IRepairStep {
|
|||
* @inheritdoc
|
||||
*/
|
||||
public function run(IOutput $output): void {
|
||||
// secure, that the schema is updated to the current status
|
||||
$this->tableManager->refreshSchema();
|
||||
$this->tableManager->setConnection($this->connection);
|
||||
|
||||
$messages = $this->tableManager->removeObsoleteMigrations();
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
}
|
||||
|
||||
$this->tableManager->migrate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,24 +25,28 @@
|
|||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class UpdateHashes implements IRepairStep {
|
||||
public function __construct(
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'Polls - Create hashes vor votes and options';
|
||||
return 'Polls - Create hashes for votes and options';
|
||||
}
|
||||
|
||||
public function run(IOutput $output): void {
|
||||
// Add hashes to votes and options
|
||||
$this->tableManager->setConnection($this->connection);
|
||||
|
||||
$messages = $this->tableManager->migrateOptionsToHash();
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,14 @@
|
|||
namespace OCA\Polls\Migration\RepairSteps;
|
||||
|
||||
use OCA\Polls\Db\TableManager;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
class UpdateInteraction implements IRepairStep {
|
||||
public function __construct(
|
||||
private TableManager $tableManager
|
||||
private TableManager $tableManager,
|
||||
private IDBConnection $connection,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -39,6 +41,8 @@ class UpdateInteraction implements IRepairStep {
|
|||
}
|
||||
|
||||
public function run(IOutput $output): void {
|
||||
$this->tableManager->setConnection($this->connection);
|
||||
|
||||
$messages = $this->tableManager->resetLastInteraction();
|
||||
foreach ($messages as $message) {
|
||||
$output->info($message);
|
||||
|
|
Загрузка…
Ссылка в новой задаче