kipcole9/money_sql

Could not read file error after upgrading to 1.10.0

bigardone opened this issue · 4 comments

Hi @kipcole9 👋🏼
After upgrading to 1.10.0, I get the following error while trying to run the migration for min and max:

11:24:35.472 [info] == Running 20231102101154 Marko.Repo.Migrations.AddPostgresMoneyMinmaxFunctions.up/0 forward
** (File.Error) could not read file "priv/SQL/postgres/get_currency_code_type.sql": no such file or directory
    (elixir 1.15.5) lib/file.ex:358: File.read!/1
    (ex_money_sql 1.10.0) lib/money/migration.ex:19: Money.Migration.postgres_money_with_currency_type/1
    (ex_money_sql 1.10.0) lib/money/migration.ex:5: Money.Migration.adjust_for_type/2
    priv/repo/migrations/20231102101154_add_postgres_money_minmax_functions.exs:42: Marko.Repo.Migrations.AddPostgresMoneyMinmaxFunctions.up/0
    (ecto_sql 3.10.2) lib/ecto/migration/runner.ex:289: Ecto.Migration.Runner.perform_operation/3
    (stdlib 5.0.2) timer.erl:270: :timer.tc/2
    (ecto_sql 3.10.2) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/8
    (ecto_sql 3.10.2) lib/ecto/migrator.ex:366: Ecto.Migrator.attempt/8

I saw a similar closed issue from some years ago. I think the issue is here:

query = File.read!("priv/SQL/postgres/get_currency_code_type.sql")

Maybe it should be using something like

defp read_sql_file(db_type, file_name) when db_type in @supported_db_types do
instead.

Thanks for the issue. Yes, thats not good at all! Will fix in the next few hours.

I can create a PR if you want :)

I've published ex_money_sql version 1.10.1 with the following changelog entry:

Bug Fixes

  • Fix compilation warnings on Elixir 1.16.

  • Fix migration generator for money_with_currency type. Thanks to @bigardone for the issue and PR. Closes #37, closes #38.

Thanks again for the support and the PR.