#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok SERIAL,
    meno character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    ulica character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    mesto character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    psc character(5) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    osoba character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    mail character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    telefon character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

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

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='ico') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN ico character(15) NOT NULL DEFAULT '';
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='dic') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN dic character(15) NOT NULL DEFAULT '';
	END IF;
	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='ic_dph') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN ic_dph character(17) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='gln') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN gln character(20) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='banka') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN banka character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='ucet') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN ucet character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='swift') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN swift character(20) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='reg_cislo') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN reg_cislo character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='reg_vydal') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN reg_vydal character(50) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='faktu_prefix') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN faktu_prefix character(10) NOT NULL DEFAULT '';
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='peciatka') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN peciatka bytea;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_prev' and column_name='logo') THEN
		ALTER TABLE <SCHEMA>.edi_prev ADD COLUMN logo bytea;
	END IF;

END IF;

#[ KONEC SOUBORU ]#