Skip to content

Commit

Permalink
Update operation model
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-sidorov committed Jan 15, 2025
1 parent 5ce1951 commit 585473b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/budget_tracker/operations/operation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ defmodule BudgetTracker.Operations.Operation do
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "operations" do
field :type, Ecto.Enum, values: [:increase, :decrease]
field :action, Ecto.Enum, values: [:increase, :decrease]
field :type, Ecto.Enum, values: [:real, :planned]
field :amount, :float
belongs_to :user, User
belongs_to :debit_account, DebitAccount
Expand Down
4 changes: 3 additions & 1 deletion priv/repo/migrations/20241128220109_create_operations.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ defmodule BudgetTracker.Repo.Migrations.CreateOperations do
import EctoEnumMigration

def change do
create_type(:operation_type, [:increase, :decrease])
create_type(:operation_action, [:increase, :decrease])
create_type(:operation_type, [:real, :planned])

create table(:operations, primary_key: false) do
add :id, :binary_id, primary_key: true
add :type, :operation_type
add :amount, :float
add :action, :operation_action
add :user_id, references(:users, on_delete: :nothing, type: :binary_id)
add :debit_account_id, references(:debit_accounts, on_delete: :nothing, type: :binary_id)

Expand Down

0 comments on commit 585473b

Please sign in to comment.