#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    idriadok SERIAL,
    id_ediprev integer NOT NULL DEFAULT 0,
    c_partner integer NOT NULL DEFAULT 0,
    edi_kod character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    edi_kodstr character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    CONSTRAINT <TABLENAME>_<PRIMARYKEY> PRIMARY KEY (idriadok)
#[ CREATE TABLE KONEC ]#

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

	IF EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='edi_part' and column_name='edi_kod') THEN
		ALTER TABLE <SCHEMA>.edi_part  ALTER COLUMN edi_kod TYPE character (50) COLLATE pg_catalog."default";	
	ELSE 
		ALTER TABLE <SCHEMA>.edi_part  ADD COLUMN edi_kod character (50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar ;	
	END IF;

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

#[ KONEC SOUBORU ]#