mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
refactor: rename keywords→tags M2M (migration 001)
- migration 001_rename_keywords_to_tags.sql: CREATE tags/thesis_tags from keywords/thesis_keywords, copy data, drop old tables, rebuild indexes and views - schema.sql: tags table, thesis_tags junction, updated indexes and v_theses_full/v_theses_public - Database.php: findOrCreateTag(), getUsedTags() with proper JOIN; backwards-compat aliases; buildSearchConditions uses EXISTS subquery on thesis_tags+tags with vp. alias throughout - admin/actions/formulaire.php: INSERT OR IGNORE INTO thesis_tags - admin/edit.php: DELETE FROM thesis_tags + findOrCreateTag - search.php: $kw['name'] (was $kw['keyword']) - fixtures/CreateTestDatabase.php: tags/thesis_tags table names
This commit is contained in:
@@ -56,7 +56,7 @@ try {
|
||||
}
|
||||
echo "Inserted " . count($supervisors) . " sample supervisors\n";
|
||||
|
||||
// Insert sample keywords
|
||||
// Insert sample tags (formerly keywords)
|
||||
$sampleKeywords = [
|
||||
'spéculation', 'narration', 'urbanisme', 'patrimoine', 'intime',
|
||||
'collectivité', 'film', 'cinéma', 'sociologie', 'anthropologie',
|
||||
@@ -65,10 +65,10 @@ try {
|
||||
];
|
||||
|
||||
foreach ($sampleKeywords as $keyword) {
|
||||
$stmt = $pdo->prepare("INSERT INTO keywords (keyword) VALUES (:keyword)");
|
||||
$stmt->execute(['keyword' => $keyword]);
|
||||
$stmt = $pdo->prepare("INSERT INTO tags (name) VALUES (:name)");
|
||||
$stmt->execute(['name' => $keyword]);
|
||||
}
|
||||
echo "Inserted " . count($sampleKeywords) . " sample keywords\n";
|
||||
echo "Inserted " . count($sampleKeywords) . " sample tags\n";
|
||||
|
||||
// Insert sample theses
|
||||
$theses = [
|
||||
@@ -192,30 +192,30 @@ try {
|
||||
}
|
||||
echo "Linked supervisors to theses\n";
|
||||
|
||||
// Link keywords to theses
|
||||
// Link tags to theses (thesis_tags junction)
|
||||
$thesisKeywords = [
|
||||
['thesis_id' => 1, 'keyword_id' => 3], // urbanisme
|
||||
['thesis_id' => 1, 'keyword_id' => 2], // narration
|
||||
['thesis_id' => 1, 'keyword_id' => 6], // collectivité
|
||||
['thesis_id' => 2, 'keyword_id' => 16], // technologies
|
||||
['thesis_id' => 2, 'keyword_id' => 18], // performance
|
||||
['thesis_id' => 2, 'keyword_id' => 20], // art numérique
|
||||
['thesis_id' => 3, 'keyword_id' => 14], // poésie
|
||||
['thesis_id' => 3, 'keyword_id' => 11], // éphémérité
|
||||
['thesis_id' => 3, 'keyword_id' => 5], // intime
|
||||
['thesis_id' => 4, 'keyword_id' => 15], // écologie
|
||||
['thesis_id' => 4, 'keyword_id' => 17], // design
|
||||
['thesis_id' => 5, 'keyword_id' => 1], // spéculation
|
||||
['thesis_id' => 5, 'keyword_id' => 4], // patrimoine
|
||||
['thesis_id' => 6, 'keyword_id' => 18], // performance
|
||||
['thesis_id' => 6, 'keyword_id' => 9], // sociologie
|
||||
['thesis_id' => 1, 'tag_id' => 3], // urbanisme
|
||||
['thesis_id' => 1, 'tag_id' => 2], // narration
|
||||
['thesis_id' => 1, 'tag_id' => 6], // collectivité
|
||||
['thesis_id' => 2, 'tag_id' => 16], // technologies
|
||||
['thesis_id' => 2, 'tag_id' => 18], // performance
|
||||
['thesis_id' => 2, 'tag_id' => 20], // art numérique
|
||||
['thesis_id' => 3, 'tag_id' => 14], // poésie
|
||||
['thesis_id' => 3, 'tag_id' => 11], // éphémérité
|
||||
['thesis_id' => 3, 'tag_id' => 5], // intime
|
||||
['thesis_id' => 4, 'tag_id' => 15], // écologie
|
||||
['thesis_id' => 4, 'tag_id' => 17], // design
|
||||
['thesis_id' => 5, 'tag_id' => 1], // spéculation
|
||||
['thesis_id' => 5, 'tag_id' => 4], // patrimoine
|
||||
['thesis_id' => 6, 'tag_id' => 18], // performance
|
||||
['thesis_id' => 6, 'tag_id' => 9], // sociologie
|
||||
];
|
||||
|
||||
foreach ($thesisKeywords as $link) {
|
||||
$stmt = $pdo->prepare("INSERT INTO thesis_keywords (thesis_id, keyword_id) VALUES (:thesis_id, :keyword_id)");
|
||||
$stmt = $pdo->prepare("INSERT OR IGNORE INTO thesis_tags (tag_id, thesis_id) VALUES (:tag_id, :thesis_id)");
|
||||
$stmt->execute($link);
|
||||
}
|
||||
echo "Linked keywords to theses\n";
|
||||
echo "Linked tags to theses\n";
|
||||
|
||||
// Link languages to theses (all in French)
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
|
||||
Reference in New Issue
Block a user