changed
CHANGELOG.md
|
@@ -2,13 2,23 @@
|
2
2
|
|
3
3
|
**Note** That `money_sql` is supported on Elixir 1.11 and later only.
|
4
4
|
|
5
|
## Money_SQL v1.10.1
|
6
|
|
7
|
This is the changelog for Money_SQL v1.10.1 released on November 3rd, 2023.
|
8
|
|
9
|
### Bug Fixes
|
10
|
|
11
|
* Fix compilation warnings on Elixir 1.16.
|
12
|
|
13
|
* Fix migration generator for `money_with_currency` type. Thanks to @bigardone for the issue and PR. Closes #37, closes #38.
|
14
|
|
5
15
|
## Money_SQL v1.10.0
|
6
16
|
|
7
17
|
This is the changelog for Money_SQL v1.10.0 released on October 30th, 2023.
|
8
18
|
|
9
19
|
### Bug Fixes
|
10
20
|
|
11
|
- * The mix tasks that generate database function migrations (`money.gen.postgres.sum_function`, `money.gen.postgres.plus_operator` and `money.gen.postgres.min_max_functions`) need to be aware of the type of the `money_with_currency` "amount" element in a Postgres database. In releases of `ex_money_sql` up to 1.7.1 the type was `char(3)`. In later releases is changed to the more canonical `varchar`. In turn, the database functions need to know the type for the internal accumulator. It is possible, as illustrated in issue #36, to have generated the `money_with_currency` type as `char(3)` and then move to a later release of `ex_money_sql`. In which case the money database function migrations would fail because they were built with `varchar` accumulators. This release will detect the underlying type of the `money_with_currency` "amount" element and adjust the migration accordingly. Thanks to @bigardone for the report and motivation to get this done. Closes #36.
|
21
|
* The mix tasks that generate database function migrations (`money.gen.postgres.sum_function`, `money.gen.postgres.plus_operator` and `money.gen.postgres.min_max_functions`) need to be aware of the type of the `money_with_currency` "currency_code" element in a Postgres database. In releases of `ex_money_sql` up to 1.7.1 the type was `char(3)`. In later releases is changed to the more canonical `varchar`. In turn, the database functions need to know the type for the internal accumulator. It is possible, as illustrated in issue #36, to have generated the `money_with_currency` "currency_code" type as `char(3)` and then move to a later release of `ex_money_sql`. In which case the money database function migrations would fail because they were built with `varchar` accumulators. This release will detect the underlying type of the `money_with_currency` "currency_code" element and adjust the migration accordingly. Thanks to @bigardone for the report and motivation to get this done. Closes #36.
|
12
22
|
|
13
23
|
### Enhancements
|
changed
hex_metadata.config
|
@@ -1,11 1,11 @@
|
1
1
|
{<<"links">>,
|
2
2
|
[{<<"Changelog">>,
|
3
|
- <<"https://github.com/kipcole9/money_sql/blob/v1.10.0/CHANGELOG.md">>},
|
3
|
<<"https://github.com/kipcole9/money_sql/blob/v1.10.1/CHANGELOG.md">>},
|
4
4
|
{<<"GitHub">>,<<"https://github.com/kipcole9/money_sql">>},
|
5
5
|
{<<"Readme">>,
|
6
|
- <<"https://github.com/kipcole9/money_sql/blob/v1.10.0/README.md">>}]}.
|
6
|
<<"https://github.com/kipcole9/money_sql/blob/v1.10.1/README.md">>}]}.
|
7
7
|
{<<"name">>,<<"ex_money_sql">>}.
|
8
|
- {<<"version">>,<<"1.10.0">>}.
|
8
|
{<<"version">>,<<"1.10.1">>}.
|
9
9
|
{<<"description">>,
|
10
10
|
<<"Money functions for the serialization a money data type.">>}.
|
11
11
|
{<<"elixir">>,<<"~> 1.11">>}.
|
changed
lib/mix/tasks/money_gen_minmax_functions.ex
|
@@ -61,7 61,7 @@ if Code.ensure_loaded?(Ecto) do
|
61
61
|
end
|
62
62
|
|
63
63
|
def down do
|
64
|
- <%= Money.DDL.execute_each(Money.DDL.drop_minmax_functions) %>
|
64
|
<%= Money.DDL.execute_each(Money.DDL.drop_minmax_functions()) %>
|
65
65
|
end
|
66
66
|
end
|
67
67
|
""")
|
changed
lib/mix/tasks/money_gen_sum_function.ex
|
@@ -61,7 61,7 @@ if Code.ensure_loaded?(Ecto) do
|
61
61
|
end
|
62
62
|
|
63
63
|
def down do
|
64
|
- <%= Money.DDL.execute_each(Money.DDL.drop_sum_function) %>
|
64
|
<%= Money.DDL.execute_each(Money.DDL.drop_sum_function()) %>
|
65
65
|
end
|
66
66
|
end
|
67
67
|
""")
|
changed
lib/mix/tasks/money_postgres_add_function.ex
|
@@ -61,7 61,7 @@ if Code.ensure_loaded?(Ecto) do
|
61
61
|
end
|
62
62
|
|
63
63
|
def down do
|
64
|
- <%= Money.DDL.execute_each(Money.DDL.drop_plus_operator) %>
|
64
|
<%= Money.DDL.execute_each(Money.DDL.drop_plus_operator()) %>
|
65
65
|
end
|
66
66
|
end
|
67
67
|
""")
|
changed
lib/mix/tasks/money_postgres_migration.ex
|
@@ -60,11 60,11 @@ if Code.ensure_loaded?(Ecto) do
|
60
60
|
use Ecto.Migration
|
61
61
|
|
62
62
|
def up do
|
63
|
- <%= Money.DDL.execute(Money.DDL.create_money_with_currency) %>
|
63
|
<%= Money.DDL.execute(Money.DDL.create_money_with_currency()) %>
|
64
64
|
end
|
65
65
|
|
66
66
|
def down do
|
67
|
- <%= Money.DDL.execute(Money.DDL.drop_money_with_currency) %>
|
67
|
<%= Money.DDL.execute(Money.DDL.drop_money_with_currency()) %>
|
68
68
|
end
|
69
69
|
end
|
70
70
|
""")
|
changed
lib/money/migration.ex
|
@@ -16,8 16,8 @@ defmodule Money.Migration do
|
16
16
|
end
|
17
17
|
|
18
18
|
def postgres_money_with_currency_type(repo) do
|
19
|
- query = File.read!("priv/SQL/postgres/get_currency_code_type.sql")
|
20
|
- case repo.query!(query, [], [log: false]) do
|
19
|
query = read_sql_file("get_currency_code_type.sql")
|
20
|
case repo.query!(query, [], log: false) do
|
21
21
|
%Postgrex.Result{rows: [["character varying"]]} ->
|
22
22
|
:varchar
|
23
23
|
%Postgrex.Result{rows: [["character(3)"]]} ->
|
|
@@ -53,4 53,10 @@ defmodule Money.Migration do
|
53
53
|
string
|
54
54
|
end
|
55
55
|
end
|
56
|
|
57
|
defp read_sql_file(file_name) do
|
58
|
:code.priv_dir(:ex_money_sql)
|
59
|
|> Path.join(["SQL", "/postgres", "/#{file_name}"])
|
60
|
|> File.read!()
|
61
|
end
|
56
62
|
end
|
changed
mix.exs
|
@@ -1,7 1,7 @@
|
1
1
|
defmodule Money.Sql.Mixfile do
|
2
2
|
use Mix.Project
|
3
3
|
|
4
|
- @version "1.10.0"
|
4
|
@version "1.10.1"
|
5
5
|
|
6
6
|
def project do
|
7
7
|
[
|