PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: elixir-ecto/ecto_sql (elixir)

Issue:
Warn on `.ex` files in `priv/repo/migrations`
### Elixir version

*

### Database and Version

*

### Ecto Versions

*

### Database Adapter and Versions (postgrex, myxql, etc)

*

### Current behavior

Right now correct-looking migration files in `priv/repo/migrations` get silently skipped if they're `.ex` files rather than `.exs`. See https://github.com/vinniefranco/exandra/discussions/52 for context.

### Expected behavior

I know that `mix ecto.gen.migration` generates correct filenames, but I’m wondering: should we just warn if there are `.ex` files in a migrations directory? Are there legit use cases for something like that?

Pull request:
Warn for migration files that end in ".ex"
Closes #599. cc @josevalim 

Patch:
diff --git a/lib/ecto/migrator.ex b/lib/ecto/migrator.ex
index 769c3b7..d1083ad 100644
--- a/lib/ecto/migrator.ex
+++ b/lib/ecto/migrator.ex
@@ -662,7 +662,7 @@ defmodule Ecto.Migrator do
     migration_source
     |> Enum.flat_map(fn
       directory when is_binary(directory) ->
-        Path.join([directory, "**", "*.exs"])
+        Path.join([directory, "**", "*.{ex,exs}"])
         |> Path.wildcard()
         |> Enum.map(&extract_migration_info/1)
         |> Enum.filter(& &1)
@@ -677,8 +677,25 @@ defmodule Ecto.Migrator do
     base = Path.basename(file)
 
     case Integer.parse(Path.rootname(base)) do
-      {integer, "_" <> name} -> {integer, name, file}
-      _ -> nil
+      {integer, "_" <> name} ->
+        if Path.extname(base) == ".ex" do
+          # See: https://github.com/elixir-ecto/ecto_sql/issues/599
+          IO.warn(
+            """
+            file looks like a migration but ends in .ex. \
+            Migration files should end in .exs. Use "mix ecto.gen.migration" to generate \
+            migration files with the correct extension.\
+            """,
+            file: file
+          )
+
+          nil
+        else
+          {integer, name, file}
+        end
+
+      _ ->
+        nil
     end
   end
 


Test patch:
diff --git a/test/ecto/migrator_test.exs b/test/ecto/migrator_test.exs
index 1fc8958..0465215 100644
--- a/test/ecto/migrator_test.exs
+++ b/test/ecto/migrator_test.exs
@@ -3,6 +3,7 @@ defmodule Ecto.MigratorTest do
 
   import Support.FileHelpers
   import Ecto.Migrator
+  import ExUnit.CaptureIO
   import ExUnit.CaptureLog
 
   alias EctoSQL.TestRepo
@@ -405,6 +406,19 @@ defmodule Ecto.MigratorTest do
     end
   end
 
+  test "warns for .ex files that look like migrations" do
+    in_tmp(fn path ->
+      output =
+        capture_io(:stderr, fn ->
+          create_migration("123_looks_like_migration.ex")
+          assert run(TestRepo, path, :up, all: true, log: false) == []
+        end)
+
+      assert output =~ "file looks like a migration but ends in .ex"
+      assert output =~ "123_looks_like_migration.ex"
+    end)
+  end
+
   describe "lock for migrations" do
     setup do
       put_test_adapter_config(test_process: self())