mirror of
https://github.com/discourse/discourse.git
synced 2026-08-12 05:37:26 +08:00
This PR fixes several bugs in the bulk import scripts that affect both
regular imports and multi-source `MERGE_IMPORT` runs.
**`import.rake` - skip virtual auto-groups in
`insert_automatic_group_users`**
The `anonymous` and `logged_in_users` groups are virtual groups with no
real membership and no valid SQL condition. Iterating over them caused
errors during import post-processing.
**`generic_bulk.rb` / `base.rb` - poll and MERGE_IMPORT re-run safety**
- **`closed_at` column name mismatch** (`import_polls`): the
intermediate DB schema uses `close_at` but the importer was reading
`closed_at`, causing all poll close dates to be silently imported as
`nil`.
- **`import_poll_options` dedup guard was a no-op**: the `next if` was
inside an `each` block, so it only skipped to the next iteration of the
inner loop - never the outer `create_poll_options` block. Poll options
would always be re-inserted on any re-run. Fixed with `next if
option_ids.all? { ... }` on the outer block.
- **`load_index` cross-source ID collision under `MERGE_IMPORT`**: when
running a second or third source with `MERGE_IMPORT=true`,
`migration_mappings` entries from all prior sources were loaded into
shared maps (`@uploads_mapping`, `@poll_mapping`, etc.). A Woltlab
upload with `id=123` could incorrectly match against a vBulletin upload
`id=123` and be skipped. The fix scopes the query to `original_id LIKE
'<prefix>:%'` and strips the prefix when building the in-memory map, so
each source's dedup is fully isolated. Regular (non-MERGE_IMPORT) runs
are unaffected — `@import_prefix` is `nil` and the original `NOT LIKE
'%:%'` path is taken.
- **Missing dedup guards on `import_chat_threads` and
`import_chat_messages`**: unlike every other entity type, chat threads
and messages had no `next if already_exists` guard. Re-running would
duplicate all chat content. Guards added using the existing
`@chat_thread_mapping` / `@chat_message_mapping` maps, already correctly
prefix-scoped by the `load_index` fix above.
|
||
|---|---|---|
| .. | ||
| base.rb | ||
| discourse_merger.rb | ||
| generic_bulk.rb | ||
| phpbb_postgresql.rb | ||
| uploads_importer.rb | ||
| uploads_importer.yml | ||
| vanilla.rb | ||
| vbulletin.rb | ||
| vbulletin5.rb | ||