#[ ZACATEK SOUBORU ]#

#DEF <SCHEMA>    food600
#DEF <PRIMARYKEY> idriadok
#DEF <TABLENAME> u_ex_obr

#[ CREATE TABLE ZACATEK ]#
    id_man character(2) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    operace character(2) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    partner character(30) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    druh character(20) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    cen_hlad character(2) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    md character(8) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    dal character(8) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    hs_md character(15) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    hs_dal character(15) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    md2 character(15) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    dal2 character(15) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    co character varying(50) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    pz character varying(50) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    poznamka character(30) COLLATE pg_catalog."default" DEFAULT ''::bpchar,
    idriadok SERIAL,
    stare smallint NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 1,
    typ_pohybu smallint NOT NULL DEFAULT 0,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (<PRIMARYKEY>)
#[ CREATE TABLE KONEC ]#

#[ IF EXIST ZACATEK ]#
#[ PRIMARYKEY ]#

	ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN md2 TYPE character(15) COLLATE pg_catalog."default";
	ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN dal2 TYPE character(15) COLLATE pg_catalog."default";

	IF not EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='typ_pohybu') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ADD COLUMN typ_pohybu smallint NOT NULL DEFAULT 0;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='cen_hlad') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN cen_hlad TYPE character(2);
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN cen_hlad SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='partner') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN partner TYPE character(30);
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN partner SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='id_man') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN id_man SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='operace') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN operace SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='druh') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN druh SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='md') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN md SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='dal') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN dal SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='hs_md') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN hs_md SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='hs_dal') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN hs_dal SET DEFAULT ''::bpchar;	
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='md2') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN md2 SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='dal2') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN dal2 SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='co') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN co SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='pz') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN pz SET DEFAULT ''::bpchar;
	END IF;

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='poznamka') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr  ALTER COLUMN poznamka SET DEFAULT ''::bpchar;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='u_ex_obr' and column_name='c_data') THEN
		ALTER TABLE <SCHEMA>.u_ex_obr ADD COLUMN c_data smallint NOT NULL DEFAULT 1;
	END IF;

END IF;

#[ KONEC SOUBORU ]#