Skip to content

Commit e200013

Browse files
committed
chore: clean up the default configuration
1 parent e18d245 commit e200013

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ for each command. The event name is `[:mongodb_driver, :execution]` and the driv
421421

422422
```elixir
423423
metadata = %{
424-
type: :mongodb_driver,
425-
command: command,
426-
params: parameters,
427-
collection: collection,
428-
options: Keyword.get(opts, :telemetry_options, [])
424+
type: :mongodb_driver,
425+
command: command,
426+
params: parameters,
427+
collection: collection,
428+
options: Keyword.get(opts, :telemetry_options, [])
429429
}
430430

431431
:telemetry.execute([:mongodb_driver, :execution], %{duration: duration}, metadata)
@@ -551,7 +551,7 @@ Or let it run if your application starts:
551551
```elixir
552552
defmodule MyApp.Release do
553553
@moduledoc """
554-
Used for executing DB release tasks when run in production without Mix
554+
Used for executing DB release tasks when run in production without mix
555555
installed.
556556
"""
557557

@@ -624,13 +624,13 @@ default values:
624624
[
625625
topology: :mongo,
626626
collection: "migrations",
627-
path: "mongo/migrations",
627+
path: "migrations",
628628
otp_app: :mongodb_driver
629629
]
630630

631631
The following options are available:
632632
* `:collection` - Version numbers of migrations will be saved in a collection named `migrations` by default.
633-
* `:path` - the `priv` directory for migrations. `:path` defaults to "mongo/migrations" and migrations should be placed at "priv/mongo/migrations"
633+
* `:path` - the `priv` directory for migrations. `:path` defaults to "migrations" and migrations should be placed at "priv/mongo/migrations". The pattern to build the path is `:priv/:topology/:path`
634634
* `:otp_app` - the name of the otp_app to resolve the `priv` folder, defaults to `:mongodb_driver`. In most cases you use your application name.
635635
* `:topology` - the topology for running the migrations, `:topology` defaults to `:mongo`
636636

@@ -673,7 +673,7 @@ mix mongo.gen.migration add_indexes topology_2
673673

674674
```
675675

676-
In `priv/topology_2/mongo/migrations` you will find an Elixir script like `20220322173354_add_indexes.exs`:
676+
In `priv/topology_2/migrations` you will find an Elixir script like `20220322173354_add_indexes.exs`:
677677

678678
```elixr
679679
defmodule Mongo.Migrations.Topology2.AddIndexes do

lib/mongo/migration.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ defmodule Mongo.Migration do
132132
end
133133

134134
def get_config(opts \\ []) do
135-
defaults = [topology: :mongo, collection: "migrations", path: "mongo/migrations", otp_app: :mongodb_driver]
135+
defaults = [topology: :mongo, collection: "migrations", path: "migrations", otp_app: :mongodb_driver]
136136

137137
defaults
138138
|> Keyword.merge(Application.get_env(:mongodb_driver, :migration, []))
@@ -153,7 +153,7 @@ defmodule Mongo.Migration do
153153
{:ok, files} ->
154154
files
155155
|> Enum.sort()
156-
|> Enum.map(fn file_name -> file_path <> "/" <> file_name end)
156+
|> Enum.map(fn file_name -> Path.join([file_path, file_name]) end)
157157

158158
{:error, _error} ->
159159
raise "Could not find migrations file path #{inspect(file_path)}"

lib/tasks/mongo.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Mix.Tasks.Mongo do
5151
5252
config :mongodb_driver,
5353
migration: [
54-
path: "mongo/migrations",
54+
path: "migrations",
5555
otp_app: :mongodb_driver,
5656
topology: :mongo,
5757
collection: "migrations"
@@ -64,7 +64,7 @@ defmodule Mix.Tasks.Mongo do
6464
6565
config :mongodb_driver, :migration, collection: "my_migrations"
6666
67-
* `:path` - the priv directory for migrations. :path defaults to "mongo/migrations" and migrations should be placed at "priv/mongo/migrations"
67+
* `:path` - the `priv` sub-directory for migrations. `:path` defaults to "migrations" and migrations should be placed at "priv/mongo/migrations"
6868
* `:otp_app` - the name of the otp_app to resolve the priv folder, defaults to :mongodb_driver. In most cases you use your application name.
6969
* `:topology` - the topology for running the migrations, :topology defaults to :mongo
7070
"""

test/mongo/migration_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Mongo.MigrationTest do
66

77
test "test lock and unlock", %{pid: top} do
88
Mongo.drop_collection(top, "migrations")
9-
Patch.patch(Mongo.Migration, :get_config, fn _ -> [topology: top, collection: "migrations", path: "mongo/migrations", otp_app: :mongodb_driver] end)
9+
Patch.patch(Mongo.Migration, :get_config, fn _ -> [topology: top, collection: "migrations", path: "migrations", otp_app: :mongodb_driver] end)
1010
assert :locked == Migration.lock()
1111
assert {:error, :already_locked} == Migration.lock()
1212
assert :unlocked == Migration.unlock()

0 commit comments

Comments
 (0)