Skip to content

Commit

Permalink
Fix gen_migration :overwrite (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrocp authored Oct 21, 2024
1 parent 9f58be0 commit fa988d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/igniter/libs/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ defmodule Igniter.Libs.Ecto do
gen_migration(igniter, repo, name <> "_1", opts)
end

:ovewrwrite ->
:overwrite ->
Igniter.create_new_file(
igniter,
file,
Expand Down
27 changes: 27 additions & 0 deletions test/igniter/libs/ecto_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,31 @@ defmodule Igniter.Libs.EctoTest do
""")
end
end

test "it overwrites existing file" do
test_project()
|> Igniter.Libs.Ecto.gen_migration(Example.Repo, "create_users",
body: """
def up, do: "up old"
def down, do: "down old"
""",
timestamp: 0
)
|> Igniter.Libs.Ecto.gen_migration(Example.Repo, "create_users",
body: """
def up, do: "up new"
def down, do: "down new"
""",
timestamp: 0,
on_exists: :overwrite
)
|> assert_creates("priv/repo/migrations/0_create_users.exs", """
defmodule Example.Repo.Migrations.CreateUsers do
use Ecto.Migration
def up, do: "up new"
def down, do: "down new"
end
""")
end
end

0 comments on commit fa988d7

Please sign in to comment.