1 -- @tag: add_customer_mandator_id
 
   2 -- @description: Einführen einer Mandanten-ID- und Signatur-Datums-Spalte bei Kunden.
 
   3 -- @depends: release_3_0_0
 
   5 ALTER TABLE customer          ADD COLUMN mandator_id                  text;
 
   6 ALTER TABLE customer          ADD COLUMN mandate_date_of_signature    date;
 
   7 ALTER TABLE sepa_export_items ADD COLUMN vc_mandator_id               text;
 
   8 ALTER TABLE sepa_export_items ADD COLUMN vc_mandate_date_of_signature date;
 
  10 UPDATE sepa_export_items
 
  11 SET vc_mandator_id = (
 
  12   SELECT c.customernumber
 
  14   LEFT JOIN customer c ON (ar.customer_id = c.id)
 
  15   WHERE ar.id = sepa_export_items.ar_id
 
  17 vc_mandate_date_of_signature = '2010-01-01'::date
 
  18 WHERE ar_id IS NOT NULL;