mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:11:09 +08:00
DEV: add rake task to annotate plugins in clean DB (#29378)
This commit is contained in:
@ -39,3 +39,23 @@ ensure
|
|||||||
db&.stop
|
db&.stop
|
||||||
db&.remove
|
db&.remove
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "regenerate plugin model annotations using a temporary database"
|
||||||
|
task "annotate:clean:plugins", [:plugin] => :environment do |task, args|
|
||||||
|
specific_plugin = "--model-dir plugins/#{args[:plugin]}/app/models" if args[:plugin].present?
|
||||||
|
|
||||||
|
db = TemporaryDb.new
|
||||||
|
db.start
|
||||||
|
db.with_env do
|
||||||
|
system("RAILS_ENV=test LOAD_PLUGINS=1 bin/rake db:migrate", exception: true)
|
||||||
|
system("RAILS_ENV=test LOAD_PLUGINS=1 bin/rake annotate:ensure_all_indexes", exception: true)
|
||||||
|
system(
|
||||||
|
"RAILS_ENV=test LOAD_PLUGINS=1 bin/annotate --models #{specific_plugin}",
|
||||||
|
exception: true,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
STDERR.puts "Annotate executed successfully"
|
||||||
|
ensure
|
||||||
|
db&.stop
|
||||||
|
db&.remove
|
||||||
|
end
|
||||||
|
Reference in New Issue
Block a user