mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: plugins that use models in their initialize section might fail when bootstrapping a new database
This commit is contained in:
@ -172,7 +172,13 @@ class Plugin::Instance
|
|||||||
end
|
end
|
||||||
|
|
||||||
initializers.each do |callback|
|
initializers.each do |callback|
|
||||||
callback.call(self)
|
begin
|
||||||
|
callback.call(self)
|
||||||
|
rescue ActiveRecord::StatementInvalid => e
|
||||||
|
# When running db:migrate for the first time on a new database, plugin initializers might
|
||||||
|
# try to use models. Tolerate it.
|
||||||
|
raise e unless e.message.try(:include?, "PG::UndefinedTable")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user