Artur-Sulej / excellent_migrations

An Elixir tool for checking safety of database migrations.
MIT License
232 stars 25 forks source link

running excellent_migrations breaks on this migration #1

Closed pmarreck closed 2 years ago

pmarreck commented 2 years ago

Here's the migration it breaks on:

https://github.com/pmarreck/mpnetwork/blob/yolo/priv/repo/migrations/20171016152948_add_additional_indexes_to_attachments_table.exs

Here's the error I see:

bash>> mix excellent_migrations.check_safety

==> excellent_migrations
Compiling 9 files (.ex)
Generated excellent_migrations app

14:07:05.637 [error] Task #PID<0.478.0> started from #PID<0.93.0> terminating
** (Protocol.UndefinedError) protocol Enumerable not implemented for :primary of type Atom
    (elixir 1.13.0-rc.0) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.13.0-rc.0) lib/enum.ex:155: Enumerable.count/1
    (elixir 1.13.0-rc.0) lib/enum.ex:656: Enum.count/1
    (excellent_migrations 0.1.0) lib/parser.ex:63: ExcellentMigrations.Parser.detect_many_columns_index/1
    (excellent_migrations 0.1.0) lib/parser.ex:21: ExcellentMigrations.Parser.detect_dangers/1
    (excellent_migrations 0.1.0) lib/parser.ex:12: anonymous fn/3 in ExcellentMigrations.Parser.traverse_ast/2
    (stdlib 3.16.1) lists.erl:1358: :lists.mapfoldl/3
    (elixir 1.13.0-rc.0) lib/macro.ex:448: Macro.do_traverse/4
Function: &:erlang.apply/2
    Args: [#Function<1.59565726/1 in ExcellentMigrations.Runner.check_migrations/1>, ["priv/repo/migrations/20171016152948_add_additional_indexes_to_attachments_table.exs"]]
** (EXIT from #PID<0.93.0>) an exception was raised:
    ** (Protocol.UndefinedError) protocol Enumerable not implemented for :primary of type Atom
        (elixir 1.13.0-rc.0) lib/enum.ex:1: Enumerable.impl_for!/1
        (elixir 1.13.0-rc.0) lib/enum.ex:155: Enumerable.count/1
        (elixir 1.13.0-rc.0) lib/enum.ex:656: Enum.count/1
        (excellent_migrations 0.1.0) lib/parser.ex:63: ExcellentMigrations.Parser.detect_many_columns_index/1
        (excellent_migrations 0.1.0) lib/parser.ex:21: ExcellentMigrations.Parser.detect_dangers/1
        (excellent_migrations 0.1.0) lib/parser.ex:12: anonymous fn/3 in ExcellentMigrations.Parser.traverse_ast/2
        (stdlib 3.16.1) lists.erl:1358: :lists.mapfoldl/3
        (elixir 1.13.0-rc.0) lib/macro.ex:448: Macro.do_traverse/4

Using latest elixir and erlang, and a recent phoenix (1.5).

This is an old-ish migration so it's entirely possible that even though it runs (it does), it might be syntactically out-of-date

Artur-Sulej commented 2 years ago

Good catch, thanks! I fixed it and released new version – 0.1.1 works fine 👍🏻