Skip to content

Commit

Permalink
🗃️ Add active field to funds
Browse files Browse the repository at this point in the history
- Defaults to true
- Set to `read_after_writes: true` for now to ensure we get back the DB default after creating/updating
- Not (yet) adding it to any changesets; funds should be created active
  • Loading branch information
randycoulman committed Jul 14, 2024
1 parent 2284f62 commit 64712af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/freedom_account/funds/fund.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ defmodule FreedomAccount.Funds.Fund do
typed_schema "funds" do
belongs_to :account, Account

field :active?, :boolean, null: false, read_after_writes: true, source: :active
field(:budget, Money.Ecto.Composite.Type) :: Money.t()
field :icon, :string, null: false
field :name, :string, null: false
Expand Down
10 changes: 10 additions & 0 deletions priv/repo/migrations/20240714040705_add_active_to_funds.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule FreedomAccount.Repo.Migrations.AddActiveToFunds do
use Ecto.Migration

@spec change :: any()
def change do
alter table(:funds) do
add :active, :boolean, default: true, null: false
end
end
end
2 changes: 2 additions & 0 deletions test/support/factory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ defmodule FreedomAccount.Factory do
@spec fund_attrs(Fund.attrs()) :: Fund.attrs()
def fund_attrs(overrides \\ %{}) do
Enum.into(overrides, %{
# This is done automatically by the database
# active?: true,
budget: money(),
icon: fund_icon(),
name: fund_name(),
Expand Down

0 comments on commit 64712af

Please sign in to comment.