#[ ZACATEK SOUBORU ]#

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

#[ CREATE TABLE ZACATEK ]#
    id integer NOT NULL DEFAULT 0,
    idriadok SERIAL,
    part_meno character(50) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    part_kod character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    part_extid integer NOT NULL DEFAULT 0,
    dat_vyst date,
    dat_splat date,
    dat_dodani date,
    cislo_pe character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    cislo_fa character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    cislo_vs character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    zakl_0 numeric(10,2) NOT NULL DEFAULT 0,
    zakl_10 numeric(10,2) NOT NULL DEFAULT 0,
    zakl_20 numeric(10,2) NOT NULL DEFAULT 0,
    zakl_celk numeric(10,2) NOT NULL DEFAULT 0,
    dph_10 numeric(10,2) NOT NULL DEFAULT 0,
    dph_20 numeric(10,2) NOT NULL DEFAULT 0,
    dph_celk numeric(10,2) NOT NULL DEFAULT 0,
    c_dokl integer NOT NULL DEFAULT 0,
    prenesene smallint NOT NULL DEFAULT 0,
    c_data smallint NOT NULL DEFAULT 1,
    zasoby smallint NOT NULL DEFAULT 0,
    part_ico character(15) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    cislo_st character(30) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::bpchar,
    zaokruhlen numeric(5,2) NOT NULL DEFAULT 0,
    mattov character(10) 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='exp_faktura' and column_name='zasoby') THEN
		ALTER TABLE <SCHEMA>.exp_faktura ADD COLUMN zasoby smallint NOT NULL DEFAULT 0;
	END IF;

	IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='exp_faktura' and column_name='part_ico') THEN
		ALTER TABLE <SCHEMA>.exp_faktura ADD COLUMN part_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='exp_faktura' and column_name='mattov') THEN
	ALTER TABLE <SCHEMA>.exp_faktura ADD COLUMN mattov character(10) not null default ''::bpchar  ;
END IF;

IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='exp_faktura' and column_name='cislo_st') THEN
	ALTER TABLE <SCHEMA>.exp_faktura ADD COLUMN  cislo_st character(30)  NOT NULL DEFAULT ''::bpchar;
END IF;

IF NOT EXISTS (SELECT column_name FROM information_schema.columns WHERE table_schema='<SCHEMA>' and table_name='exp_faktura' and column_name='zaokruhlen') THEN
	ALTER TABLE <SCHEMA>.exp_faktura   ADD COLUMN zaokruhlen numeric(5, 2) NOT NULL DEFAULT 0;
END IF;

END IF;

#[ KONEC SOUBORU ]#