Merge remote-tracking branch 'origin/main' into fix/atomic-votes
This commit is contained in:
commit
9d65e85c55
21 files changed
+402
-128
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
/**
|
||||
* Removes answer options and responses whose slide no longer exists.
|
||||
*
|
||||
* Deleting a poll used to rely on ON DELETE CASCADE, which SQLite does not enforce
|
||||
* by default, so options and responses of deleted polls could stay behind.
|
||||
* PollsTable now deletes them via the ORM; this cleans up what was left before.
|
||||
* Safe to run repeatedly, a no-op on databases that enforce foreign keys.
|
||||
*/
|
||||
class RemoveOrphanedRows extends BaseMigration
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$this->execute('DELETE FROM responses WHERE slide_id NOT IN (SELECT id FROM slides)');
|
||||
$this->execute('DELETE FROM slide_options WHERE slide_id NOT IN (SELECT id FROM slides)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Deleted rows cannot be restored.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
/**
|
||||
* polls.show_results_to_participants is unused: results belong on the stage, participants
|
||||
* only get them where they interact with them (see PollStateService). There is no switch per poll.
|
||||
*/
|
||||
class DropShowResultsToParticipants extends BaseMigration
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$table = $this->table('polls');
|
||||
if ($table->hasColumn('show_results_to_participants')) {
|
||||
$table->removeColumn('show_results_to_participants')->update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$table = $this->table('polls');
|
||||
if (!$table->hasColumn('show_results_to_participants')) {
|
||||
$table->addColumn('show_results_to_participants', 'boolean', [
|
||||
'null' => false,
|
||||
'default' => true,
|
||||
'after' => 'is_active',
|
||||
])->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Error\RedactingErrorLogger;
|
||||
use Cake\Cache\Engine\FileEngine;
|
||||
use Cake\Database\Connection;
|
||||
use Cake\Database\Driver\Sqlite;
|
||||
@@ -236,6 +237,8 @@ return [
|
||||
'trace' => true,
|
||||
'ignoredDeprecationPaths' => [],
|
||||
'traceFormat' => null,
|
||||
// Masks admin tokens and embed keys in logged URLs and messages.
|
||||
'logger' => RedactingErrorLogger::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user