Skip to content

Commit

Permalink
remove transaction stock_id null contraint
Browse files Browse the repository at this point in the history
  • Loading branch information
superspike7 committed Jul 15, 2022
1 parent 71d4646 commit d4319cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/transaction.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Transaction < ApplicationRecord
validates_presence_of :amount

belongs_to :stock
belongs_to :stock, optional: true
belongs_to :user

after_create :update_shares
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RemoveStocknullFromTransactions < ActiveRecord::Migration[7.0]
def change
change_column_null :transactions, :stock_id, true
remove_index :transactions, name: "index_transactions_on_stock_id"
end
end
3 changes: 1 addition & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d4319cc

Please sign in to comment.