Artur-Sulej / excellent_migrations

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

FunctionClauseError #3

Closed pmarreck closed 2 years ago

pmarreck commented 2 years ago
** (FunctionClauseError) no function clause matching in ExcellentMigrations.MessageGenerator.build_message/1    

    The following arguments were given to ExcellentMigrations.MessageGenerator.build_message/1:

        # 1
        :column_reference_added

    Attempted function clauses (showing 10 out of 14):

        def build_message(%{type: type, path: path, line: line})
        def build_message(:raw_sql_executed)
        def build_message(:index_not_concurrently)
        def build_message(:many_columns_index)
        def build_message(:column_added_with_default)
        def build_message(:column_removed)
        def build_message(:table_dropped)
        def build_message(:table_renamed)
        def build_message(:column_renamed)
        def build_message(:not_null_added)
        ...
        (4 clauses not shown)

    (excellent_migrations 0.1.1) lib/message_generator.ex:4: ExcellentMigrations.MessageGenerator.build_message/1
    (excellent_migrations 0.1.1) lib/message_generator.ex:5: ExcellentMigrations.MessageGenerator.build_message/1
    (excellent_migrations 0.1.1) lib/mix/tasks/check_safety.ex:23: anonymous fn/1 in Mix.Tasks.ExcellentMigrations.CheckSafety.run/1
    (elixir 1.13.0-rc.0) lib/enum.ex:937: Enum."-each/2-lists^foreach/1-0-"/2
    (excellent_migrations 0.1.1) lib/mix/tasks/check_safety.ex:21: Mix.Tasks.ExcellentMigrations.CheckSafety.run/1
    (mix 1.13.0-rc.0) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.13.0-rc.0) lib/mix/cli.ex:84: Mix.CLI.run_task/2

I'm actually not sure which of my migrations triggered this, but the whole lot of them are at: https://github.com/pmarreck/mpnetwork/tree/yolo/priv/repo/migrations

pmarreck commented 2 years ago

It was possibly 20190930174006_create_sessions.exs or any migration subsequent to that, based on the previous warnings

Artur-Sulej commented 2 years ago

I fixed it by creating more a generic version of generating message that is now able to handle any danger type. I tested it on all your migrations and it works fine.

The fix is available in version 0.1.2 that I've just released on Hex. Thanks!