fix(scripts): correct autotag rule direction in legacy migration

The old autotags worked child -> parent (adding child_id pulled in parent_id,
per tfm__add_file_to_tag_recursive). The new tag_rules model is "when_tag
applied -> then_tag follows", so child must map to when_tag and parent to
then_tag. The transform had it reversed, so migrated rules never fired —
adding a tag added only itself.

Map child_id -> when_tag_id, parent_id -> then_tag_id. Verified on a scratch DB.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 13:45:52 +03:00
parent f73f954b1a
commit aae0c587e8
2 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ psql "$NEW_DSN" -v ON_ERROR_STOP=1 -f transform.sql
| `mime` | `core.mime_types` | id **uuid → smallint** (remapped by `name`); types not already seeded are added |
| `categories` | `data.categories` | id kept; `is_private`**`is_public`** (inverted) |
| `tags` | `data.tags` | id + `category_id` kept; inverted privacy |
| `autotags` | `data.tag_rules` | `parent_id``when_tag_id`, `child_id``then_tag_id` |
| `autotags` | `data.tag_rules` | `child_id``when_tag_id`, `parent_id``then_tag_id` (old: adding the child pulled in the parent) |
| `files` | `data.files` | id kept; `datetime``content_datetime`; `orig_name``original_name`; **EXIF** lifted from `metadata->'exif'` into the `exif` column, the rest stays as user `metadata` |
| `file_tag` | `data.file_tag` | orphan rows skipped |
| `pools` | `data.pools` | id kept; `parent_id` + `created` preserved under `metadata` (see below) |