aaronrenner / phx_gen_auth

An authentication system generator for Phoenix 1.5 applications.
772 stars 55 forks source link

Is it MySQL compatible? #85

Closed rafaelfess closed 4 years ago

rafaelfess commented 4 years ago

Just ran into an issue trying out the generator with TiDB (a MySQL compatible database - TiDB is fully compatible with the MySQL 5.7 protocol).

I've not found MySQL documentation for citext, only for PostgreSQL. So I was wondering if it isn't compatible with a MySQL database because of a specific PostgreSQL's function.

❯ mix ecto.create
The database for Fort.Repo has been created

❯ mix ecto.migrate

18:43:44.060 [info]  == Running 20200929201610 Fort.Repo.Migrations.CreateUsersAuthTables.change/0 forward

18:43:44.063 [info]  execute "CREATE EXTENSION IF NOT EXISTS citext"
** (MyXQL.Error) (1064) (ER_PARSE_ERROR) You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 16 near "EXTENSION IF NOT EXISTS citext"
    (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:593: Ecto.Adapters.SQL.raise_sql_call_error/1
    (elixir 1.10.4) lib/enum.ex:1396: Enum."-map/2-lists^map/1-0-"/2
    (ecto_sql 3.4.5) lib/ecto/adapters/sql.ex:686: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.4.5) lib/ecto/migration/runner.ex:343: Ecto.Migration.Runner.log_and_execute_ddl/3
    (ecto_sql 3.4.5) lib/ecto/migration/runner.ex:117: anonymous fn/6 in Ecto.Migration.Runner.flush/0
    (elixir 1.10.4) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto_sql 3.4.5) lib/ecto/migration/runner.ex:116: Ecto.Migration.Runner.flush/0
    (stdlib 3.12.1) timer.erl:166: :timer.tc/1
    (ecto_sql 3.4.5) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/7
    (ecto_sql 3.4.5) lib/ecto/migrator.ex:342: Ecto.Migrator.attempt/7
    (ecto_sql 3.4.5) lib/ecto/migrator.ex:243: anonymous fn/4 in Ecto.Migrator.do_up/4
    (ecto_sql 3.4.5) lib/ecto/migrator.ex:320: Ecto.Migrator.run_maybe_in_transaction/6
    (elixir 1.10.4) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.10.4) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
aaronrenner commented 4 years ago

Hi @rafaelfesi! PhxGenAuth is compatible with MySQL and it's tested as part of our integration tests here: https://github.com/aaronrenner/phx_gen_auth/blob/master/test/mix/tasks/phx_gen_auth/integration_tests/mysql_app_test.exs

Citext is a postgres only extension and shouldn't have been generated in your migrations. It seems like Postgres was the active adapter when the generator was run (either via config/config.exs or config/dev.exs). I'd suggest removing all of the PhxGenAuth code, ensuring that the database adapter is configured correctly, and then rerunning the generators.

Let me know how that works!

josevalim commented 4 years ago

Closing per the above. :)