Snapshot of main at 9f39a6e1e (2026-11-02)
This commit is contained in:
commit
6ccf1792d7
2580 files changed
+1040202
No files matched your search
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Hotfix: Remove "For X" tags that were seeded without a category
|
||||
*
|
||||
* These 19 tags (For Groups, For Infants, For Toddlers, For Children,
|
||||
* For Teenagers, For Adults, For Elderly, For Students, For Parents,
|
||||
* For Professionals, For Hobbyists, For Vegans, For Vegetarians,
|
||||
* For Academics, For Women, For Men, For Non-Binary, For Refugees,
|
||||
* For Expats) were seeded with category_id = NULL, causing grey badges
|
||||
* and errors on profile pages.
|
||||
*
|
||||
* Run from the application root:
|
||||
* php database/hotfixes/remove_uncategorized_for_x_tags.php
|
||||
*
|
||||
* Or from tinker:
|
||||
* require base_path('database/hotfixes/remove_uncategorized_for_x_tags.php');
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
// Base EN tag IDs seeded without category
|
||||
$baseIds = range(1511, 1529);
|
||||
|
||||
// Get all related tag IDs (all language translations sharing the same contexts)
|
||||
$contextIds = DB::table('taggable_locale_context')
|
||||
->whereIn('tag_id', $baseIds)
|
||||
->pluck('context_id')
|
||||
->unique();
|
||||
|
||||
$allTagIds = DB::table('taggable_locale_context')
|
||||
->whereIn('context_id', $contextIds)
|
||||
->pluck('tag_id')
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
echo "Found " . $allTagIds->count() . " tag IDs to remove (base + all translations)\n";
|
||||
echo "Context IDs: " . $contextIds->implode(', ') . "\n";
|
||||
|
||||
$profileAssociations = DB::table('taggable_taggables')
|
||||
->whereIn('tag_id', $allTagIds)
|
||||
->count();
|
||||
echo "Profile associations to remove: {$profileAssociations}\n";
|
||||
|
||||
// Remove in dependency order
|
||||
$deleted = DB::table('taggable_taggables')->whereIn('tag_id', $allTagIds)->delete();
|
||||
echo "Deleted {$deleted} rows from taggable_taggables\n";
|
||||
|
||||
$deleted = DB::table('taggable_locale_context')->whereIn('tag_id', $allTagIds)->delete();
|
||||
echo "Deleted {$deleted} rows from taggable_locale_context\n";
|
||||
|
||||
$deleted = DB::table('taggable_contexts')->whereIn('id', $contextIds)->delete();
|
||||
echo "Deleted {$deleted} rows from taggable_contexts\n";
|
||||
|
||||
$deleted = DB::table('taggable_locales')->whereIn('taggable_tag_id', $allTagIds)->delete();
|
||||
echo "Deleted {$deleted} rows from taggable_locales\n";
|
||||
|
||||
$deleted = DB::table('taggable_tags')->whereIn('tag_id', $allTagIds)->delete();
|
||||
echo "Deleted {$deleted} rows from taggable_tags\n";
|
||||
|
||||
Cache::flush();
|
||||
echo "Cache flushed\n";
|
||||
echo "Done.\n";
|
||||
Reference in new issue
Block a user