Add SQLite indexes for contenus page language/tag queries + WIP: Peertube orphans, dialogs, contact decoupling, context note, finality types

This commit is contained in:
Pontoporeia
2026-06-21 13:33:55 +02:00
parent 0d5e9dac19
commit 03c9c3566f
38 changed files with 1432 additions and 333 deletions

71
scripts/fix-finality-types.php Executable file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/env php
<?php
/**
* fix-finality-types.php — Rename finality types from old masculine/spelling to
* canonical feminine forms.
*
* Approfondi → Approfondie
* Didactique → Enseignement
* Spécialisé → Spécialisée
*
* Idempotent — safe to run multiple times.
*
* Usage:
* php scripts/fix-finality-types.php [DB_PATH]
* Default: storage/xamxam.db
*/
$root = dirname(__DIR__);
// Detect layout: local dev has app/storage/, server has storage/ at root
if ($argc > 1) {
$dbPath = $argv[1];
} elseif (file_exists($root . '/app/storage/xamxam.db')) {
$dbPath = $root . '/app/storage/xamxam.db';
} elseif (file_exists($root . '/storage/xamxam.db')) {
$dbPath = $root . '/storage/xamxam.db';
} else {
die("Database not found. Pass path as argument.\n");
}
if (!file_exists($dbPath)) {
die("Database not found: $dbPath\n");
}
$pdo = new PDO('sqlite:' . $dbPath);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$renames = [
'Approfondi' => 'Approfondie',
'Didactique' => 'Enseignement',
'Spécialisé' => 'Spécialisée',
];
foreach ($renames as $old => $new) {
// Check if old name exists
$oldId = $pdo->query("SELECT id FROM finality_types WHERE name = '$old'")->fetchColumn();
if (!$oldId) {
echo " [skip] '$old' not found\n";
continue;
}
// Get or create canonical row
$newId = $pdo->query("SELECT id FROM finality_types WHERE name = '$new'")->fetchColumn();
if (!$newId) {
$pdo->exec("INSERT INTO finality_types (name) VALUES ('$new')");
$newId = $pdo->lastInsertId();
}
// Relink theses from old to new
$updated = $pdo->exec("
UPDATE theses SET finality_id = $newId
WHERE finality_id = $oldId
");
echo " Relinked $updated thesis(es) from '$old' → '$new'\n";
// Delete old row
$pdo->exec("DELETE FROM finality_types WHERE id = $oldId");
echo " Deleted '$old' (id=$oldId)\n";
}
echo "Done.\n";