Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

docs(plans): record Phase 4 data migration (taxon sever + string backfill)

Łukasz Adamczykb8903f14baef
diff --git a/docs/plans/6.0-replace-taxons-with-categories.md b/docs/plans/6.0-replace-taxons-with-categories.md
index 796ef74268..9f2086ccba 100644
--- a/docs/plans/6.0-replace-taxons-with-categories.md
+++ b/docs/plans/6.0-replace-taxons-with-categories.md
@@ -624,13 +624,20 @@ Runs after the Phase 2 rename **and the Phase 3 class rename** — so the script
# model ships in Phase 1 (interim legacy-column apply), so its rows migrate cleanly
# with value + match_policy preserved; they go channel-aware once Phase 5 reimplements apply.
# - copy their ProductCategories -> ProductCollections
+# - copy columns + metadata + table translations; MOVE the ActionText description,
+# ActiveStorage image/square_image, metafields, and friendly_id slugs onto the
+# collection (else category.destroy purges/destroys them). Match both
+# 'Spree::Taxon' and 'Spree::Category' record_type/sluggable_type (deploy window).
# (regardless of which taxonomy / name they lived under)
-# then delete the automatic rows from spree_categories
+# then delete the automatic rows from spree_categories (one txn per category, idempotent)
# 2. Manual categories stay as Spree::Category (the nested-set tree, owned via store_id)
# - manual categories that happened to live under a "Collections" tree stay as
# categories; merchants re-file them as collections via the new UI
# (safe, reversible — no name-based guessing)
-# 3. Drop the now-empty taxonomy roots and the taxonomy_id references
+# 3. Sever the taxonomy structure from the survivors: drop taxonomy roots left
+# childless after step 1 (keep non-empty roots as top-level categories), then
+# null taxonomy_id on all remaining categories — they are store-owned now.
+# The taxonomy_id COLUMN + spree_taxonomies + the Taxonomy model drop in 6.1.
# 4. Backfill stored class-name strings 'Spree::Taxon*' -> 'Spree::Category*'
# (Phase 3 renamed the classes and writes the new names; existing rows still
# hold the old ones, so migrate them here):
@@ -646,6 +653,8 @@ Runs after the Phase 2 rename **and the Phase 3 class rename** — so the script
# new 5.5+ stores (arbitrary or zero taxonomies).
```
+**Status: implemented** as `spree/core/lib/tasks/categories_and_collections.rake` (spec: `spec/lib/tasks/categories_and_collections_spec.rb`). Each automatic category migrates in its own transaction — a partial failure rolls back and a re-run skips what's already gone, so the task is idempotent. Automatic categories with child categories are skipped (automatic taxons are leaves; the task refuses to destroy a subtree). After the automatic pass it severs the taxonomy structure (backfill store_id from taxonomy → drop childless taxonomy roots → null `taxonomy_id` on the rest), then runs the string backfills once for the surviving (manual) category rows.
+
### Phase 5: Reintroduce channel-aware `AvailableOn` (after `6.0-channels-catalogs-b2b.md`)
Gated on the channels plan finishing the `available_on` → `ProductPublication#published_at` migration. Until then, `CollectionRules::AvailableOn` runs the interim legacy-column query shipped in Phase 1.