---    kredit.hot_kred

DO
$$
BEGIN
IF EXISTS (SELECT table_name FROM information_schema.tables WHERE table_schema='kredit' and table_name='hot_kred') THEN
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='izba') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN izba character(5) NOT NULL DEFAULT ''::BPCHAR;
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='account_id') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN account_id integer NOT NULL DEFAULT 0;
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='dieta') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN dieta character(5) NOT NULL DEFAULT '';
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='stol') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN stol character(10) NOT NULL DEFAULT ''::BPCHAR;
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='stolicka') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN stolicka integer NOT NULL DEFAULT 0;
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='miestnost') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN miestnost character(30) NOT NULL DEFAULT ''::BPCHAR;	
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hot_kred' and column_name='id_hores') THEN
		ALTER TABLE kredit.hot_kred ADD COLUMN id_hores integer NOT NULL DEFAULT 0;	
	END IF;
END IF;


---    HKREDOBR

IF EXISTS (SELECT table_name FROM information_schema.tables WHERE table_schema='kredit' and table_name='hkredobr') THEN
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hkredobr' and column_name='id_limit') THEN
		ALTER TABLE kredit.hkredobr  ADD COLUMN id_limit integer NOT NULL DEFAULT 0;
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hkredobr' and column_name='id_den') THEN
		ALTER TABLE kredit.hkredobr  ADD COLUMN id_den integer NOT NULL DEFAULT 0;
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='kredit' and table_name='hkredobr' and column_name='id_rov') THEN
		ALTER TABLE kredit.hkredobr  ADD COLUMN id_rov integer NOT NULL DEFAULT 0;
	END IF;
END IF;

END
$$
