0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/script
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
..
benchmarks
bulk_import Fix/bulk import merge import and poll fixes (#39830) 2026-05-10 08:25:03 -04:00
demon_test
import_scripts DEV: Update rubocop (#38721) 2026-03-20 00:39:52 +01:00
.gitignore
alice.txt
analyse_message_bus.rb
analyze_sidekiq_queues.rb
assemble_ember_build.rb DEV: Remove (again) the old non-rollup plugin compiler (#39419) 2026-04-21 21:07:46 +02:00
backport.rb DEV: Fixup script/backport.rb for unmerged PRs (#39794) 2026-05-06 16:27:57 +01:00
bench.rb DEV: Remove Unicorn web server in favor of Pitchfork (#39032) 2026-04-01 15:04:59 +02:00
biggest_objects.rb
boot_mem.rb
cache_critical_dns DEV: Support connecting to Redis with a username. (#31710) 2025-03-13 10:39:50 +08:00
check_forking.rb
check_reproducible_assets.rb DEV: Prepare for rename of app/assets/javascripts/ -> frontend/ 2025-10-22 16:24:11 +01:00
copyright-deposit
db_timestamps_mover.rb DEV: Remove ignored tables that have been dropped (#30185) 2024-12-10 07:11:05 +08:00
diff_heaps.rb DEV: Update to lastest rubocop-discourse 2024-05-27 18:06:14 +02:00
discourse DEV: Rename Backuper to Creator 2026-01-22 18:46:02 +00:00
docker_test.rb
i18n_lint.rb FEATURE: New automation for emailing specific users when a post is flagged (#36580) 2025-12-11 10:31:13 +08:00
install_minio_binaries.rb
list_bundled_plugins DEV: Update core lint commands to only affect bundled plugins (#29824) 2024-11-19 18:56:14 +00:00
local_minio_s3.rb
memory-analysis
memstats.rb
micro_bench.rb
mwrap_sidekiq
profile_db_generator.rb DEV: Update rubocop-discourse to 3.13 and autofix issues (#35073) 2025-10-06 16:11:01 +02:00
promote_migrations DEV: Promote old post-deploy migrations to pre-deploy (#38595) 2026-03-13 19:09:30 +00:00
publish_built_assets.rb DEV: Remove (again) the old non-rollup plugin compiler (#39419) 2026-04-21 21:07:46 +02:00
rails
redis_memory.rb
require_profiler.rb
silence_successful_output
spawn_backup_restore.rb DEV: Rename Backuper to Creator 2026-01-22 18:46:02 +00:00
start_test_db.rb DEV: Set synchronous_commit to off in start_test_db (#25453) 2024-01-29 10:14:32 +08:00
switch_container_ruby
test_email_settings.rb
test_mem.rb
test_memory_leak.rb
test_pretty_text.rb
thread_detective.rb
user_simulator.rb DEV: Clean up requires (#34946) 2025-09-24 12:00:22 +02:00