2 -- we use target date as a proxy for ship date in planning stuff.
3 ALTER TABLE cohead ADD COLUMN cohead_targetdate DATE;
4 CREATE INDEX cohead_targetdate ON cohead USING btree (cohead_targetdate);
7 -- store intended source in coitem and default in cohead - can be null..
8 ALTER TABLE coitem ADD COLUMN coitem_location_src INTEGER DEFAULT NULL;
9 ALTER TABLE coitem ADD CONSTRAINT coitem_location_src
10 FOREIGN KEY ( coitem_location_src ) REFERENCES location (location_id)
14 -- store intended destination on (defaults to matching cohead..)
15 ALTER TABLE coitem ADD COLUMN coitem_shipto_id INTEGER DEFAULT NULL;
16 ALTER TABLE coitem ADD CONSTRAINT coitem_shipto_id
17 FOREIGN KEY ( coitem_shipto_id ) REFERENCES shiptoinfo(shipto_id)
22 ALTER TABLE cohead ADD COLUMN cohead_location_src INTEGER;
23 ALTER TABLE cohead ADD CONSTRAINT cohead_location_src
24 FOREIGN KEY ( cohead_location_src ) REFERENCES location (location_id)
28 -- changes to ship head so they ship per locations..
31 ALTER TABLE shiphead ADD COLUMN shiphead_location_id INT;
32 ALTER TABLE shiphead ADD CONSTRAINT shiphead_location_id
33 FOREIGN KEY ( shiphead_location_id ) REFERENCES location (location_id)
37 ALTER TABLE shiphead ADD COLUMN shiphead_shipto_id INT;
38 ALTER TABLE shiphead ADD CONSTRAINT shiphead_shipto_id
39 FOREIGN KEY ( shiphead_shipto_id ) REFERENCES shiptoinfo(shipto_id)
43 CREATE INDEX shiphead_shipto_id_ix ON shiphead USING btree (shiphead_shipto_id);
44 CREATE INDEX shiphead_location_id_ix ON shiphead USING btree (shiphead_location_id);
46 ALTER TABLE cmhead ADD COLUMN cmhead_billto_cntct_id integer;
47 ALTER TABLE cmhead ADD COLUMN cmhead_billto_addr_id integer;
48 ALTER TABLE cmhead ADD COLUMN cmhead_location_id integer;
55 ADD CONSTRAINT cmhead_cmhead_billto_cntct_id_fkey FOREIGN KEY (cmhead_billto_cntct_id)
56 REFERENCES cntct (cntct_id) MATCH SIMPLE
57 ON UPDATE NO ACTION ON DELETE NO ACTION;
60 ADD CONSTRAINT cmhead_cmhead_salesrep_id_fkey FOREIGN KEY (cmhead_salesrep_id)
61 REFERENCES salesrep (salesrep_id) MATCH SIMPLE
62 ON UPDATE NO ACTION ON DELETE NO ACTION;
65 ADD CONSTRAINT cmhead_cmhead_taxzone_id_fkey FOREIGN KEY (cmhead_taxzone_id)
66 REFERENCES taxzone (taxzone_id) MATCH SIMPLE
67 ON UPDATE NO ACTION ON DELETE NO ACTION;
70 ADD CONSTRAINT cmhead_cmhead_location_id FOREIGN KEY (cmhead_location_id)
71 REFERENCES location (location_id) MATCH SIMPLE
72 ON UPDATE NO ACTION ON DELETE NO ACTION;
75 ADD CONSTRAINT cmitem_itemsite_id FOREIGN KEY (cmitem_itemsite_id)
76 REFERENCES itemsite (itemsite_id) MATCH SIMPLE
77 ON UPDATE NO ACTION ON DELETE NO ACTION;
79 -- bills - add a revision number..
81 ALTER TABLE cobmisc ADD COLUMN cobmisc_rev INT DEFAULT 0;
82 ALTER TABLE shiphead ADD COLUMN shiphead_rev INT DEFAULT 0;