Skip to content

Commit daea024

Browse files
authored
Merge pull request #4228 from nextcloud/fix/migration-table-name
use correct table name
2 parents 9567461 + 32fc2a4 commit daea024

7 files changed

Lines changed: 21 additions & 67 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# Changelog
66
All notable changes to this project will be documented in this file.
77

8-
## [8.3.1] - 2025-08-22
9-
- Fix migration from 7.x to 8.x
8+
## [8.3.3] - 2025-08-24
9+
- Fix migration
1010

1111
### Fixed (v8.3.0)
1212
- Made description sticky again on horizontal scrolling
@@ -27,6 +27,9 @@ All notable changes to this project will be documented in this file.
2727
- Make comments available to owner and delegated poll administration if commenting is disabled
2828
- Add hint, if commenting is disabled
2929

30+
## [8.3.2] - 2025-08-22
31+
- Fix migration from 7.x to 8.x
32+
3033
## [8.3.0] - 2025-08-21
3134
If you experience update problems, please refer to [this article](https://github.com/nextcloud/polls/wiki/Installation-help#update-issues)
3235

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<name>Polls</name>
55
<summary>A polls app, similar to Doodle/DuD-Poll with the possibility to restrict access.</summary>
66
<description>A polls app, similar to Doodle/DuD-Poll with the possibility to restrict access (members, certain groups/users, hidden and public).</description>
7-
<version>8.3.2</version>
7+
<version>8.3.3-alpha.2</version>
88
<licence>agpl</licence>
99
<author>Vinzenz Rosenkranz</author>
1010
<author>René Gieling</author>

lib/Command/Db/Rebuild.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ private function fixNullish(): void {
9999
$messages = $this->tableManager->fixNullishPollGroupRelations();
100100
$this->printInfo($messages, ' ');
101101
}
102+
102103
/**
103104
* Create index for $table
104105
*/

lib/Db/V2/TableManager.php

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929

3030
class TableManager extends DbManager {
3131

32-
// private string $dbPrefix;
33-
// private Schema|ISchemaWrapper $schema;
34-
3532
/** @psalm-suppress PossiblyUnusedMethod */
3633
public function __construct(
3734
protected IConfig $config,
@@ -41,27 +38,8 @@ public function __construct(
4138
private VoteMapper $voteMapper,
4239
) {
4340
parent::__construct($config, $connection);
44-
// $this->dbPrefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
4541
}
4642

47-
// public function setSchema(Schema|ISchemaWrapper &$schema): void {
48-
// $this->schema = $schema;
49-
// }
50-
51-
// public function createSchema(): Schema {
52-
// $this->schema = $this->connection->createSchema();
53-
// return $this->schema;
54-
// }
55-
// public function migrateToSchema() : void {
56-
// // Schema must be of class Schema
57-
// $this->needsSchema(iSchemWrapperClass: false);
58-
// $this->connection->migrateToSchema($this->schema);
59-
// }
60-
61-
// public function setConnection(IDBConnection &$connection): void {
62-
// $this->connection = $connection;
63-
// }
64-
6543
/**
6644
* @return string[]
6745
*
@@ -464,23 +442,22 @@ public function fixNullishShares(): array {
464442
$query = $this->connection->getQueryBuilder();
465443
$schema = $this->connection->createSchema();
466444

467-
if (!$schema->hasTable(Share::TABLE)) {
468-
$messages[] = 'Table ' . Share::TABLE . ' does not exist';
445+
if (!$schema->hasTable($this->dbPrefix . Share::TABLE)) {
446+
$messages[] = 'Table ' . $this->dbPrefix . Share::TABLE . ' does not exist';
469447
return $messages;
470448
}
471449

472-
$table = $schema->getTable(Share::TABLE);
450+
$table = $schema->getTable($this->dbPrefix . Share::TABLE);
473451

474452
if ($table->hasColumn('group_id')) {
475453
// replace all nullish group_ids with 0 in share table
476454
$query->update(Share::TABLE)
477455
->set('group_id', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
478456
->where($query->expr()->isNull('group_id'));
479-
480457
$count = $query->executeStatement();
481458

482459
if ($count > 0) {
483-
$messages[] = 'Updated ' . $count . ' shares and set group_id to 0 for nullish values';
460+
$messages[] = 'Updated ' . $count . ' shares with nullish group_id and set group_id to 0';
484461
}
485462
}
486463

@@ -506,6 +483,12 @@ public function fixNullishShares(): array {
506483
public function fixNullishPollGroupRelations(): array {
507484
$messages = [];
508485
$query = $this->connection->getQueryBuilder();
486+
$schema = $this->connection->createSchema();
487+
488+
if (!$schema->hasTable($this->dbPrefix . PollGroup::RELATION_TABLE)) {
489+
$messages[] = 'Table ' . $this->dbPrefix . PollGroup::RELATION_TABLE . ' does not exist';
490+
return $messages;
491+
}
509492

510493
// replace all nullish group_ids with 0 in share table
511494
$query->update(PollGroup::RELATION_TABLE)
@@ -611,37 +594,4 @@ public function migrateOptionsToHash(): array {
611594
}
612595
return $messages;
613596
}
614-
615-
// protected function getTableName(string $tableName): ?string {
616-
// if ($this->schema instanceof Schema) {
617-
// // If the schema is an instance of Schema, we need to prefix the table name
618-
// return $this->config->getSystemValue('dbtableprefix', 'oc_') . $tableName;
619-
// }
620-
// return $tableName;
621-
// }
622-
623-
// protected function needsSchema(bool $schemaClass = true, bool $iSchemWrapperClass = true): void {
624-
// if (($this->schema instanceof Schema) && $schemaClass) {
625-
// return;
626-
// }
627-
628-
// if (($this->schema instanceof ISchemaWrapper) && $iSchemWrapperClass) {
629-
// return;
630-
// }
631-
632-
// if ($schemaClass && $iSchemWrapperClass) {
633-
// // If the schema is not set or not an instance of Schema or ISchemaWrapper, throw an exception
634-
// throw new Exception('Schema is not set or not an instance of Schema or ISchemaWrapper');
635-
// }
636-
// if ($schemaClass) {
637-
// // If the schema is not set or not an instance of Schema, throw an exception
638-
// throw new Exception('Schema is not set or not an instance of Schema');
639-
// }
640-
// if ($iSchemWrapperClass) {
641-
// // If the schema is not set or not an instance of ISchemaWrapper, throw an exception
642-
// throw new Exception('Schema is not set or not an instance of ISchemaWrapper');
643-
// }
644-
// throw new Exception('Unexpected. Schema is an instance of ' . get_class($this->schema));
645-
// }
646-
647597
}

lib/Migration/Version080301Date20250822182903.php renamed to lib/Migration/Version080303Date20250824090101.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @psalm-suppress UnusedClass
2626
*/
27-
class Version080301Date20250822182903 extends SimpleMigrationStep {
27+
class Version080303Date20250824090101 extends SimpleMigrationStep {
2828
private ISchemaWrapper $schema;
2929
private ?IOutput $output = null;
3030

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polls",
3-
"version": "8.3.2",
3+
"version": "8.3.3-alpha.2",
44
"private": true,
55
"description": "Polls app for nextcloud",
66
"homepage": "https://github.com/nextcloud/polls#readme",

0 commit comments

Comments
 (0)