Class: Hanami::CLI::Commands::App::DB::Seed Private
- Inherits:
-
Command
- Object
- Dry::CLI::Command
- Hanami::CLI::Command
- Command
- Command
- Hanami::CLI::Commands::App::DB::Seed
- Defined in:
- lib/hanami/cli/commands/app/db/seed.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants inherited from Command
Instance Attribute Summary
Attributes inherited from Command
#system_call, #test_env_executor
Instance Method Summary collapse
Methods inherited from Command
#initialize, #nested_command?, #run_command
Methods inherited from Command
#app, inherited, #measure, #run_command
Methods inherited from Hanami::CLI::Command
Constructor Details
This class inherits a constructor from Hanami::CLI::Commands::App::DB::Command
Instance Method Details
#call(app: false, slice: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hanami/cli/commands/app/db/seed.rb', line 15 def call(app: false, slice: nil, **) # We use `databases` below to discover the databases throughout the app and slices. It # yields every database, so in a slice with multiple gateways, we'll see multiple # databases for the slice. # # Since `db seed` is intended to run over whole slices only (not per-gateway), keep # track of the seeded slices here, so we can avoid seeding a slice multiple times. seeded_slices = [] databases(app: app, slice: slice).each do |database| next if seeded_slices.include?(database.slice) seeds_path = database.slice.root.join(SEEDS_PATH) unless seeds_path.file? out.puts "no seeds found at #{seeds_path.relative_path_from(database.slice.app.root)}" next end relative_seeds_path = seeds_path.relative_path_from(database.slice.app.root) measure "seed data loaded from #{relative_seeds_path}" do load seeds_path.to_s end seeded_slices << database.slice end end |