DEV: skip_jobs when seeding topics (#11289)
Don't raise an exception when creating a post inside a transaction in import_mode.
This commit is contained in:
parent
7af061fafa
commit
b143412be4
|
@ -199,8 +199,10 @@ class PostCreator
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if !Rails.env.test? && ActiveRecord::Base.connection.open_transactions > 0 && !@opts[:skip_jobs]
|
if !Rails.env.test? && !@opts[:import_mode]
|
||||||
raise "You must use 'skip_jobs = true' when creating a post inside a transaction, otherwise jobs won't run properly."
|
if ActiveRecord::Base.connection.open_transactions > 0 && !@opts[:skip_jobs]
|
||||||
|
raise "You must use 'skip_jobs = true' when creating a post inside a transaction, otherwise jobs won't run properly."
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if valid?
|
if valid?
|
||||||
|
|
|
@ -131,6 +131,7 @@ module SeedData
|
||||||
Discourse.system_user,
|
Discourse.system_user,
|
||||||
title: title,
|
title: title,
|
||||||
raw: raw,
|
raw: raw,
|
||||||
|
skip_jobs: true,
|
||||||
skip_validations: true,
|
skip_validations: true,
|
||||||
category: category&.id
|
category: category&.id
|
||||||
)
|
)
|
||||||
|
@ -139,6 +140,7 @@ module SeedData
|
||||||
PostCreator.create!(
|
PostCreator.create!(
|
||||||
Discourse.system_user,
|
Discourse.system_user,
|
||||||
raw: first_reply_raw(title),
|
raw: first_reply_raw(title),
|
||||||
|
skip_jobs: true,
|
||||||
skip_validations: true,
|
skip_validations: true,
|
||||||
topic_id: post.topic_id
|
topic_id: post.topic_id
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue