mirror of
https://github.com/discourse/discourse.git
synced 2026-03-04 01:15:08 +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.
|
||
|---|---|---|
| .. | ||
| migrate | ||