Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change invoices.issue_date database column to NOT NULL #1107

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Invoice < ActiveRecord::Base

scope :overdue, -> { unpaid.non_cancelled.where('due_date < ?', Time.zone.today) }

validates :issue_date, presence: true
validates :due_date, :currency, :seller_name,
:seller_iban, :buyer_name, :items, presence: true
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeInvoicesIssueDateToNotNull < ActiveRecord::Migration
def change
change_column_null :invoices, :issue_date, false
end
end
4 changes: 3 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ CREATE TABLE public.invoices (
total numeric(10,2) NOT NULL,
in_directo boolean DEFAULT false,
buyer_vat_no character varying,
issue_date date
issue_date date NOT NULL
);


Expand Down Expand Up @@ -4934,6 +4934,8 @@ INSERT INTO schema_migrations (version) VALUES ('20190311111718');

INSERT INTO schema_migrations (version) VALUES ('20190312211614');

INSERT INTO schema_migrations (version) VALUES ('20190315172802');

INSERT INTO schema_migrations (version) VALUES ('20190319133036');

INSERT INTO schema_migrations (version) VALUES ('20190322152123');
Expand Down
16 changes: 0 additions & 16 deletions lib/tasks/data_migrations/populate_invoice_issue_date.rake

This file was deleted.

5 changes: 0 additions & 5 deletions test/models/invoice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ def test_overdue_scope_does_not_return_invoices_with_due_due_of_today_or_in_the_
assert_not Invoice.overdue.include?(@invoice), 'Should not return non-overdue invoice'
end

def test_invalid_without_issue_date
@invoice.issue_date = nil
assert @invoice.invalid?
end

def test_optional_vat_rate
@invoice.vat_rate = nil
assert @invoice.valid?
Expand Down
37 changes: 0 additions & 37 deletions test/tasks/data_migrations/populate_invoice_issue_date_test.rb

This file was deleted.