Seeds: scope compiler_options to seed run, restore in after
Remove global ignore_module_conflict from mix.exs. Set it only in seeds.exs during eval_file and restore via try/after so crashes do not leave the option enabled.
This commit is contained in:
parent
70c3ca82ea
commit
a98d921848
2 changed files with 16 additions and 10 deletions
|
|
@ -4,16 +4,24 @@
|
|||
#
|
||||
# Bootstrap runs in all environments. Dev seeds (members, groups, sample data)
|
||||
# run only in dev and test.
|
||||
#
|
||||
# Compiler option ignore_module_conflict is set only during seed evaluation
|
||||
# so that eval_file of bootstrap/dev does not emit "redefining module" warnings;
|
||||
# it is always restored in `after` to avoid hiding real conflicts elsewhere.
|
||||
|
||||
prev = Code.compiler_options()
|
||||
Code.compiler_options(ignore_module_conflict: true)
|
||||
|
||||
# Always run bootstrap (fee types, custom fields, roles, admin, system user, settings)
|
||||
Code.eval_file("priv/repo/seeds_bootstrap.exs")
|
||||
try do
|
||||
# Always run bootstrap (fee types, custom fields, roles, admin, system user, settings)
|
||||
Code.eval_file("priv/repo/seeds_bootstrap.exs")
|
||||
|
||||
# In dev and test only: run dev seeds (20 members, groups, custom field values)
|
||||
if Mix.env() in [:dev, :test] do
|
||||
Code.eval_file("priv/repo/seeds_dev.exs")
|
||||
# In dev and test only: run dev seeds (20 members, groups, custom field values)
|
||||
if Mix.env() in [:dev, :test] do
|
||||
Code.eval_file("priv/repo/seeds_dev.exs")
|
||||
end
|
||||
|
||||
IO.puts("✅ All seeds completed.")
|
||||
after
|
||||
Code.compiler_options(prev)
|
||||
end
|
||||
|
||||
IO.puts("✅ All seeds completed.")
|
||||
Code.compiler_options(ignore_module_conflict: false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue