From: Sven Schöling Date: Fri, 29 May 2015 13:26:58 +0000 (+0200) Subject: Rechnungen: amount, netamount, paid NOT NULL DEFAULT 0 X-Git-Tag: release-3.3.0beta~70 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=36b8f1ece3531e2f5fba5bc38932e450e57bb012;p=kivitendo-erp.git Rechnungen: amount, netamount, paid NOT NULL DEFAULT 0 --- diff --git a/SL/DB/MetaSetup/Invoice.pm b/SL/DB/MetaSetup/Invoice.pm index 72aaa4505..ac7f6716f 100644 --- a/SL/DB/MetaSetup/Invoice.pm +++ b/SL/DB/MetaSetup/Invoice.pm @@ -9,7 +9,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->table('ar'); __PACKAGE__->meta->columns( - amount => { type => 'numeric', precision => 15, scale => 5 }, + amount => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, cp_id => { type => 'integer' }, currency_id => { type => 'integer', not_null => 1 }, cusordnumber => { type => 'text' }, @@ -37,11 +37,11 @@ __PACKAGE__->meta->columns( marge_percent => { type => 'numeric', precision => 15, scale => 5 }, marge_total => { type => 'numeric', precision => 15, scale => 5 }, mtime => { type => 'timestamp' }, - netamount => { type => 'numeric', precision => 15, scale => 5 }, + netamount => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, notes => { type => 'text' }, orddate => { type => 'date' }, ordnumber => { type => 'text' }, - paid => { type => 'numeric', precision => 15, scale => 5 }, + paid => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, payment_id => { type => 'integer' }, quodate => { type => 'date' }, quonumber => { type => 'text' }, diff --git a/SL/DB/MetaSetup/PurchaseInvoice.pm b/SL/DB/MetaSetup/PurchaseInvoice.pm index b3cb02970..cc5eb4d9e 100644 --- a/SL/DB/MetaSetup/PurchaseInvoice.pm +++ b/SL/DB/MetaSetup/PurchaseInvoice.pm @@ -9,7 +9,7 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->table('ap'); __PACKAGE__->meta->columns( - amount => { type => 'numeric', precision => 15, scale => 5 }, + amount => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, cp_id => { type => 'integer' }, currency_id => { type => 'integer', not_null => 1 }, datepaid => { type => 'date' }, @@ -28,11 +28,11 @@ __PACKAGE__->meta->columns( itime => { type => 'timestamp', default => 'now()' }, language_id => { type => 'integer' }, mtime => { type => 'timestamp' }, - netamount => { type => 'numeric', precision => 15, scale => 5 }, + netamount => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, notes => { type => 'text' }, orddate => { type => 'date' }, ordnumber => { type => 'text' }, - paid => { type => 'numeric', precision => 15, scale => 5 }, + paid => { type => 'numeric', default => '0', not_null => 1, precision => 15, scale => 5 }, payment_id => { type => 'integer' }, quodate => { type => 'date' }, quonumber => { type => 'text' }, diff --git a/sql/Pg-upgrade2/invoices_amount_paid_not_null.sql b/sql/Pg-upgrade2/invoices_amount_paid_not_null.sql new file mode 100644 index 000000000..9add1418a --- /dev/null +++ b/sql/Pg-upgrade2/invoices_amount_paid_not_null.sql @@ -0,0 +1,24 @@ +-- @tag: invoices_amount_paid_not_null +-- @description: Bei Rechnungen die drei Spalten "amount", "netamount" und "paid" auf NOT NULL setzen +-- @depends: release_3_2_0 +-- @encoding: utf-8 + +UPDATE ar SET amount = 0 WHERE amount IS NULL; +ALTER TABLE ar ALTER COLUMN amount SET NOT NULL; +ALTER TABLE ar ALTER COLUMN amount SET DEFAULT 0; +UPDATE ar SET netamount = 0 WHERE netamount IS NULL; +ALTER TABLE ar ALTER COLUMN netamount SET NOT NULL; +ALTER TABLE ar ALTER COLUMN netamount SET DEFAULT 0; +UPDATE ar SET paid = 0 WHERE paid IS NULL; +ALTER TABLE ar ALTER COLUMN paid SET NOT NULL; +ALTER TABLE ar ALTER COLUMN paid SET DEFAULT 0; + +UPDATE ap SET amount = 0 WHERE amount IS NULL; +ALTER TABLE ap ALTER COLUMN amount SET NOT NULL; +ALTER TABLE ap ALTER COLUMN amount SET DEFAULT 0; +UPDATE ap SET netamount = 0 WHERE netamount IS NULL; +ALTER TABLE ap ALTER COLUMN netamount SET NOT NULL; +ALTER TABLE ap ALTER COLUMN netamount SET DEFAULT 0; +UPDATE ap SET paid = 0 WHERE paid IS NULL; +ALTER TABLE ap ALTER COLUMN paid SET NOT NULL; +ALTER TABLE ap ALTER COLUMN paid SET DEFAULT 0;