Keep getting a 1064 (MySQL) error when trying to run mix test

** (Mariaex.Error) (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1
    (ecto) lib/ecto/adapters/sql.ex:185: Ecto.Adapters.SQL.query!/5
    (ecto) lib/ecto/adapters/mysql.ex:85: anonymous fn/4 in Ecto.Adapters.MySQL.execute_ddl/3
    (elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/adapters/mysql.ex:85: Ecto.Adapters.MySQL.execute_ddl/3
    (ecto) lib/ecto/migration/runner.ex:89: anonymous fn/2 in Ecto.Migration.Runner.flush/0
    (elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto) lib/ecto/migration/runner.ex:87: Ecto.Migration.Runner.flush/0
    (stdlib) timer.erl:181: :timer.tc/

I’m getting this error when running mix test. It’s a Phoenix application.

I’ve tried a lot of things. Deleting all tests, old branches, commenting certain sections, deleting the git repo and downloading again, upgrading mysql, removing mysql and installing again, upgrading some deps.

In my colleague’s laptop this runs fine and we’ve got the exact same setup (Ubuntu, same MYSQL version, same erlang and elixir version). This was working fine some time ago, but now it breaks with this error.

We’re at a loss on how to solve this :confused: It seems to come from a bad query in Ecto that’s using something from timer.erl (maybe something related to processes sleeping?

Dropping the test DB and creating again seems to have solved it. I guess removing MySQL doesn’t remove its databases along with it?

That’s usually correct. Also worth noting that if you upgrade you sometimes need to run an upgrade to update your DBs too (so always check release notes).

1 Like

@AstonJ It’s just weird that it was working before. I guess it somehow got into a weird and wrong state/corrupted?

1 Like

You could have tried to repair/rebuild tables: https://dev.mysql.com/doc/refman/5.7/en/rebuilding-tables.html something I’ve had to do often when using MySQL.

…and something I’ve never had to do with Postrges :icon_wink: :003:

1 Like

Yeah I’ll probably migrate to Postgres after I get a stable version of this project :angry:

I would just do it now :slight_smile: the earlier the better imo.

There are some slight differences and this way you will learn them early on.

1 Like