0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-12 05:37:26 +08:00
discourse/script/bulk_import
Ruben Oussoren 1338f05312
Fix/bulk import merge import and poll fixes (#39830)
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.
2026-05-10 08:25:03 -04:00
..
base.rb Fix/bulk import merge import and poll fixes (#39830) 2026-05-10 08:25:03 -04:00
discourse_merger.rb DEV: Move category approval settings to join table (#38523) 2026-03-16 10:20:26 +08:00
generic_bulk.rb Fix/bulk import merge import and poll fixes (#39830) 2026-05-10 08:25:03 -04:00
phpbb_postgresql.rb DEV: Bump rubocop_discourse (#29608) 2024-11-06 06:27:49 +08:00
uploads_importer.rb MT: Fix upload import issues (#39703) 2026-05-04 15:19:07 +02:00
uploads_importer.yml MT: Fix upload import issues (#39703) 2026-05-04 15:19:07 +02:00
vanilla.rb FIX: Use a valid value for disabling backups using backup_frequency (#34245) 2025-08-12 13:19:56 +08:00
vbulletin.rb FIX: Use a valid value for disabling backups using backup_frequency (#34245) 2025-08-12 13:19:56 +08:00
vbulletin5.rb FIX: Use a valid value for disabling backups using backup_frequency (#34245) 2025-08-12 13:19:56 +08:00