You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mongo.Migration.migrate() ## default values specified in the configs
649
+
650
+
IO.puts("running topology_2 migration")
651
+
Mongo.Migration.migrate([topology: :topology_2]) ## override the topology
652
+
653
+
Adding the options parameter in the `up/1` and `down/1` function of the migration script is supported as well. It is
654
+
possible to pass additional parameters to the migration scripts.
655
+
656
+
defmodule Mongo.Migrations.Topology.CreateIndex do
657
+
def up(opts) do
658
+
IO.inspect(opts)
659
+
...
660
+
end
661
+
662
+
def down(opts) do
663
+
IO.inspect(opts)
664
+
...
665
+
end
666
+
end
667
+
668
+
The topology is part of the namespace and of the migration path as well. The default value is defined in the configuration.
669
+
You can specify the topology in the case of creating a new migration script by appending the name to the script call:
670
+
```elixir
671
+
672
+
mix mongo.gen.migration add_indexes topology_2
673
+
674
+
```
675
+
676
+
In `priv/topology_2/mongo/migrations` you will find an Elixir script like `20220322173354_add_indexes.exs`:
677
+
678
+
```elixr
679
+
defmodule Mongo.Migrations.Topology2.AddIndexes do
680
+
...
681
+
end
682
+
683
+
```
684
+
685
+
By using the `:topology` keyword, you can organise the migration scripts in different sub-folders. The migration path is prefixed with the `priv` folder of the application and the topology name.
686
+
687
+
If you call
688
+
689
+
Mongo.Migration.migrate([topology: :topology_2])
690
+
691
+
then the migration scripts under `/priv/topology_2/` are used and the options keyword list is passed through
692
+
to the `up/1` function if it is implemented. That means you can create migration scripts for multiple topologies
693
+
separated in sub folders and module namespaces.
694
+
637
695
## Auth Mechanisms
638
696
639
697
For versions of Mongo 3.0 and greater, the auth mechanism defaults to SCRAM.
0 commit comments