\encoding UTF8

-- pridane storno contract_item (cez novy stlpec 'status')
BEGIN;

CREATE TABLE contract_item_status (
	id SERIAL NOT NULL,
	name VARCHAR NOT NULL,
	PRIMARY KEY (id)
);

GRANT SELECT ON contract_item_status TO extranet;
GRANT SELECT ON contract_item_status TO billing;

COMMENT ON TABLE contract_item_status IS 'ciselnik stavov poloziek contract_item';

INSERT INTO contract_item_status (id, name) VALUES (70, 'Zrušený - storno');

ALTER TABLE contract_item ADD COLUMN status INT REFERENCES contract_item_status (id) ON UPDATE CASCADE ON DELETE RESTRICT;
ALTER TABLE contract_item ADD COLUMN comment VARCHAR;

COMMENT ON COLUMN contract_item.status IS 'stav polozky - ID z tabulky contract_item_status';
COMMENT ON COLUMN contract_item.comment IS 'komentar pre interne potreby dodavatela';

COMMIT;
