
CREATE SEQUENCE invadjgrp_id_seq
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 2147483647
  START 1
  CACHE 1;
ALTER TABLE invadjgrp_id_seq
  OWNER TO admin;
GRANT ALL ON TABLE invadjgrp_id_seq TO admin;
GRANT ALL ON TABLE invadjgrp_id_seq TO xtrole;



---- CREATE TABEL invadjgrp -------
CREATE TABLE invadjgrp
(
  invadjgrp_id integer NOT NULL DEFAULT nextval(('invadjgrp_id_seq'::text)::regclass),
  invadjgrp_name  TEXT,
  invadjgrp_transdate  date,
  invadjgrp_location_id integer,
  invadjgrp_posted boolean,
  invadjgrp_comments TEXT,
  
    CONSTRAINT invadjgrp_pkey PRIMARY KEY (invadjgrp_id ),

    CONSTRAINT invadjgrp_location_fkey FOREIGN KEY (invadjgrp_location_id)
        REFERENCES location (location_id) 
      ON UPDATE CASCADE ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);


ALTER TABLE invadjgrp
  OWNER TO admin;
GRANT ALL ON TABLE invadjgrp TO admin;
GRANT ALL ON TABLE invadjgrp TO xtrole;
COMMENT ON TABLE invadjgrp
  IS 'Inventory Adjustment Group';


CREATE INDEX invadjgrp_name_ix  ON invadjgrp  USING btree  (invadjgrp_name);
CREATE INDEX invadjgrp_location_id_ix  ON invadjgrp  USING btree  (invadjgrp_location_id);
CREATE INDEX invadjgrp_transdate_ix  ON invadjgrp  USING btree  (invadjgrp_transdate);
CREATE INDEX invadjgrp_posted_ix  ON invadjgrp USING btree  (invadjgrp_posted);
CREATE INDEX invadjgrp_comments_ix  ON invadjgrp USING btree  (invadjgrp_comments);

update invadjgrp SET invadjgrp_posted = false where invadjgrp_posted IS NULL;
ALTER TABLE invadjgrp ALTER COLUMN invadjgrp_posted  SET NOT NULL;
ALTER TABLE invadjgrp ALTER COLUMN invadjgrp_posted  SET DEFAULT false;

ALTER TABLE invadjgrp ADD COLUMN invadjgrp_void boolean NOT NULL DEFAULT false;