mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 22:05:52 +08:00
We're adding `slug` to the `Tag` model so that we can move URLs away
from the `/tag/name` convention to `/tag/slug/id`.
This commit only includes adding the column in the database, a migration,
and ActiveRecord validation. For extra info to the reviewer, this is a
list of scenarios for how slugs are generated in categories, in the tag
migration, and tag model:
| scenario | category | tag (migration) | tag (model) |
|-----------------------------------|------------------|------------------|------------------|
| normal ("Turkish Angora") | "turkish-angora" | "turkish-angora" |
"turkish-angora" |
| numeric-only ("123") | "" | "" | "" |
| unicode-only ("猫") | "" | "" | "" |
| unicode mixed ("turkish猫angora") | "turkish-angora" | "turkish-angora"
| "turkish-angora" |
| special chars ("turkish@angora!") | "turkish-angora" |
"turkish-angora" | "turkish-angora" |
| special chars only ("@#$%") | "" | "" | "" |
| conflict | "" | "" | "" |
All empty slugs use slug_for_url → "#{id}-tag" for URLs. This is similar
to how categories work to keep consistent. This PR contains 2
migrations, slug generation and index creation. The migration spec
doesn't allow for "CONCURRENT" index creation, so we are separating them
to make things easier to test.
|
||
|---|---|---|
| .. | ||
| .gitkeep | ||
| 20250714010001_backfill_themeable_site_settings_spec.rb | ||
| 20250902072941_sync_timerable_id_topic_id_spec.rb | ||
| 20251024015907_populate_image_quality_setting_spec.rb | ||
| 20260106060807_add_slug_to_tags_spec.rb | ||